Hi,

I have problem with XSLT transformation, SAX content-lexical handler and
CDATA
section. I based my application architecture on SAX transformation and
pipeline mechanims and now I have passed the deadline of my project and I
have many others
staff to implement for my application. I already posted this message to
xalan-dev mailing list, 
but may be a Xalan user can help me.

Here is the trouble I have:

My XmlProducer sends SAX events to SAX Transformer handler as follow:

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<custom:metadata xmlns:custom="http://www.imtf.com/edoc/metadata/custom/";>
   <custom:section1><![CDATA[<<<Yvan Hess>>>]]></custom:section1>
   <section2>SECTION 2 WITHOUT CDATA</section2>
</custom:metadata>

I created a transformer handler using the follwing stylesheet:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:custom="http://www.imtf.com/edoc/metadata/custom/";>
   <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"
        cdata-section-elements="custom:section1 section2"/>
   <xsl:template match="/">
         <xsl:copy-of select="."/>
   </xsl:template>
</xsl:stylesheet>

and intialized as follow:
......
transformerHandler = saxTFactory.newTransformerHandler(template);
SAXResult result = new SAXResult();
result.setHandler(xmlConsumer);        /*Dummy handler showing SAX events*/
result.setLexicalHandler(xmlConsumer); /*Dummy handler showing SAX events*/
transformerHandler.setResult(result);
//transformerHandler.setResult(new StreamResult(System.out)); ---> see
trouble (2)

HERE ARE THE TROUBLES I HAVE:

Beetween my XML producer and the XST transformer handler, I put a dummy
handler verifying events and I get the following (only interesting event are
showed):

DUMMY[BEFORE XSLT]: Call startDocument
DUMMY[BEFORE XSLT]: Call startCDATA
DUMMY[BEFORE XSLT]: Call characters
DUMMY[BEFORE XSLT]: Call endCDATA
DUMMY[BEFORE XSLT]: Call characters
DUMMY[BEFORE XSLT]: Call endDocument

The result of the conversion is send to a dummy handler verifying SAX events
and    and I get the following (only interesting event are showed):

DUMMY[AFTER XSLT]: Call startDocument
DUMMY[AFTER XSLT]: Call characters
DUMMY[AFTER XSLT]: Call characters
DUMMY[AFTER XSLT]: Call characters
DUMMY[AFTER XSLT]: Call endDocument

1) The lexical handler is not called as for example startCDATA-endCDATA,
only content handler events. I don't understand why because I have CDATA
section and the others chained handler doesn't work correctly (as for
example a serializer) because they expected to have CDATA section.
2) If instead of transmitting the result to a SAX handler, I send it to a
StreamResult (see commented code above) and I get the following

<?xml version="1.0" encoding="ISO-8859-1"?>
<custom:metadata xmlns:custom="http://www.imtf.com/edoc/metadata/custom/";>
<custom:section1>&lt;&lt;&lt;Yvan Hess&gt;</custom:section1>
<section2><![CDATA[SECTION 2 WITHOUT C]]><![CDATA[DATA]]></section2>
</custom:metadata>
 
As you can see section2 have be wrapped with a CDATA section, sorry with 2
section CDATA; I would like to have only one section data! But as you can
see also section1 has not been wrapper with a CDATA section. It seems that
namespace are treated correctly. I did a standalone test and I get the same
problem with section having a namespace!

For your information, I am using JVM 1.3.1, Xalan-j_2_5_D1 and xerces-2_4_0.

Please help me, I am in a very critical situation due to this problem. 

Regards. Yvan Hess


Reply via email to