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

RE: Saxon and Sun Serializer problems?

  • From: "Jim Tivy" <jimt@bluestream.com>
  • To: "'Michael Kay'" <mike@saxonica.com>,<xml-dev@l...>
  • Date: Fri, 29 May 2009 14:40:38 -0700

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

 

http://www.w3.org/TR/2004/REC-xml-infoset-20040204/

 

in 2.1 notes that under the document node -  If there is a document type declaration, the list also contains a http://www.w3.org/TR/2004/REC-xml-infoset-20040204/#infoitem.doctype 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.

 

Jim

 

 


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