xml to c++: handling escape characters <=
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 <= in xml file but I开发者_StackOverflow中文版 don't get <= in C++ file but I get <=. To be user friendly I need to have <= in xml file rather than <=.
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
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" />
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 < ; = strategy and parse the field after you read it to replace the & sequences with the desired characters from the C code.
精彩评论