Reputation: 71
How would I, using XQuery, transform
<author>John Smith</author>
to
<author><![CDATA[John Smith]]></author>
?
Also, how would I transform
<content><p><em>Hello</em></p></content>
to
<content><![CDATA[<p><em>Hello</em></p>]]></content>
?
If it matters, I am using XSLPalette.app.
Upvotes: 2
Views: 5283
Reputation: 71
Solution:
declare namespace saxon="http://saxon.sf.net/";
declare option saxon:output "cdata-section-elements=content";
Thanks to Jim Garrison for inspiring me to search the Saxon documentation a little more carefully.
Upvotes: 1
Reputation: 86754
XSLPalette seems to use Saxon under the covers, so it should support the cdata-section-elements option on xsl:output. See http://www.w3.org/TR/xslt#output for details.
Essentially, if the underlying XSLT processor supports it, you can code
<xsl:output cdata-section-elements="name1 name2 ... etc"/>
The value of cdata-section-elements is a space-separated list of tag names for which child text nodes are to be output as CDATA sections.
I'll be curious to know if this works with XSLPalette.
Upvotes: 1