[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] prevent xslt ant task using xalan from converting CDATA to spaces


Subject: Re: [xsl] prevent xslt ant task using xalan from converting CDATA to spaces
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 25 Feb 2004 20:52:32 GMT

> How do I prevent the CDATA from being transformed into spaces ?
?? It isn't being transformed into spaces.
The sole purpose of CDATA is to "auto" quote < and & XPath does not
record whether a < character was input as &lt; or as <![CDATA[<]]> these
are equivalent input and both reported by the parser as a single <
character, so XSLT can not distinguish these.

Why do you need it to be something that looks like a comment but inside
a Cdata section rather than a real comment? If your input file had a
real comment you wouldn't have the problem, you could just copy the
comment node. 

If you can't change the input, then if this text is inside an element
rather thna at the top of the file you can specify that element as a
cdata-section-elements attribute to xsl:output, then it will linearise
the content of that element using CDATA rather than character entities.

Note however that either format is equivalent to teh next xml parser in
the chain though so this should be a cosmetic change.


      <!-- Evil work-around for Xalan warning message about not being able to
           copy the jsp:root version attribute which is mandatory for JSP -->

You'd be getting that because you are trying to add attributes (by
applying templates to @*) after you have added your jsp:directive and
jsp:scriptlet elements and you have to add attributes first.

remove the |@* from your apply-templates and instead have 
<xsl:copy-of select="@*"/> immeditately after the xsl:copy.

David


-- 
http://www.dcarlisle.demon.co.uk/matthew

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords