You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Hess Yvan <yv...@imtf.ch> on 2003/04/09 17:28:50 UTC
HELP!! Xalan trouble using XSLT transformation, SAX content-lexic
al handler and CDATA section
Hi,
Your are my last chance to solve big trouble I have with Xalan. 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 and I have many others
staff to implement. Please...help me.
Here is the trouble I have:
My Xml producer send 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 (lexical and content hanlder)*/
result.setLexicalHandler(xmlConsumer); /* Dummy handler showing SAX
events (lexical and content hanlder)*/
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><<<Yvan Hess></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