Subjects
Home
Xalan extension functions
Fomatting question serializing DOM with pretty print
xalan with pull parser
Cannot find the declaration
Apache Xalan drop support to run on JRE 1 1 x
Why does Doctype change processing of a document
Node set to XML string via Java extensions in Xalan J: possible?
Templates/Transformers + thread safety???
Problem evaluating xpath with muliple prefix with different namespace
remove an arbitrary attribute from xsl output
Xalan3 XSLT 2 0 XPath 2 0 support?
Problem using compiled translets with Xalan !!
Xalan and jstl 1 1 problem with transform tag
NullPointer in DOM2DTM getLocalName
URIResolvers base parameter with xsltc and cascaded imports
Performance problem for Xalan J on intel dual core
Standard libraries in JAXP?
Serializing a DOM tree to XML file, customize entities replacement
Library Conflict Involving BCEL Library
A question on how users are using <xsl:message >
Kevin Cormier as a new Apache Xalan J committer
Struggling to iterate over tokenized string
Xalan count() trouble
Problem with recursive xpath
Error when switching to java 1 5
document( ' ')
Problem with Xalan2 7 0 transformation
cr/lf options
entity encoded XML
can xalan transform 2 xml using one xslt?
Xalan J JIRA defect review Monday October 16, 2006 from 2:00 to 3:30 pm ED
xsl transform with cdata section elements
xslt parameters not expanded
Weird behavior of XPath evaluate()
How to avoid <xsl:message > instruction prints stylesheet file informations ?
Cannot find SimpleTransform subdirectory after installing Xalan J
recover from document not found exceptions
jdk1 5 and Xalan jar differences?
Performance Issue
Error/Bug adding floating point numbers
XPathAPI: eval exp using nodes with default namespace
modifying xalan to output invalid XML
NullPointerException
mege two separate xml nodes into one
Is this a XALAN document identification bug?
is StylesheetRoot really java io Serializable ?
transform() fails for DOMSource but succeeds for StreamSource
Thoughts on Transformer parameter passing
HELP, Xalan and jstl 1 1 problem with transformer
Problem with XPath namespace axis?
string utils:replace deleting search string if replacement string is an HTML
help with enumeration values pls
xalan 2 5 1 vs 2 7 performance question
How to insert/update in XML document
HTML Serialization and Handling of Ampersands in HREF Attributes
XHTML link tag stripping
SystemId Unknown; Line #24; Column #49; java lang NullPointerException
xpath text() help
Apostrophe problem with xalan 2 7 0
How to set variables in XML document?
Links
Home
Oracle database error code ...
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Adjacent CDATA node problems

Adjacent CDATA node problems

2003-03-19       - By Mike McLean
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

I'm currently experiencing much grief over CDATA nodes not transforming
correctly. The exact problem is that the processor outputs adjacent
CDATA nodes for no apparent reason. I've looked at the text through a
hex editor and there are no strange characters causing this to happen.

The problem I'm having seems to be outlined here:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10726

Here's an example of what's happening:

A document containing this:

<element>
  <news>
  High Estrogen/Progestin Levels May Reduce Asthma Severity
  </news>
</element>

Gets transformed to this:

<element>
  <news>
  <![CDATA[High Estrogen/Progestin Levels May Redu]]><CDATA[ce
Asthma Severity]]>
  </news>
</element>

Using a stylesheet which specifies that the news element should be
cdata:
<xsl:output method="xml" encoding="ISO-8859-1"
cdata-section-elements="headline news" media-type="text/xml"
standalone="no" />


- I'm currently using Xalan 2.4.1 (unpatched).
- This is a servlet using Tomcat 4.12
- My web-inf/lib contains (xml related) jaxb-api.jar, jaxb-libs.jar,
jaxb-ri.jar, jaxen-full.jar, xalan.jar, xerces.jar and xercesImpl.jar

Here's some sample code on how I'm doing it all:

JAXBSource source = null;
JAXBContext jc = JAXBContext.newInstance("blabla");
ObjectFactory factory = new ObjectFactory();    
List objects = null;    
Marshaller marshaller = jc.createMarshaller();
....

source = new JAXBSource(jc, dgn);  
marshaller.marshal(dgn, System.out);
   
System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");
TransformerFactory tf = TransformerFactory.newInstance();    
Transformer t = tf.newTransformer(new StreamSource("mysheet.xslt"));
t.transform(source, new StreamResult(transformedOut));
           

The marshal statement sends a string of xml back without any CDATA
nodes. I rely on the Transform to do that.

