XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
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?

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
 
http://ajwelch.blogspot.com/2008/08/lexev-xmlreader-converts-lexical-events.html
 
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!
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay



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:text>

</xsl:text>

   </xsl:variable>

 

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

 

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

     The outer target node list.

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

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

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

      <xsl:copy>

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

      </xsl:copy>

   </xsl:template>

 

   <xsl:template match="p">

      <xsl:copy>

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

      </xsl:copy>

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

   </xsl:template>

  

</xsl:stylesheet>

 

 

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

 

    private void init(Writer writer)

    {

      try

      {

         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);

         serialT.setResult(streamResult);

 

         // set the super pass through to point to here

         super.setContentHandler(serialT);

         super.setLexicalHandler(serialT);

      }

      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()

    {

      m_charWriter.reset();

    }

   

    private TransformerFactory getTransformerFactory()

    {

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

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

       return transFact;

    }

 

 

 

www.bluestream.com

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