tags:

views:

34

answers:

2

Hi All,

I am using xsl to convert data from xml into C++ code. I am running into problems when I have <= or >= in the xml file that needs to be converted to C++ code.

For example if I have (in .xml file)

 
<Check>max(x,y) <= 20 </Check>
 

and the .xsl file is


if(<xsl:value-of select="Check"/>") {
...
}

But this does not compile as XML errors out on seeing <=.

I tried &lt;= in xml file but I don't get <= in C++ file but I get &lt;=. To be user friendly I need to have <= in xml file rather than &lt;=.

How can I fix the code within if() condition so that I can handle all the escape characters in xml and properly output them to a C++ file?

Thanks Anand

+1  A: 

You can't have the < sign in the XML file - if you do it's not an XML file and won't be parsed by other editors etc. so I think you need to go with the &lt ; = strategy and parse the field after you read it to replace the & sequences with the desired characters from the C code.

Elemental
+3  A: 

Have you set an xsl:output element in your stylehsheet? By default, XSLT thinks its output is XML, and will escape characters. Try this:

<xsl:output method="text" />
Ned Batchelder
It works. Thanks a lot
Anand