Re: space replaced with %20

Subject: Re: space replaced with %20
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sun, 15 Oct 2000 19:31:41 +0100
Eric,

>Have this is my xsl:
>
>      <xsl:for-each select="//index">
>        <xsl:sort select="@entry"/>
>        <p><a href="{../@location}"><xsl:value-of select="@entry"/></a></p>
>      </xsl:for-each>
>
>I get the appropriate information except that some of the @location
>attributes have spaces in them, and for each of these, the space is replaced
>with %20 (e.g., location="d:\new docs\doc1" ends up as
>"d:\new%20docs\doc1"), which causes my link not to work.  (Using Instant
>Saxon--not sure if this makes a difference.)

If you are outputting HTML (as it looks like you are), then you will be
using the 'HTML' output method which automatically escapes any href values.
 From the Rec:

"The html output method should escape non-ASCII characters in URI attribute
values using the method recommended in Section B.2.1 of the HTML 4.0
Recommendation."

When an HTML browser encounters an escaped URI it should deal with it
properly - I'm not sure but it's possible that you're having problems
because the 'URI's that you're using are local paths - try doing:

  <a href="file:///{../@location}">...</a>

instead and see if that makes a difference.

If you want to stop the URI from being escaped, then you could force SAXON
to use the 'xml' output method instead using:

<xsl:output method="xml" />

but this may cause you problems in other areas (such as outputting closing
tags and doing all the other things that are taken care of for you with the
HTML output method).

I hope that helps somewhat,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread