[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Serializing elements in CDATA, based on an attribu

Subject: Re: 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
Re:  Serializing elements in CDATA
Ok, thanks a lot. I'm gonna look at both solutions.
Best regards,
Christophe


Le 2017-04-12 18:14, Michael Kay mike@xxxxxxxxxxxx a C)critB :
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.