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]
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