[xsl] testing for presence of a variable
 
Subject: [xsl] testing for presence of a variable 
 
From: Bruce D'Arcus <bdarcus@xxxxxxxxx> 
 
Date: Fri, 6 May 2005 18:59:30 -0400 
 | 
 
Is there a way I can condition a variable on the presence (or absence) 
of another variable?
I have a crucial global variable in my stylesheets which goes through a 
document a collects all the citation references.  This works well when 
I have self-contained documents.  However, in the case of the 
manuscript I just finished, I needed to first include the individual 
chapters into a variable, and then run the stylesheets on that.
To get it to work thus required adding the $chapters variable to the 
path.
<xsl:variable name="citerefs" 
select="($chapters)//db:biblioref/@linkend"/>
If I then run the stylesheets on a standalone document that doesn't 
include this variable, it fails.
So I'm wanting to do something like this:
  <xsl:variable name="root-node" select="if ($chapters) then 
($chapters) else ()"/>
  <xsl:variable name="citerefs" 
select="($root-node)//db:biblioref/@linkend"/>
... but get an  error about the missing $chapters.
Any suggestions?
Bruce