RE: Context item, context position, context size

> 
> I think we should clearly say that if there is no context item, the 
> context position and context size are undefined. It is not 
> reasonable to 
> have no context item but set the context position to 42 and 
> the context 
> size to 43.

Agreed.
> 
> I think we should clearly say that if there is a context item, the 
> context position and context size are 1. It is not meaningful to say 
> that the single context item is in position 42 of some 
> sequence to which 
> the query has no access. (Obviously, the context item might have a 
> position in a child sequence to which the query has access).
> 

When XPath is hosted in XSLT, it is normal for the context position on
entry to an XPath expression to be a value other than one. For example
the following idiom is common:

<xsl:for-each select="author">
  <xsl:value-of select="."/>
  <xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>

Here the context on entry to the XPath expression "position()!=last()"
reflects the position of the context item in the sequence of authors.

I don't see a strong reason to prohibit it in XQuery if it makes sense
in XPath.

Michael Kay

Received on Tuesday, 10 February 2004 16:23:02 UTC