• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need < & > sign after applying XSLT

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a requirement where I need following line in an XML file (this file is generated after applying XSLT):



This number is generated dynamically (with the help of for loop).

Now if I write following line in my XSLT:

*![CDATA[<xsl:value-of select='position()'/>]]*

Where first star is: and, lt and colon.
And last star is: and, gt and colon.

I get following in my output XML file:

*![CDATA[2]]*

Which doesn't solve my purpose.

I can't write like this in my XSLT:




Please help. How do I get this?

Thanks.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This software was converting and, gt and colon to > so I had to mention it like this...


 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you don't really need that, you know. The CDATA section is really just a convenience for people whose serializers can't handle escaping properly and for people typing XML into a text editor. You can just as well output this:

and all compliant XML parsers will treat that exactly the same as they would treat

However it's possible to have your XSLT output as CDATA every text child of elements with specific names. Look up the "cdata-section-elements" attribute of the xsl:output element.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ankur rathi wrote:This software was converting and, gt and colon to < so I had to mention it like this...



You can escape those characters in the forum exactly as you would escape them in an XML document.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Well, you don't really need that, you know. The CDATA section is really just a convenience for people whose serializers can't handle escaping properly and for people typing XML into a text editor. You can just as well output this:

and all compliant XML parsers will treat that exactly the same as they would treat

However it's possible to have your XSLT output as CDATA every text child of elements with specific names. Look up the "cdata-section-elements" attribute of the xsl:output element.



Thanks Paul.

I have added cdata-section-elements="namelist" in my xsl:output tag but it doesn't make any difference.
Do I need to change something in xsl:value-of tag?

Thanks.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It worked for me when I just tried it. But I have no idea what "namelist" is so I can't suggest anything except providing information about your question.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic