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

Create CDATA Section in XML Output

Subject: Create CDATA Section in XML Output
From: Mark Miller <storefront2000@xxxxxxxxx>
Date: Tue, 9 Oct 2001 07:10:56 -0700 (PDT)
xsl create cdata
Greetings,

I need to output a CDATA tag in the XML output.
I've tried using cdata-section-elements="grammar"
as an output attribute, but just get a jumbled
mess of CDATA tags.

Example:
<grammar><![CDATA[
[]]><![CDATA[
(]]><![CDATA[mccoy]]><![CDATA[) 
]]><![CDATA[
(]]><![CDATA[doc]]><![CDATA[) 
]]><![CDATA[
(]]><![CDATA[bones]]><![CDATA[) 
]]><![CDATA[] {]]><![CDATA[<]]><![CDATA[question1]]>
<![CDATA[ ]]><![CDATA[mccoy]]><![CDATA[>]]><![CDATA[}
]]></grammar>

It looks as if every single token is being placed in
a seperate CDATA section, instead of one CDATA
surrounding the contents of the tag.

If I don't use cdata-section-elements="grammar" in the
output element, I get the correct output for the
grammar tag, but the VoiceXML interpreter won't accept
it without the CDATA surrounding. I've tried replacing
the opening and closing (lt/gt) symbols with entities,
but that didn't work either.

I'm using Xerces/Xalan. Any solutions would be greatly

appreciated. 

Thanks,
Mark


XML INPUT
---------

   <!-- QUESTION 1 -->
   <set>
      <question recording="mccoy-bricklayer.wav">
         I'm a doctor, not a bricklayer.
      </question>
      <answers>
         <answer
recording="startrek-mccoy-name.wav">mccoy</answer>
         <answer>doc</answer>
         <answer>bones</answer>
      </answers>
      <hint recording="">
         He, supposedly, did not get along with Spock.
      </hint>
   </set>
   

DESIRED OUTPUT
--------------
...

	<grammar>
	<![CDATA[
	   [(mccoy) (doc) (bones)] {<question1 mccoy>}
	]]>
	</grammar>
...


CURRENT XSLT
------------
<xsl:template match="set">
...
<grammar>
  [<xsl:apply-templates select="answers/answer"/>] 
  {&lt;<xsl:value-of select="concat('question', 
        position())"/><xsl:text> </xsl:text>
  <xsl:value-of select="answers"/>&gt;}
</grammar>

...
	
</xsl:template>

<xsl:template match="answers">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="answer">
   (<xsl:apply-templates/>)<xsl:text> </xsl:text>
</xsl:template>




__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.