Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2004, 04:06 PM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating CDATA Sections

I'm using XSL to transform two XML documents into one tailor formatted XML document. Because some of the elements will need to contain HTML, I need to specify them as CDATA sections. Is there an easy way to do this with XSL?

At the moment I'm having to use the following code (although it works fine, it seems a little over the top):

<xsl:element name="value">
<xsl:value-of disable-output-escaping="yes" select="concat('&lt;','![CDATA[')" />
<xsl:value-of select="text()" />
<xsl:value-of disable-output-escaping="yes" select="concat(']]', '&gt;')" />
</xsl:element>

Are there any alternative methods?

 
Old November 17th, 2004, 07:19 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need an output element with the names of the elements that contain cdata as follows:
Code:
<xsl:output cdata-section-elements="value"/>
If you have more than one element separate the names with spaces.

In my opinion this method of storing html within xml rarely works, it always limits what you can do later but I realise that there are no perfect solutions.


--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Config Sections Muhammad Zeeshan BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 February 3rd, 2008 01:23 AM
Add a CDATA section; add nodeset to CDATA section kssudhish XSLT 3 January 3rd, 2008 07:13 AM
I need Help Customizing the Grouping Sections ... raza_mrk36 Crystal Reports 2 January 21st, 2006 01:24 AM
Sections formatting s_chilkury Crystal Reports 0 December 21st, 2005 06:46 AM
How to move sections lxken XSLT 5 April 28th, 2004 06:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.