Encode URL in XSLT

If you need to URL encode something in XSLT, you can use serverside – not perfect, but it gets the job done. Here is the and below you can find link to a simpel XSLT which has the script implemented.

   1:    <script language="javascript" xmlns="urn:schemas-microsoft-com:xslt" implements-prefix="js">
   2:      <![CDATA[ 
   3:      // This will return a URI encoded string
   4:      function encodeURL(sUrl) {
   5:        sUrl.MoveNext();
   6:        sUrl = sUrl.Current.Value;
   7:        return (sUrl);
   8:      }
   9:      ]]>
  10:    </script>

Find example XSLT here: http://dl.dropbox.com/u/3260327/xslt/js_encodeURL.xslt


Leave a Reply