Andrey Shitov
XSLT string resources 2 December 2005 |
|
Task: | Remind what function document() can do. |
||
Function document() is usually used to locate external files. However, few programmers remember (and some never knew) that it also allows to parse the current XSLT templatethe calling file itself.
Just write document('').
Compatibility |
Both popular XSLT processorslibxslt and msxslenable this equally well. |
Take for example the XSLT template that returns the name of the month (a string) when the input is the following XML code:
|
The resource strings are stored directly in the XSLT file. To retrieve them, use simple XPath expression document('')/xsl:stylesheet/... following usual XSLT rules.
|
Note that you have to declare a namespace.