- From: David Carlisle <davidc@nag.co.uk>
- Date: Tue, 8 Jan 2002 14:58:28 GMT
- To: www-xpath-comments@w3.org
Xpath variables may be bound in the host language to any value, but xpath2 introduces variable bindings within xpath. The current draft allows variables to be bound to an object of any type except sequence. eg for $x in (1) return .... some expression involving $x ... gives a local scope in which $x is bound to 1. Due to the restriction that sequences can not contain sequences (what is the rationale for this restriction?) I don't think it is currently possible to bind a variable to a sequence, certainly the "obvious extension" of the above for $x in ((1, 2)) return .... some expression involving $x ... doesn't work as ((1, 2)) isn't a sequence of length 1, but is the sequence (1,2) of length 2, so $x isn't bound to (1,2) but rather the for loop iterates with $x being 1 then 2.+ If a let clause were added to xpath then one could perhaps consider getting rid of the full for expression and instead allow a simplified form that just used . as an implicit range variable (and moved the focus to match). then if this focus needed to be saved before executing any nested expression one could use a let clause if needed to bind a variable to . this would be analogous to xsl:for-each where most of the time just accessing . (or current()) is sufficient but occasionally you need to use <xsl:variable name="x" select="."/> to save the current node. David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service.
Received on Tuesday, 8 January 2002 09:59:34 UTC