You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bavo De Ridder <ba...@life.be> on 2000/11/23 14:36:24 UTC

url encode question

Hi,

I have an XML that is built using the LDAP processor. One of the fields it
outputs is the cn field. Now I want to use this field in a url like this:

<xsl:element name="a">
                <xsl:attribute name="href">
                employeedetail.xml?cn=<xsl:value-of select="cn" />
        </xsl:attribute>
        <xsl:value-of select="cn" />
</xsl:element>

However, the CN field can and almost always will contain spaces or other
characters that should be encoded. 

How can I accomplish this in XSL ?

I saw something about response:encode-url and the like, but these don't
seem to do the thing I want them to do.

Any help would be greatly appreciated since this "bug" currently stops me
from continuing work on the intranet site.


-- 
Bavo De Ridder

Project Manager Development Services
VA Linux Professional Services Europe
Interleuvenlaan 15A
3001 Haasrode
Belgium
tel.  +32  16 20 89 61
fax.  +32  16 20 79 73  
gsm.  +32 476 24 58 36


Re: url encode question

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
The method java.net.URLEncoder.encode() does just what you want. To call
it from your XSL, you have to declare it as an Xalan extension. Or you
can also more simply generate a new element in your xsp :

<encoded-cn><xsp:expr>java.net.URLEncoder.encode(cnValue)</xsp:expr></encoded-cn>

Hope this helps,
-Sylvain

Bavo De Ridder a écrit :
> 
> Hi,
> 
> I have an XML that is built using the LDAP processor. One of the fields it
> outputs is the cn field. Now I want to use this field in a url like this:
> 
> <xsl:element name="a">
>                 <xsl:attribute name="href">
>                 employeedetail.xml?cn=<xsl:value-of select="cn" />
>         </xsl:attribute>
>         <xsl:value-of select="cn" />
> </xsl:element>
> 
> However, the CN field can and almost always will contain spaces or other
> characters that should be encoded.
> 
> How can I accomplish this in XSL ?
> 
> I saw something about response:encode-url and the like, but these don't
> seem to do the thing I want them to do.
> 
> Any help would be greatly appreciated since this "bug" currently stops me
> from continuing work on the intranet site.
> 
> --
> Bavo De Ridder
> 
> Project Manager Development Services
> VA Linux Professional Services Europe
> Interleuvenlaan 15A
> 3001 Haasrode
> Belgium
> tel.  +32  16 20 89 61
> fax.  +32  16 20 79 73
> gsm.  +32 476 24 58 36
>