This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How to search for <, >, etc. in a string?


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@icl.com]
Sent: Wednesday, September 27, 2000 12:37 PM
To: 'xsl-list@mulberrytech.com'
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 
> &lt; and &gt; but I believe that it is then literally looking 
> for '&' followed by 'l' by 't' by ';' and soforth.
>
Remember that CDATA and &lt; 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 &lt;u&gt; 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]