[thelist] XSLT search and replace Regex and escaping Special Characters...
Mozer, Matt
Matt_Mozer at intuit.com
Sat Apr 23 15:53:06 CDT 2005
I am trying to do a search and replace on an element with a regex. The
problem I am having is on the replace. I am looking for any http(s) strings
and needing to create an href out of it.
The syntax looks like...
<xsl:template match="whatever">
<xsl:copy>
<xsl:value-of select='replace(.,"(https?:\/\/[^\s]*)", "<a
href=$1>$1</a>")'/>
</xsl:copy>
</xsl:template>
I can't figure out how to escape the "<" & ">" characters... I have tried a
number of different ways... \<; > and < <![CDATA[ ]>; hex equivalent
and putting the select inside an <xsl:element name="a"> - Nothing has worked
and all of the examples I have seen don't give me exactly what I need.
Unfortunately, escaping the <> doesn't work since the XML parser won't
decode it, the browswer will instead so It just prints out a href on the
page.
Anyone better than me with XSLT? :-)
Thank you.
More information about the thelist
mailing list