Re: File Names with Spaces ???

Subject: Re: File Names with Spaces ???
From: "Kent Fitch" <kent.fitch@xxxxxxxxxxxx>
Date: Fri, 2 Apr 1999 13:48:39 +1000
From: harryk <harryk@xxxxxxxxxxx>


> How do I use xsl to process the element 
> <MATL>NEW FILE WITH SPACES.PDF</MATL>
> that contains a file name with spaces so that it is
> attached to the <A HREF with the %20 in the spaces. e.g.,
> NEW%20FILE%20WITH%SPACES.PDF ???
> 
> <A HREF="http://mysite/NEW FILE WITH SPACES.PDF>NEW FILE WITH
> SPACES.PDF</A>
> 
> 
> It appears that IE5 inserts the %20 automatically, while
> Netscape 4.5 does not.
> Is there a way, using xsl, to insure that the file name will always be
> seen
> with %20 in the spaces by either/any browser.

I've been doing something like this using the IE5 XSL implementation
on the server (which allows escape to script):

...
<xsl:template match="A | a">
  <xsl:element name="A">
   <xsl:for-each select="@*"> 
    <xsl:choose>
     <xsl:when test=".[nodeName() = 'HREF' or  nodeName() = 'href']">
      <xsl:attribute><xsl:eval>escURLValue(this)</xsl:eval></xsl:attribute>
     </xsl:when>
     <xsl:otherwise>
      <xsl:attribute><xsl:value-of select="." /></xsl:attribute>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:for-each>
  <xsl:apply-templates/>
 </xsl:element>
</xsl:template>

....

<xsl:script><![CDATA[

function escURLValue(node) {
 if (node == null) return "" ; //!!?
 var str =  node.text ;
 if (str == null) return "" ;
 ... (some other irrelevant pre-processing) ..
 return str.replace(/ /g, "%20") ;
}
...

Kent Fitch                           Ph: +61 2 6276 6711
ITS  CSIRO  Canberra  Australia      kent.fitch@xxxxxxxxxxxx




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


Current Thread