is it possible to access a query string using xslt?
i have a url e.g
http://www.example.com/page.aspx?k=aa&lang=en
I want to do something like
if lang = en
<div>displaly stuff</div>
else
<div>display other stuff</div>
can you show me how to do this using xslt?
Yes, if the query string is passed as a parameter.
The code below shows that no extension function is required to access a query-string. It can be passed as a (global) parameter. This is to be preferred as it reduces the need for extensions and results in cleaner and more readable code.
Then one can perform tokenization (with the
tokenize()function in XSLT 2.0 or in XSLT 1.0 using thestr-split-to-wordstemplate of FXSL 1.x or a self-written recursive tokenization template.)XSLT 1.0 solution:
when the above transformation is applied on any XML document (will not be used), the wanted result is produced:
Do note the use of the FXSL 1.x
str-split-to-wordstemplate and the use of the EXSLText:node-set()extension function.XSLT 2.0 solution:
When the above XSLT 2.0 transformation is performed, it produces the correct result: