Re: [xsl] Copy CDATA nodes from XML to XML format w/ XALAN

Subject: Re: [xsl] Copy CDATA nodes from XML to XML format w/ XALAN
From: Morten Primdahl <morten@xxxxxxx>
Date: Mon, 04 Mar 2002 13:42:09 +0100

Thanks for the pushing me in the right direction Mike, it's really appreciated. I've been having a lot of fun with copy and copy-of!

I added a call-template element to the <xsl:template match="text()">
example you gave, and can now succesfully perform some search/replace
on the output being generated. More specifically I can escape all
quotes contained in the text elements within data element.

Ie. the following

<data>
<a>
 <b>"Bub"</b>
</a>
</data>

Gets translated to <a><b>\"Bub\"</b></a> - which is what I want it
to. But if one of the descendants of the data element contain an
attribute, I need to escape the quotes used there as well, eg.

<data>
<a>
 <b foo="bar">"Bub"</b>
</a>
</data>

Should become <a><b foo=\"bar\">\"Bub\"</b></a> - I'm beginning to
doubt if this is at all possible as it's no longer "just content",
but syntax I'm messing with (sort of).

I tried using my search/replace template directly on the output
from the copy elements, but that just resulted in all tagged
elements getting filtered away.

I would prefer if there was some way to just treat the content
of the data element like a string value, there's no way to
have copy-of to copy the current node to a variable rather than
the output (or something similar)?

Thanks,

Morten



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


Current Thread