Subject: Re: [xsl] Serializing elements in CDATA, based on an attribute value From: "cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 13 Apr 2017 09:11:23 -0000 |
Ok, thanks a lot. I'm gonna look at both solutions. Best regards, Christophe
The only way of getting CDATA sections output by the serializer using standard XSLT capabilities, or using standard Saxon capabilities, is the cdata-section-elements property, and that is driven entirely by element name. For finer-grained control you'll have to do something else.
One approach would be output the relevant elements with a different name, e.g. METADATA, and specify cdata-section-elements="METADATA". You can then replace < METADATA and </METADATA by <metadata and </metadata by post-processing the serialized output at the text level.
If you're feeling more adventurous it's not difficult to inject a custom processing step into the Saxon serialization pipeline by nominating your own subclass of Saxon's SerializerFactory.
Michael Kay Saxonica
On 12 Apr 2017, at 14:23, cmarchand@xxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Hello,
In a document, I write many tags of metadata. Part of them, based on @code value (debug & info), MUST be serialized with a CDATA content.
With this input : <metadata code="dummy">Standard serialization</metadata> <metadata code="debug">C-Data serialization</metadata> <metadata code="foe">Standard serialization</metadata> <metadata code="info">C-Data serialization</metadata>
I do expect this : <metadata code="dummy">Standard serialization</metadata> <metadata code="debug"><![CDATA[C-Data serialization]]></metadata> <metadata code="foe">Standard serialization</metadata> <metadata code="info"><![CDATA[C-Data serialization]]></metadata>
What must I define as serialization parameters to get this ? I use Saxon 9.7EE, so I can use Saxon extensions.
Thanks in advance, Christophe
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Serializing elements in C, Michael Kay mike@xxx | Thread | [xsl] Select everything up to and i, Rick Quatro rick@xxx |
Re: [xsl] Select everything up to a, Michael Müller-Hille | Date | Re: [xsl] Select everything up to a, Wendell Piez wapiez@ |
Month |