![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - URL Encoded for white space [Thread Next] Re: URL Encoded for white spaceTo: 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/
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
