XSLT pass node into CDATA JS
Posted
by davomarti
on Stack Overflow
See other posts from Stack Overflow
or by davomarti
Published on 2010-03-15T18:49:39Z
Indexed on
2010/03/15
19:29 UTC
Read the original article
Hit count: 357
I have the following xml
<AAA>
<BBB>Total</BBB>
</AAA>
Transforming it with the following xslt using the xsl:copy-of tag, because I want to use the xml to create a xml doc in js.
<xsl:template match="/">
<![CDATA[
function myFunc() {
xmlStr = ']]><xsl:copy-of select="/"/><![CDATA[';
}
]]>
</xsl:template>
The output looks like this
function myFunc() {
xmlStr = '<AAA>
<BBB>Total</BBB>
</AAA>';
}
JS doesn't like this because of the missing semicolons ending the lines. How can I fix my xsl to get the below result:
function myFunc() {
xmlStr = '<AAA><BBB>Total</BBB></AAA>';
}
I've tried normalize-space() and translate() but they strip the tags from the xml.
Thanks!
© Stack Overflow or respective owner