RE: [xsl] push-pull

Subject: RE: [xsl] push-pull
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 19 Mar 2008 09:21:30 -0000
> Why error "The context item is not set", when the context is 
> not set, on something like this:
> <xsl:value-of select="if (.) then 'a' else 'b'"/> How else 
> does one check if the context item is set?
> 

There's no way to test whether the context item is currently set. I think
the only case where you can't tell statically is probably within a named
template. I think it's probably good practice for a named template to
declare a parameter:

<xsl:param name="target" select="."/>

and within the body of the template to refer to $target rather than ".". The
caller must then either pass over a context item, or set the value of
$target explicitly.

Michael Kay
http://www.saxonica.com/

Current Thread