[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

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
replacing lt strings in xslt
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 
> &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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.