XQuery: document() function

XQuery: A Query Language for XML
W3C Working Draft 15 February 2001

Section 2.1 (Path Expressions) introduces "the function document(string),
which returns the root node of a named document." But by "the root node", do
you mean XML Query Data Model's DocNode (which XPath refers to as the root
node), or the ElemNode returned by its "root" accessor (which is variously
referred to as the document element, root element, or top-level element).

If you mean the DocNode, then the following expressions are incorrect:
    document("zoo.xml")/chapter[...]  (three times)
    document("bib.xml")/book[...]     (twice)
    depth(document("partlist.xml"))   (because depth's arg is an ELEMENT)
    document("company.xml")/emp[...]  (twice)
    document("acme_corp.xml")/emp[...]
  (and in the Use Cases:)
    document("prices.xml")/book/title (implicitly, in 1.1.9.10)

On the other hand, if "root node" means the top-level element, these are
incorrect:
  (in the Use Cases:)
    document("http://www.bn.com")/bib/book (4 times)
    document("book1.xml")/book/section

-Michael Dyck

Received on Saturday, 3 March 2001 20:07:51 UTC