[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] [Fwd: %20 in href attribute]
Subject: RE: [xsl] [Fwd: %20 in href attribute] From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Wed, 30 Jan 2002 18:48:25 -0000 |
> When use a variable with string value, which contains spaces > after the > #, as the value of href attribute to the <a> tag, the transformer > automatically replaces the spaces with %20 and causes the link not > recognize the anchor in the targeting page. Is there a work > around for > that? Sample code as follow: > > <xsl:variable name="url" select="$urlink/@url"/> > <a href="{$url}" target="ext_link" onclick="new_win()"><xsl:value-of > select="$title"/></a> > > href value desired: > http://www.state.ma.us/dhcd/components/dns/HtOHA.htm#About > Our Programs > what I got: > http://www.state.ma.us/dhcd/components/dns/HtOHA.htm#About%20O > ur%20Programs > This is a tricky one. The XSLT spec says that the whole URI reference should be escaped, which is what is happening. XSLT 1.0 doesn't say that the "name" attribute of the <a> element should be escaped, although HTML 4.0 recommends this. But it's worse than that: in XHTML the name attribute is replaced with an id attribute, and the id attribute is of type ID, which means it must be an NCName, which means it cannot be URI-escaped, because it cannot contain a "%" character. The best workaround is to only use NCName values, containing ASCII characters only, as your fragment identifiers. I know that's not very satisfactory. XSLT 2.0 provides an option to disable escaping of URI values in HTML output. We're currently trying to define a function that would allow you to do the escaping by hand. This would give you finer control, e.g. you could avoid escaping the fragment identifier, and you could avoid escaping javascript: URLs, which is another case that often causes problems. Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [Fwd: %20 in href attribu, Jeni Tennison | Thread | [xsl] How to create a temporary xml, Khalid |
Re: [xsl] JSP &XML/XSL in netscape , Paul Sprakes | Date | Re: [xsl] insert an attribute value, Joerg Heinicke |
Month |