XML Query Use Case NS, query 1

XML Query Use Cases
W3C Working Draft 15 February 2001

Use Case NS

1.7.4.1 Q1

The Solution in XQuery uses a function named "namespace_uri". If this is
intended to be a reference to the XPath function, then:
(a) it should be spelled with a hyphen, not an underscore; and
(b) the solution won't work. The XPath function is defined to return:
        the namespace URI of the expanded-name of the node in
        the argument node-set that is first in document order.
    (rather than the namespace URI of the expanded-name of *each* node in
    the argument node-set, as you presumably intended).
You could replace
    namespace_uri(//*)
with
    FOR $x IN //* RETURN namespace-uri($x)

But even with that replacement, it still doesn't do what you want, because
it only returns the namespace URI of the expanded-name of each *element* in
the document. Thus, it misses these URIs:
    http://www.w3.org/1999/xlink
    http://www.AuctionMediatorCompany.com/auctioneers#yabadoo
    http://www.w3.org/1999/XMLSchema-datatypes
because they are only used for *attribute* names.
So you should replace
    //*
with
    (//*|//@*)


The newline() function is not defined.


There's nothing in the spec to indicate that '+' performs string
concatenation.  You could replace
    $n + newline()
with
    [ $n, newline() ]

-Michael Dyck

Received on Tuesday, 15 May 2001 03:55:28 UTC