Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: URL Encoded for white space

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 8/10/2007 3:07:00 PM

kamkaro wrote:
> Can someone help me regarding to the white space url encoded. For instance, i 
> have a xml tag which has multiple values 'sun set, sea site, under water' ( 
> with spaces) and i have to give link but i can not give link if i have 
> spaces. The following sample link using 'id' param and i would like to give 
> link (using URL Encoded) to sun set, sea site, under water. I can create the 
> param=id for multiple values but how do i handle with whipe space????
> 
> Sample link <a href="Action?pg=60000&idtype={idtype}&id={id}">

Can you use an extension function? For instance with MSXML and .NET you 
can implement one using JScript as follows:

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:msxsl="urn:schemas-microsoft-com:xslt"
   xmlns:mf="http://example.com/2007/functions"
   exclude-result-prefixes="msxsl mf"
   version="1.0">

   <xsl:output method="html"/>

   <msxsl:script language="JScript" implements-prefix="mf">
   function urlEscape (str) {
     return encodeURIComponent(str);
   }
   </msxsl:script>

   <xsl:template match="text">
     <a href="page.asp?param={mf:urlEscape(string(.))}">link test</a>
   </xsl:template>

</xsl:stylesheet>

then the result of transforming
<text>sun set, sea site, under water</text>
is
<a 
href="page.asp?param=sun%20set%2C%20sea%20site%2C%20under%20water">link 
test</a>

See also EXSLT.NET at 
<http://www.codeplex.com/MVPXML/Wiki/View.aspx?title=EXSLT.NET&referringTitle=Home>

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent