| Author |
need < & > sign after applying XSLT
|
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
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
Joined: Oct 11, 2004
Posts: 3829
|
|
This software was converting and, gt and colon to > so I had to mention it like this...
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
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
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
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
Joined: Oct 11, 2004
Posts: 3829
|
|
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
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
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.
|
 |
 |
|
|
subject: need < & > sign after applying XSLT
|
|
|