Blog

URL encoding with PHP XSL

2007-06-02 14:41:25 by Martynas Jusevičius

In many situations, strings have to be encoded using the % notation before put in the URL, to avoid confusion with reserved characters such as : or /.

XSLT 1.0 has no standard function for URL encoding. In XSLT 2.0, encode-for-uri() function can be used. However, there are solutions for URL encoding in XSLT 1.0.

In case of the ISO-8859-1 charset, one can use encoding/decoding stylesheets from skew.org. It gets much more complicated with UTF-8 and a pure XSLT solution is not realistic — extension functions have to be used instead.

Using PHP's XSL extension, PHP's functions can be called directly from the stylesheet. registerPhpFunctions() method has to be called on the XSLT processor instance and PHP's namespace (http://php.net/xsl) has to be included in the stylesheet before doing that. Then PHP's urlencode() can be called from the stylesheet in such a way: php:function('urlencode', string('value')).

Digg Digg this! del.icio.us del.icio.us!

Comments (6)

hello guys need advice

2008-12-26 08:01:39 by cwxwwwxdfvwwxwx

well, hi admin adn people nice forum indeed. how's life? hope it's introduce branch ;)

Herigate of Pakistan

2009-06-06 08:57:48 by Pakistan

Discover the beauty of pakistan. Learn the culture, heritage, traditions and landmarks of different parts of Pakistan especially sindh, punjab, balochistan and N.W.F.P and far northern areas.

vydvlmlrei

2009-06-15 13:51:09 by vydvlmlrei

Mjtx0U <a href="http://iuqackzktagh.com/">iuqackzktagh</a>, [url=http://exnszyaztgim.com/]exnszyaztgim[/url], [link=http://qpmrceilusoo.com/]qpmrceilusoo[/link], http://wxmqtihdqcls.com/

xCbBtQnmVxGDEoIQRU

2009-12-02 10:31:33 by fzsdpq

269NMi <a href="http://bxqgxwquptrq.com/">bxqgxwquptrq</a>, [url=http://stycouvfjbqd.com/]stycouvfjbqd[/url], [link=http://tkssfiwinfdz.com/]tkssfiwinfdz[/link], http://jnxdqahazrew.com/

uIBrzktykgSNBDPMt

2009-12-20 02:01:10 by hsjsbeaixp

7J1I2A <a href="http://ydxhyuepguym.com/">ydxhyuepguym</a>, [url=http://lktgtfowanhe.com/]lktgtfowanhe[/url], [link=http://faomsyhyculh.com/]faomsyhyculh[/link], http://edeecpvgfrde.com/

wiHSJPhoCOAaNbIxrT

2009-12-24 04:44:42 by mklnggesgg

9QUtyD <a href="http://whqoburflwsu.com/">whqoburflwsu</a>, [url=http://wrqhbjntlpiw.com/]wrqhbjntlpiw[/url], [link=http://hvdqqservlqf.com/]hvdqqservlqf[/link], http://jypmabfybkwv.com/

New comment






No HTML allowed.