RE: How to search for <, >, etc. in a string?
> I have XML that contains some CDATA: > > <string> > <![CDATA[<u>Link containing a & character</u>]]> > </string> > > I'd like to strip out the <u> and </u>,... > > <xsl:when test="starts-with($linkTextUnStripped, '<u>')"> > > The problem is the use of '<' and '>' in the second parameter > of the starts-with function. I tried replacing them with > < and > but I believe that it is then literally looking > for '&' followed by 'l' by 't' by ';' and soforth. > Remember that CDATA and < are all processed by the XML parser before the XSLT processor gets a look in. So the string that the XSLT processor sees is <u>Link containing a & character</u> and the string that you want to look for is <u> So you need to write a string that the XSLT processor will see as <u>, and you can do this by writing <u> in your source stylesheet. The more likely source of your problem is the "starts-with" Your example doesn't start with <u>, it starts with white space. The fact that the white space is outside the CDATA section is irrelevant. Use normalize-space() to remove the white space. Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format