No there's nothing wrong with your code, it's another Saxon bug.
It's looking quite a pig's ear. I think I made a change here to make the
JAXP interface work according to spec (which is itself pretty treacherous)
and this caused an upset here. The basic problem is working out how the
serialization parameters supplied via the API relate to those specified
inside the transformation or query, and for s9api that has never been very
clearly defined. I think the rule should probably be that a parameter
supplied via the API overrides one supplied in the query or transformation
source. Unfortunately the code isn't structured to make that easy to
achieve, so I'm having a bit of trouble devising a patch - especially
without destabilizing the rather delicate JAXP code in this area.
I'm working on it.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: saxon-help-bounces@...
> [mailto:saxon-help-bounces@...] On Behalf
> Of Norman Walsh
> Sent: 22 July 2008 16:05
> To: saxon-help@...
> Subject: [saxon] omit-xml-declaration?
>
> Hi Michael,
>
> Is there something obvious wrong with this code, with respect
> to omit-xml-declaration, I mean?
>
> XQueryCompiler xqcomp = qtproc.newXQueryCompiler();
> XQueryExecutable xqexec = xqcomp.compile(".");
> XQueryEvaluator xqeval = xqexec.load();
> xqeval.setContextItem(node);
>
> Serializer serializer = new Serializer();
>
>
> serializer.setOutputProperty(Serializer.Property.BYTE_ORDER_MA
> RK, "no");
> serializer.setOutputProperty(Serializer.Property.ENCODING,
> "utf-8");
> serializer.setOutputProperty(Serializer.Property.INDENT, "no");
> serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
>
> serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECL
> ARATION, "yes");
>
> ByteArrayOutputStream os = new ByteArrayOutputStream();
> serializer.setOutputStream(os);
>
> xqeval.setDestination(serializer);
> xqeval.run();
>
> String result = os.toString();
>
> The resulting string seems to *always* have an XML declaration.
>
> Be seeing you,
> norm
>
> --
> Norman Walsh <ndw@...> | It does not do harm to the mystery to
> http://nwalsh.com/ | know a little about it. For far more
> | marvelous is the truth than
> any artists
> | of the past imagined!--Richard Feynman
>
|