Search code examples
xsltxslt-2.0

XSLT: Check if variable exits, was declared


I need to check if a variable is declared, because there were different .xsl documents included with different variables and I need to check if the variable was declared so I can use it in my process?

I always get an Error with my Process. Message: Variable sortedNumbers has not been declared (or its declaration is not in scope)

I use XSLT 2.0

My XSLT Code:

<xsl:if test="exists($sortedNumbers) and $sortedNumbers = 'true' >

Solution

  • You need to re-think your approach. If you have a stylesheet A that sometimes imports B and sometimes imports C, then you are doing things the wrong way round: the special-purpose stylesheet module should import the general-purpose module.