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 July 18th, 2008, 02:17 PM
Authorized User
Join Date: Oct 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to avoid multiple display of CDATA

I'm using XSLT 1.0. I need help on NOT displaying multiple CDATAs in a tag.

Here is my snippet of XSLT:
<xsl:output method="xml" version="1.0" encoding="UTF-8" cdata-section-element="Room"/>

<xsl:template match="Room">
    <xsl:call-template name="Pen_Template"/>
    <xsl:call-template name="Pencil_Template"/>
<xsl:template name="Pen_Template">Blue Pen,</xsl:template>
<xsl:template name="Pencil_Template">Black Pencil</xsl:template>

The output is the following:
<Box><![CDATA[Blue Pen,]]><!CDATA[Black Pencil]]></Box>

What I like my output to be is the following:
<Box><![CDATA[Blue Pen,Black Pencil]]></Box>

Please help.
Old July 18th, 2008, 03:16 PM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

Your XSLT processor isn't being very clever here, but it's acting within the rules, and there's no obvious way of changing its behaviour. You could switch to a better XSLT processor, or you could write to the vendor and complain. Alternatively, a trick that might work is to concatenate the results of the two template calls in a variable and then output the variable (or perhaps in two separate variables, and output <xsl:value-of select="concat($v1, $v2)"/>)

But do you really need the output in CDATA sections, and why? Any XML parser will treat it exactly the same if it's not in a CDATA section.

Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference

Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoid multiple logins gabrieldcr2 ASP.NET 1.0 and 1.1 Professional 1 March 6th, 2008 11:47 AM
Multiple Image Upload/Display rstelma ASP.NET 1.0 and 1.1 Professional 3 February 22nd, 2007 03:25 PM
Avoid null display ajaidass ADO.NET 2 January 17th, 2007 03:54 PM
Multiple Tables Display in XSL bmagadi XSLT 1 February 8th, 2005 03:06 PM
Display results from multiple tables Librarian Classic ASP Databases 6 July 6th, 2004 11:28 PM

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