[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Saxon and Sun Serializer problems?

  • From: "Jim Tivy" <jimt@bluestream.com>
  • To: <xml-dev@lists.xml.org>
  • Date: Fri, 29 May 2009 13:38:54 -0700

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;

    }

 

 

 

http://www.bluestream.com

Jim Tivy

604 669 4469 x116

 



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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.