xsl-list
[Top] [All Lists]

RE: [xsl] push-pull

2008-03-19 02:22:05

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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--