[thelist] XSLT 2.0 replace < > special characters

Mozer, Matt Matt_Mozer at intuit.com
Mon Apr 25 09:46:46 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. 
This code below works for replace any http(s) with say a text result such as
"fred" or "bob" - for example. You can see what I am trying to do with it
though with the a href.

<xsl:template match="whatever">


<xsl:value-of select='replace(.,"(https?:\/\/[^\s]*)", "<a



The element in this case "whatever" could have multiple http references and
are contained in a text element of arbitrary content and length. So, with
that being said, the below example is not what I'm looking for as someone
has already pointed out. I have tried something similar to no avail.

<xsl:template match="//addr">

    <xsl:element name="a">

       <xsl:attribute name="href">

          <xsl:value-of select="."/>


       <xsl:value-of select="."/>




I need to be able to escape the "<" & ">" characters or change my approach
entirely... I think this would prove to be a valuable tool if it were to




More information about the thelist mailing list