File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating CDATA through XSLT

 
Tushar Kherde
Ranch Hand
Posts: 56
  • 0
  • 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
Pie
Posts: 42966
73
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 42966
73
  • 0
  • 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
  • 0
  • 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

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic