- From: Michael Dyck <MichaelDyck@home.com>
- Date: Sun, 17 Jun 2001 17:32:42 -0700
- To: www-ql@w3.org
- CC: Wayne Steele <xmlmaster@hotmail.com>
Howard Katz wrote:
>
> What's the syntax for longer path expressions? None of the examples
> show multi-step expressions having more than a single operator.
Actually, http://www.w3.org/TR/2001/WD-xqueryx-20010607#Example1 has a
three-step path:
document("bib.xml")//book[publisher = $p]/price
which supposedly translates as
<q:step axis="CHILD">
<q:function name="document">
<q:constant datatype="CHARSTRING">bib.xml</q:constant>
</q:function>
<q:step axis="CHILD">
<q:predicatedExpr>
<q:identifier>book</q:identifier>
<q:predicate>
<q:function name="EQUALS">
<q:identifier>publisher</q:identifier>
<q:variable>$p</q:variable>
</q:function>
</q:predicate>
</q:predicatedExpr>
<q:identifier>price</q:identifier>
</q:step>
</q:step>
although I suspect that first "axis" should be "SLASHSLASH".
> What if I want to say
>
> /article/section
>
> Given the DTD, it looks like I have to recast this into AST form:
>
> /
> null /
> article section
>
> so I can say something like this:
>
> <q:query ...>
> <q:step axis="CHILD">
> <q:identifier/>
> <q:step axis="CHILD">
> <q:identifier>article</q:identifier>
> <q:identifier>section</q:identifier>
> </q:step>
> </q:step>
> </q:query>
>
> Is that correct?
Apparently. Modulo the correct expression of absolute paths (your previous
question).
------
For contrast, in Wayne Steele's XML Encoded XPath (XEXPath), these would
(I think) be expressed as follows:
<!-- document("bib.xml")//book[publisher = $p]/price -->
<compose>
<function name="document">
<literal>bib.xml</literal>
</function>
<descendant-or-self type="node" />
<child>book</child>
<filter>
<eq>
<compose><child>publisher</child></compose>
<variable>p</variable>
</eq>
</filter>
<child>price</child>
</compose>
<!-- /article/section -->
<compose>
<root/>
<child>article</child>
<child>section</child>
</compose>
As you can see, XEXPath does *not* reflect the recursive tree structure of
path expressions, which makes them flatter, briefer, and (in my opinion)
easier to read. For info on XEXPath, see:
http://lists.xml.org/archives/xml-dev/200104/msg00013.html
and the 3 messages that follow that.
-Michael
Received on Sunday, 17 June 2001 20:36:52 UTC