is it possible to access a query string using xslt?
i have a url e.g
www.example.com/page.aspx?k=aa&lang=en
I want to do something like
i
is it possible to access a query string 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 the str-split-to-words template 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:
lang = en
Do note the use of the FXSL 1.x str-split-to-words
template and the use of the EXSLT ext:node-set()
extension function.
XSLT 2.0 solution:
lang = " "
When the above XSLT 2.0 transformation is performed, it produces the correct result:
lang = "en"