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: bvijaykr1@xxxxxxxxxxx
Date: Thu, 26 Feb 2004 01:36:13 +0000
Thanks for the reply.I cannot change the input.The xslt is to add code before and after many jsp pages.I cannot determine beforehand what the cdata-section-elements will be for pages which will be created in the future.

The problem with &lt; instead of <![CDATA[ being used is that it puts /r/n after some data in some of the CDATA sections.
eg:
<![CDATA[<input type="hidden" name="controllerLocation" value="]]>
          <c:out value="${tabLocationUrl}"/>
          <![CDATA["/>]]>

gets converted to data but there is a /r/n added at the end now and it totally screws up my application logic.I just  want the xslt processor to not change the CDATA sections if possible.

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


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


Current Thread