omit-xml-declaration?

View: New views
4 Messages — Rating Filter:   Alert me  

omit-xml-declaration?

by Norman Walsh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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_MARK, "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_DECLARATION, "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


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

attachment0 (191 bytes) Download Attachment

Re: omit-xml-declaration?

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
>


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: omit-xml-declaration?

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've logged and described the bug at

https://sourceforge.net/tracker/index.php?func=detail&aid=2025294&group_id=2
9872&atid=397617

and have put a patch in Subversion. I decided the least disruptive fix was
to create a new interface between the s9api XsltTransformer/XQueryEvaluator
and the Serializer which is used in place of the current getReceiver() call;
it merges the output properties defined in the query/stylesheet with those
defined in the Serializer API and uses the combined set to create a
serialization pipeline; the SerializerFactory is also changed so that when
the destination is an Emitter, whose output properties have already been
set, then no further change to the output properties is made.

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
>


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: omit-xml-declaration?

by Norman Walsh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

/ "Michael Kay" <mike@...> was heard to say:
| I've logged and described the bug at
|
| https://sourceforge.net/tracker/index.php?func=detail&aid=2025294&group_id=2
| 9872&atid=397617
|
| and have put a patch in Subversion.

Works for me, thanks again!

                                        Be seeing you,
                                          norm

--
Norman Walsh <ndw@...> | I finally figured out the only reason
http://nwalsh.com/            | to be alive is to enjoy it.--Rita Mae
                              | Brown


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

attachment0 (191 bytes) Download Attachment
LightInTheBox - Buy quality products at wholesale price