Testing for presence of a variable
Hi everyone!
I came across a little problem recently and I need to know if there's a way to solve this.
Let's say I have a style sheet called "wrapper.xsl" that imports two other stylesheets called "doSomething.xsl" and "placeHolder.xsl".
"wrapper.xsl" defines a variable named "location" which is used in "doSomething.xsl". However, due to the nature of my application, I sometimes need to use "doSomething.xsl" directly, without "wrapper.xsl".
My question is: is it possible to check for the presence of a variable in the context of "doSomething.xsl"?
I was thinking of something like this in "doSomething.xsl":
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="hasLocation">
<xsl:choose>
<xsl:when test="boolean($location)">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/">
<xsl:if test="$hasLocation">
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I don't know if there is a solution. I probably will find a workaround in the application, but still, I find this issue interesting.
Thanks,
Rushman
Dijkstra's law on Programming and Inertia:
If you don't know what your program is supposed to do, don't try to write it.
__________________
Dijkstra's law on Programming and Inertia:
If you don't know what your program is supposed to do, don't try to write it.
|