Subject: Re: [xsl] url encoding of ampersands From: Mike Brown <mike@xxxxxxxx> Date: Sun, 25 Feb 2001 12:36:17 -0700 (MST) |
Sivan Mozes wrote: > 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> According to http://www.w3.org/TR/html401/appendix/notes.html#h-B.2 you really want: <a href="#Cr%C3%A9pe">Crépe</a> or <a href="#Cr%C3%A9pe">Crépe</a> Though if %C3%A9 doesn't work, and if your output encoding is iso-8859-1 or windows-1252, try %E9. > Template: > <xsl:template match="link"> > <xsl:variable name="anchor" select="concat(substring-before( . , > '&'), '%26', substring-after( . , '#'))"/> This won't work because there is no ampersand in your *source tree* (which was *derived* from your original XML). é in your XML is resolved by the XML parser into a single LATIN SMALL E WITH ACUTE character long before the XSLT processor sees it. Likewise, your output will be *derived* from the result tree you construct, hence the automatic conversion of the character in question into é or é by the XSLT processor's result tree serializer, just as it would convert an ampersand into &. <xsl:variable name="anchor" select="concat(substring-before(.,'é'), '%C3%A9',substring-after(.,'é'))"/> - Mike ____________________________________________________________________ Mike J. Brown, software engineer at My XML/XSL resources: webb.net in Denver, Colorado, USA http://skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] url encoding of ampersands, Sivan Mozes | Thread | Re: [xsl] url encoding of ampersand, Sivan Mozes |
[xsl] Extreme Markup Languages 2000, B. Tommie Usdin | Date | Re: [xsl] [exsl] Draft 0.1 - call f, Francis Norton |
Month |