W3C home > Mailing lists > Public > public-qt-comments@w3.org > February 2004

[XQuery] 3.2 Path expressions returning non-nodes

From: Sarah Wilkin <swilkin@apple.com>
Date: Tue, 3 Feb 2004 11:15:16 -0800
Message-Id: <4CB50CFF-567D-11D8-BA08-0003935B7D94@apple.com>
To: public-qt-comments@w3.org

3.2 Path Expressions
"Each evaluation of E2 must result in a (possibly empty) sequences of 
nodes; otherwise a type error is raised. [err:XP0019]"

We feel XQuery is limited by its focus on nodes. The evaluation of E2 
should be able to contain nodes or atomic values.

The main purpose of this is to allow for a function at the end of a 
path. Generally this saves writing a loop. For example:

let $root := <b><a>   foo  bar</a><a>baz     faz</a></b>
return $root/a/normalize-space(.)

instead of
let $root := <b><a>   foo  bar</a><a>baz     faz</a></b>
let $seq := $root/a
let $result := for $item in $seq
	return normalize-space($item)
return $result

In addition, without this functionality ugly workarounds are required 
to obtain the value of context functions. For example:
("a", "b", "c" )/text{ position() }

instead of the straightforward:
("a", "b", "c" )/position()

--Sarah
Received on Tuesday, 3 February 2004 14:15:32 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:13:57 UTC