What is the result of a path expression?

Dear colleagues,

I have a question about the latest working draft "XQuery 1.0: An XML
Query Language".

>2.1 Path Expressions
..
>The result of a path expression is a sequence of nodes or primitive
>values. The nodes in a path expression result are ordered according to
>their position in the original hierarchy, in document order (as
>defined in [XPath 1.0].) If the result of a path expression includes
>nodes that are in different documents, the ordering of these nodes is
>implementation-dependent.

Suppose that an XML document <div><div><p/><p/></div></div> is stored 
in test.xml.  What is the result of the following query?

   document("zoo.xml")//div

In my understanding, the result is <div><div><p/></p></div></div>
followed by <div><p/></p></div>.  Is this correct?  

If this is the case, the image of a simple tree regular language
(<div><div></div></div>, <div><div><p/></div></div>,
<div><div><p/><p/></div></div>,...) by this query is not tree-regular.

Or, is my understanding incorrect?  The following sentence suggests
that the result is rather <div><div><p/></p></div></div>.  If this is
the case, I am quite sure that queries by regular path expressions 
always lead to hedge regular languages.

> The result of a path expression may contain
>duplicate values (i.e., multiple nodes with the same name, type, and
>content), but it will not contain duplicate nodes (i.e., multiple
>occurrences of the same node).

Cheers,

<warning>Speaking for himself only</warning>

IBM Tokyo Research Lab / International University of Japan, Research Institute
MURATA Makoto (FAMILY Given)

Received on Wednesday, 13 June 2001 06:26:39 UTC