I would like to upgrade to 2.5.1d but can't because I keep getting this
error as soon as I replace the jar:
The output format must have a
'{http://xml.apache.org/xslt}content-handler' property

So I'm stuck with 2.4.1 unless I resolve this other problem.

Thanks for any input.





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6249.1">
<TITLE>Adjacent CDATA node problems</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">I'm currently experiencing much
grief over CDATA nodes not transforming correctly. The exact problem is that
the processor outputs adjacent CDATA nodes for no apparent reason. I've looked
at the text through a hex editor and there are no strange characters causing
this to happen. </FONT></P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">The problem I'm having seems to
be outlined here: </FONT><A HREF="http://nagoya.apache.org/bugzilla/show_bug
.cgi?id=10726"><U></U><U><FONT COLOR="#0000FF" SIZE=2 FACE="Verdana">http:/
/nagoya.apache.org/bugzilla/show_bug.cgi?id=10726</FONT></U></A><FONT COLOR="
#800000" SIZE=2 FACE="Verdana"> </FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Here's an example of what's
happening:</FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">A document containing this:<
/FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&lt;element&gt;</FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&nbsp;&nbsp; &lt;news&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#800000" SIZE=2
FACE="Verdana">High Estrogen/Progestin Levels May Reduce Asthma Severity</FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&nbsp;&nbsp; &lt;/news&gt;<
/FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&lt;/element&gt;</FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Gets transformed to this:</FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&lt;element&gt;</FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&nbsp;&nbsp; &lt;news&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#800000" SIZE=2
FACE="Verdana">&lt;![CDATA[High Estrogen/Progestin Levels May Redu]]&gt;&lt
;CDATA[ce Asthma Severity]]&gt;</FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&nbsp;&nbsp; &lt;/news&gt;<
/FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&lt;/element&gt;</FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Using a stylesheet which
specifies that the news element should be cdata:</FONT>

<BR><FONT COLOR="#800000" SIZE=2 FACE="Verdana">&lt;xsl:output method=&quot;xml
&quot; encoding=&quot;ISO-8859-1&quot; cdata-section-elements=&quot;<SPAN LANG=
"en-ca">headline news</SPAN><SPAN LANG="en-us">&quot;</SPAN><SPAN LANG="en-ca">
m</SPAN><SPAN LANG="en-us">edia-type=&quot;text/xml&quot; standalone=&quot;no
&quot; /&gt;</SPAN></FONT></P>
<BR>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">- I'm
currently using Xalan 2.4.1 (unpatched).</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">- This is a
servlet using Tomcat 4.12</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">- My web-inf
/lib contains (xml related) jaxb-api.jar, jaxb-libs.jar, jaxb-ri.jar, jaxen-full
.jar, xalan.jar, xerces.jar and xercesImpl.jar</FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Here's some
sample code on how I'm doing it all:</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">JAXBSource
source = null;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">JAXBContext
jc = JAXBContext.newInstance(&quot;blabla&quot;);</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana"
>ObjectFactory factory = new ObjectFactory();&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">List objects
= null;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT><
/SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Marshaller
marshaller = jc.createMarshaller();</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">....&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">source = new
JAXBSource(jc, dgn);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">marshaller
.marshal(dgn, System.out);</FONT></SPAN>

<BR><SPAN LANG="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">System
.setProperty(&quot;javax.xml.transform.TransformerFactory&quot;, &quot;org
.apache.xalan.processor.TransformerFactoryImpl&quot;);</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana"
>TransformerFactory tf = TransformerFactory.newInstance();&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Transformer
t = tf.newTransformer(new StreamSource(&quot;mysheet.xslt&quot;));</FONT></SPAN
>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">t.transform
(source, new StreamResult(transformedOut));</FONT></SPAN>

<BR><SPAN LANG="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>
</P>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">The marshal
statement sends a string of xml back without any CDATA nodes. I rely on the
Transform to do that.</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">I would like
to upgrade to 2.5.1d but can't because I keep getting this error as soon as I
replace the jar:</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">The output
format must have a '{</FONT></SPAN><A HREF="http://xml.apache.org/xslt}content
-handler"><SPAN LANG="en-us"><U></U><U><FONT COLOR="#0000FF" SIZE=2 FACE=
"Verdana">http://xml.apache.org/xslt}content-handler</FONT></U></SPAN></A><SPAN
LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">' property</FONT><
/SPAN>
</P>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">So I'm stuck
with 2.4.1 unless I resolve this other problem.</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT COLOR="#800000" SIZE=2 FACE="Verdana">Thanks for
any input.</FONT></SPAN>
</P>
<BR>
<BR>
<BR>

</BODY>
</HTML>