This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
url encoding of ampersands
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] url encoding of ampersands
- From: Sivan Mozes <sivan at kiwi dot slip dot net>
- Date: Sun, 25 Feb 2001 00:49:36 -0800 (PST)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Greetings all. Here's a problem I'm working on:
Description:
A link is pointing to an anchor, whose name contains an
accented character. The URL is constructed based on a text node in the
XML to avoid using special characters in an attribute. Next, the
stylesheet needs to replace all ampersands with %26 for URL
encoding.
Example:
XML:
<link type="anchor">Crépe</link>
Expected result:
<a href="#Cr%26#233;pe">Crépe</a>
Template:
<xsl:template match="link">
<xsl:variable name="anchor" select="concat(substring-before( . ,
'&'), '%26', substring-after( . , '#'))"/>
...
</xsl:template>
Actual result:
I am unable to match on the ampersands using contains() or
substring functions, but can see them in the result tree, as the entity
has transformed into é.
I tried various combinations of CDATA, disable-output-escaping, and
others which I can't describe clearly here. translate() can see the
ampersands, but I can't think of a way of using it here.
Help will be greatly appreciated.
Sivan
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list