Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I have an xml file that begins like this:
<?xml version="1.0" encoding="UTF-8"?>
<Signature xmlns="http://www.someplace.org/sig" isClass="true">
<Version Number="1.1" Date="2007.04.30"/>
I've created a simple XQuery to return the Header information, which works only if the xmlns attribute DOESN'T exist in the Signature element. So I was wondering if there is a way I can have saxon ignore the xmlns attribute and continue with the query? Any help is greatly appreciated!
Here's the code that I use to create and execute my query:
Configuration config = new Configuration();
StaticQueryContext sqc = new StaticQueryContext(config);
XQueryExpression exp = sqc.compileQuery(" let $doc := . " +
" for $v in $doc//Signature " +
" return $v/Header");
DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
dynamicContext.setContextItem(config.buildDocument(new StreamSource(new File("C:/signature.xml"))));
exp.run(dynamicContext, new StreamResult(new File("C:/result.html")), null);
Thanks in Advance,
Thanks the declare works!
Also, thanks for pointing out x-query.com, I'm heading over there now,..
XQuery coding questions (that have nothing specifically to do with the Saxon implementation) are probably best posted on the XQuery Talk list at x-query.com.
You can't ignore the namespace in which your source elements appear - the namespace is an intrinsic part of the element name of every element in your document. What you can do is to include
declare default element namespace "http://www.someplace.org/sig";
in the query prolog.
Note however that this will also affect any unprefixed element names in element constructors.