[Home] [By Thread] [By Date] [Recent Entries]
Hi,
It seems that it might be useful to determine if the context item is set. Of course, currently, the best is to keep it set at all times, it works, even if it is not always very pretty. Using something like you suggested or like this:
<xsl:template name="abc">
<xsl:param name="target" select="."/>
<xsl:message>
<xsl:for-each select="$target">
<xsl:copy-of select="."/>
</xsl:for-each></xsl:message>
</xsl:template>
Still fails if the context item is not set, prior to invocation.As David pointed out, the most usual case is calling one of these push&pull templates from a function, prior to (re-)setting the context node. There must have been a good reason for functions not to inherit the calling context item, at least until they change it, like in (called) templates ... It can be quite useful to initialize parameters from the context node as in ... <xsl:param name="status" select="if (string(@status) then @status else 'new'"/> where, if context item is not set, then $status = 'new', for example. Ensuring that the context node is set at all times, does the trick. Thanks for the info. Cheers, ac Michael Kay a icrit : Why error "The context item is not set", when the context is not set, on something like this:
|

Cart



