OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Saxon and Sun Serializer problems?

Thanks Michael


I appreciate your answer althought I might not have the right list or lists - this kind of involves trax too.


I suspected there was a spec reason.  My gut tells me the spec is broken although I respect the fact that these things have to be speced properly - is there no information about the input?


With regards to what a Transform Identity means - what does identity means.  If it means InfoSet identity then if I read Infoset right:




in 2.1 notes that under the document node -  If there is a document type declaration, the list also contains a document type declaration information item.


If it is XPath/XQuery DM identity - then if as you say there may be no idea of a DocType there, then that is a perhaps a flaw.





From: Michael Kay [mailto:mike@saxonica.com]
Sent: Friday, May 29, 2009 2:14 PM
To: 'Jim Tivy'; xml-dev@lists.xml.org
Subject: RE: [xml-dev] Saxon and Sun Serializer problems?


I would suggest asking generic XSLT questions on the xsl-list at mulberrytech.com, and Saxon-specific questions on the saxon-help list at SourceForge.


If you're using XSLT, then DOCTYPE is not part of the data model and is not retained through the transformation. You can generate a DOCTYPE in the output using the doctype-system and doctype-public attributes of xsl:output, but you can't do anything with any DOCTYPE that was present on the input. There's a workaround for this in the form of Andrew Welch's LexEv




If you're using a JAXP identity transformation, then Saxon produces exactly the same result as if you had done the identity transformation in XSLT - things that aren't part of the XDM data model get thrown away. That seems a reasonable interpretation of the spec, though since the JAXP specification is a single sentence, there's room for other interpretations!



Michael Kay


From: Jim Tivy [mailto:jimt@bluestream.com]
Sent: 29 May 2009 21:39
To: xml-dev@lists.xml.org
Subject: [xml-dev] Saxon and Sun Serializer problems?

Hi Folks


I am using saxonb9-1-0-2j


When I serialize through a sax pipeline which is handling ContentHandler and LexicalHandler events and I run through a saxon XSLT transformer, my DOCTYPE dissapears unless I use the the saxon serializer.  When I run through a sax pipeline that just parses and serializes, my DOCTYPE dissapears unless I use the Sun provided serializer.


This causes problems for generalizing the code.




Here is my XSL and serializer setup code below:



**************** XSL

<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>


   <!-- conrefTargets.xsl  

   Make the link target text for the navigation link targets.  This expects topic input.


   <xsl:output method="xml" encoding="UTF-8" />


   <xsl:param name='parm1' select="'Parm1 Default Value'"></xsl:param>



   <!-- Define a newline character -->

   <xsl:variable name='newline'>





   <xsl:variable name='topicId' select='/topic/@id'></xsl:variable>


   <!-- *********************************************************************************

     The outer target node list.

     ********************************************************************************* -->

<!--   <xsl:template match="*|@*|text()"> -->

   <xsl:template match='node()|@*'>


         <xsl:apply-templates select="node()|@*"/>




   <xsl:template match="p">


         <xsl:apply-templates select="node()|@*"/>


      <p class="- topic/p "><xref class="- topic/xref " href=""{$parm1}"" >Hello Link</xref></p>






//******************* SERIALIZER CODE


    private void init(Writer writer)




         TransformerFactory transFact = this.getTransformerFactory();

         SAXTransformerFactory saxTFactory = (SAXTransformerFactory) transFact;

         TransformerHandler serialT = saxTFactory.newTransformerHandler();

         Transformer t = serialT.getTransformer();

         t.setOutputProperty(OutputKeys.METHOD, "xml");  // always Xml

         StreamResult streamResult = new StreamResult(writer);



         // set the super pass through to point to here




      catch (TransformerConfigurationException ex)


         throw new SysException(ex);






     * Returns the Xml string from this serializer.

     * @return String xml.


    public String getXmlString()


       return m_charWriter.toString();




     * clear and reset this class so it can create a new Xml serialization

     * with a fresh set of incoming sax events.

     * WARNING!! This may be called after construction but before any SAX events.

     * You have passed this writer on contruction, so clear it, not its reference.

     * Thats why char writer was chosen.


    public void clear()





    private TransformerFactory getTransformerFactory()


       // TransformerFactory transFact = new net.sf.saxon.TransformerFactoryImpl();

       TransformerFactory transFact = new TransformerFactoryImpl();  // gets the JDK internal one

       return transFact;






Jim Tivy

604 669 4469 x116


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS