This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating CDATA through XSLT

 
Tushar Kherde
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

How can I write XSLT that outputs CDATA nodes?

For example, how would I modify XSLT code that looks like this:

<xsl:element name="root">
<xsl:element name="node">
<xsl:value-of select="value"/>
</xsl:element>
</xsl:element>

to produce an output like this:

<root>
<node><![CDATA[ This is my value ]]></node>
</root>
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need an "<xslutput cdata-section-elements="node"/>" element. Here's some more information on xslutput.
 
Tushar Kherde
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I tried given code but its not working

I am generating XML through XML using XSLT and I want the following output



This is what i have written. Please help how to add <![CDATA[]]>



Please let me know if any explaination is required
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what does your xslutput element look like?
 
Tushar Kherde
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is giving an error

Element must only be used at top level of stylesheet and Element must be empty

This is how i used it, and code is under template tag

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic