[xslt] XPath string functions question.



I am trying to transform xml into c++ code. I want to put the original 
xml source tree in c++ comments (/* ... */) so that people know where 
the c++ code was transformed from.

For example:

//////////////// Xml ///////////////////////////////////
<mylist>
    <item>foo</item>
    <item>bar</item>
</mylist>

///////////////// c++ code //////////////////////////////
/*
  Following code was created from xml source tree:
  <mylist>
    <item>foo</item>
    <item>bar</item>
  </mylist>
*/
std::vector<std::string> mylist;
mylist.push_back("foo");
mylist.push_back("bar");

However there is one problem bothering me. If in the xml source tree, 
there is any string containing substring "*/", it will break the c++ 
comment in c++ code.
For example:
//////////////// Xml ///////////////////////////////////
<mylist>
    <item>foo</item>
    <item>bar</item>
    <item>item that breaks comment because of */</item>
</mylist>

///////////////// c++ code //////////////////////////////
/*
  Following code was created from xml source tree:
  <mylist>
    <item>foo</item>
    <item>bar</item>
    <item>item that breaks comment because of */</item>
  </mylist>
*/
std::vector<std::string> mylist;
mylist.push_back("foo");
mylist.push_back("bar");
mylist.push_back("item that breaks comment because of */");


Is there anyway I can recursively check all nodes in the source tree to 
see if there is any string containing substring "*/"?

Thanks.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]