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

RE: [XQUC] two question about http://www.w3.org/TR/xquery-use-cases/

From: Michael Kay <mhk@mhk.me.uk>
Date: Tue, 8 Mar 2005 16:50:39 -0000
To: "'Frank Yung-Fong Tang'" <franktang@gmail.com>, <public-qt-comments@w3.org>
Message-ID: <E1D8hvR-0000QI-7y@frink.w3.org>

> Question 1:
> In http://www.w3.org/TR/xquery-use-cases/#xmp-data the text inside the
> <price> of the first <book> is
>         <price> 65.95</price>
> instead of
>         <price>65.95</price>
> Notice the space in front of '6'
> but the Expected Result: of Q5 is
> <books-with-prices>
>     <book-with-prices>
>         <title>TCP/IP Illustrated</title>
>         <price-bstore2>65.95</price-bstore2>
>         <price-bstore1>65.95</price-bstore1>
>     </book-with-prices>
> Well the "$a/price/text()" remove the white space before '6'? or is
> that a mistake in the
> sample data?

I think you are right, there is nothing in this query that removes the

In fact, in queries of this kind it's probably better to write $a/price
rather than $a/price/text(). In this particular case it makes no difference,
but in an expression such as sum($a/price), writing sum($a/price/text())
would give the wrong answer if there is a comment splitting the value into
several text nodes.

> Question 2:
> About Q4
> distinct-values($a/last)
> distinct-values($a[last=$last]/first)
> The distinct-values function defined in
> http://www.w3.org/TR/xpath-functions/#func-distinct-values  take
> xdt:anyAtomicType
> But $a/last or $a[last=$last]/first are not atomic type, right? should
> these two lines be
> distinct-values($a/last/text())
> distinct-values($a[last=$last]/first/text())
> instead? or the XQuery will automatically convert it?

When nodes are passed to a function that expects atomic values, the nodes
are automatically atomized.
> also, how about
>                 where some $ba in $b/author 
>                       satisfies ($ba/last = $last and 
> $ba/first=$first)
> since $last is return by distinct-values($a/last) eariler, the value
> of $last must be an atomicType. but $ba/last is not a atomicType. How
> does the comparison perform in this case? Is there a implicit
> conversion defined in XQuery to make that comparison happen?

Again, atomization happens implicitly, as part of the rules for the "="

Michael Kay
Received on Tuesday, 8 March 2005 16:51:17 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:23 UTC