I am working in a framework (cocoon) which means that the pages after I produce them are re-transformed by processes I have little or no control of. What I am doing is making a web service call, then transforming the results into an HTML page for presentation. Sounds like a job for XSLT. Everything works fine, until the data returned in an XML text node has an '&' character in it. The returned XML is properly escaped, but I want to put it into the href attribute of an anchor node. Everything I have tried ends up with the unescaped '&' character showing up in the href attribute. For example:
If the node returned from the web service looks like:
<ns:name>Foo&Bar</ns:name>
The resulting <a>
token (in the page source) looks like:
<a href="ADifferentPage.jsp?name=Foo&Bar">Foo&Bar</a>
My current XSLT code looks like:
<a>
<xsl:attribute name="href">
ADifferentPage.jsp?name=<xsl:value-of select="ns:name" />
</xsl:attribute>
<xsl:value-of select="ns:name" />
</a>
The desired result is:
<a href="ADifferentPage.jsp?name=Foo&Bar">Foo&Bar</a>