Subject: RE: How to search for <, >, etc. in a string?
From: Brian Young <Brian.Young@xxxxxxx>
Date: Thu, 28 Sep 2000 15:17:41 -0400
|
Hello Mike,
That is exactly what was getting me. I'm learning more and more gotchas everyday. It keeps me on my toes and makes it fun!
Thanks,
Brian Young
-----Original Message-----
From: Kay Michael [mailto:Michael.Kay@xxxxxxx]
Sent: Wednesday, September 27, 2000 12:37 PM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: 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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|