You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Dave Blake <da...@mindcandydesign.com> on 2005/10/21 14:51:21 UTC

URL encoding

I'm constructing a URL in XSL to use as a reference to an external XML 
fragment in document() call. I need to encode the parameters used in the 
URL (space to %20 for example). These parameters are pulled in from an 
XML file which are not URL encoded. I was wondering what the generally 
used solution to this problem is when using Xalan (XSLTC engine). From 
what I can tell, Xalan doesn't have a built in encodeURL type function.

Any help would be appreciated!
Dave.

Re: URL encoding

Posted by Emmanouil Batsis <Em...@eurodyn.com>.
Dave Blake wrote:

> Well, I'm constructing a URL in XSL - hence not in Java - I guess I 
> could use the support in Xalan to call any Java method, but this isn't 
> a great solution. Secondly, although the params I'm pulling in from 
> the XML file are XML-escaped, they are not URL encoded, so this does 
> cause a problem when forming URLs using them.


Aaaah, now it all makes sense. You should address these questions to a 
more suitable forum like the XSL-List.. The archives are extremely helpful

An XSLT template for that is at

http://skew.org/xml/stylesheets/url-encode/

Cheers,

Manos


Re: URL encoding

Posted by Dave Blake <da...@mindcandydesign.com>.
>> I'm constructing a URL in XSL to use as a reference to an external 
>> XML fragment in document() call. I need to encode the parameters used 
>> in the URL (space to %20 for example). These parameters are pulled in 
>> from an XML file which are not URL encoded. I was wondering what the 
>> generally used solution to this problem is when using Xalan (XSLTC 
>> engine). From what I can tell, Xalan doesn't have a built in 
>> encodeURL type function. 
>
> I probably miss something here but whats wrong with 
> java.net.URLEncoder? Also, XML-escaping here is probably irrelevant as 
> you probably obtain the params using an XML API that hides how the 
> params are escaped in the XML.
>
> hth,
>
> Manos

Well, I'm constructing a URL in XSL - hence not in Java - I guess I 
could use the support in Xalan to call any Java method, but this isn't a 
great solution. Secondly, although the params I'm pulling in from the 
XML file are XML-escaped, they are not URL encoded, so this does cause a 
problem when forming URLs using them.

Re: URL encoding

Posted by Emmanouil Batsis <Em...@eurodyn.com>.
Dave Blake wrote:

> I'm constructing a URL in XSL to use as a reference to an external XML 
> fragment in document() call. I need to encode the parameters used in 
> the URL (space to %20 for example). These parameters are pulled in 
> from an XML file which are not URL encoded. I was wondering what the 
> generally used solution to this problem is when using Xalan (XSLTC 
> engine). From what I can tell, Xalan doesn't have a built in encodeURL 
> type function. 


I probably miss something here but whats wrong with java.net.URLEncoder? 
Also, XML-escaping here is probably irrelevant as you probably obtain 
the params using an XML API that hides how the params are escaped in the 
XML.

hth,

Manos