[xsl] XSLT 2.0 replace()

Subject: [xsl] XSLT 2.0 replace()
From: Lou Iorio <lou@xxxxxxxxxxxx>
Date: Tue, 2 Sep 2008 09:18:47 -0400
Just learning XSLT 2.0 (and regex), and I'm stumped on the replace() function.

I have XML that looks like this:

<toc>
<category title="Structure">
<item title="&amp;lt;attribute&amp;gt;" href="tag.attribute.html" />
<item title="&amp;lt;handler&amp;gt;" href="LzDelegate.html" />
<item title="&amp;lt;event&amp;gt;" href="LzEvent.html" />
.
.
.


And I want to replace the &amp; with just &, so the HTML that looks like this:

 <body>
     <h1>nav toc</h1>
     <ol>
        <li>Structure</li>
        <ol>
           <li>&lt;lattribute&gt;</li>
           <li>&lt;handler&gt;</li>
           <li>&lt;event&gt;</li>

The closed I've been able to get is this:

  <body>
     <h1>nav toc</h1>
     <ol>
        <li>Structure</li>
        <ol>
           <li>&lt;attribute&amp;gt;</li>
           <li>&lt;handler&amp;gt;</li>
           <li>&lt;event&amp;gt;</li>

So I can change the first &amp;, but not the second. Any ideas? I feel like I
must be missing a fundamental concept here.


Here's a fragment of my XSLT:

<ol>
<xsl:for-each select="category">
<li>
<xsl:value-of select="@title"/>
</li>
<ol>
<xsl:for-each select="item">
<li>
<xsl:value-of select="replace(@title, '&amp;lt;', '&lt;')"/>
</li>
</xsl:for-each>
</ol>
</xsl:for-each>
</ol>


thanks,

Lou

Current Thread