cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulrich Mayring <u...@denic.de>
Subject Re: URL Encoding
Date Fri, 23 Jun 2000 10:34:00 GMT
Geoff Drake wrote:
> 
> Can anyone help me out with this problem.
> 
> I have an XSLT Style sheet that needs to build an HREF.  It all works
> except when the input field contains spaces.
> How do I get XSLT to url-encode a string i.e. replace blank etc. with +
> % etc.
> 
> The code is as follows.
> 
> <xsl:element name="a">
> <xsl:attribute name="href">pharmdisplay.xml?postcode=<xsl:value-of
> select="postcode"/></xsl:attribute>
> </xsl:element>
> 
> It works if postcode contains 'ABC'  but not when it contains 'ABC 123'
> 
> How do I code the first xsl:value-of select="postcode" to return a
> correct url encoded reference?

Just pass the postcode in as a parameter and then do an XSP page with:

<xsp:logic>
     <xsp:expr>
         
<postcode>url.encodeURL(request.getParameter("postcode"))</postcode>
     </xsp:expr>
</xsp:logic>

Note that I'm not sure about the syntax of the Java method encodeURL,
you should check your Java API documentation, I believe the method
belongs to the URL class.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

Mime
View raw message