W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2003

RE: document is not an element, is it?

From: Todd A. Mancini <todd.mancini@daxat.com>
Date: Tue, 11 Mar 2003 12:43:20 -0500
To: "'MW'" <onlymails@gmx.net>, <public-qt-comments@w3.org>
Message-ID: <000001c2e7f5$c6afa9c0$0201a8c0@qodfathr>

I'll leave the real answers to the spec authors, but here's how I came
up with my answers:

>The document function is defined in "XQuery 1.0: An XML Query Language"
>as follows:
>"The fn:document function, when its first argument is a string
>containing a single URI that refers to an XML document, converts that
>document to a Data Model representation and returns its document node."
>So I was (and still am) assuming that the return type of the document()
>function is of  type 'document' and not 'element', since the document
>node is not a element node, is it?

My source is
http://www.w3.org/2003/02/DIFF-xquery-operators.html#func-document ,
which I think is more authoritative than the prose within the XML Query
Language document.  The real problem is that there are multiple
documents covering this specification, and they are not always
consistent.  But, let's not forget that they are also marked as DRAFT.

>I am a real XQuery-beginner, so I have to cite "XQuery 1.0: An XML
Query
>Language" again:
">- node* refers to a sequence of zero or more nodes of any type
>  - item* refers to a sequence of zero or more nodes or atomic values"
>Isn't 'item' the supertype of 'node' and 'atomic value'? If it is,
there
>should be no static error when using "item" because document() returns
>exactly one document node (see my comment above).
>Nevertheless I partly agree with you. I think the argument type should
>be 'node' - as it is more special than 'item'.
>Please correct me, if I am wrong.

I am referring to static type analysis, which is performed before the
document() function is evaluated.  Before the function is evaluated, an
XML Query engine which implements static type analysis can only assume
that the result of calling document() will either be node* or an
evaluation error.  It is at static type analysis time that the depth()
function call is matched against the declaration of the depth()
function.  If the depth() function is declared with type 'item' or
'node', then static type analysis should say there is a type mismatch,
because document() is statically typed to return node*.  It does not
matter that, at evaluation time, document() actually returns only a
document node in this particular example.  (The document() function can
return XML fragments without document nodes, or even a sequence of
document nodes -- a forest of XML documents, if you will.  For example:
document( ("foo.xml", "bar.xml")) returns a sequence of two document
nodes, assuming foo.xml and bar.xml exist.)

And, yes, 'item' is a supertype of 'node' and 'atomic value', but
hopefully I've correctly explained why neither 'item' nor 'node' are
good enough -- it has to be either 'item*' or 'node*'.

	-Todd
Received on Tuesday, 11 March 2003 12:43:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:24 GMT