[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What does //distinct-values(...) mean?

Subject: Re: What does //distinct-values(...) mean?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 Apr 2020 08:19:06 -0000
Re:  What does //distinct-values(...) mean?
> The above XPath productions clearly shows that, the following XPath
expression
> //distinct-values(..)
>
> is allowed by the XPath language.

Yes, that's undisputed, just as (say) //name() is allowed and returns a
sequence containing the names of all nodes.
>
> The signature of 'distinct-values(..)' function is specified as following in
the XPath 2.0 F&O spec,
>
> fn:distinct-values($arg as xs:anyAtomicType*) as xs:anyAtomicType*
>
> The above function signature, allows as argument to the function, a sequence
of atomic values or a sequence of nodes.

The argument to the function is irrelevant. The "//" doesn't affect the
arguments to the function. It affects the dynamic context for the function,
but distinct-values() doesn't depend on the context (except to the extent that
its arguments depend on the context).
>
> Although, the expression //distinct-values(..) seems to be allowed by the
XPath spec, its run-time result looks to me ambiguous & should likely be
treated as implementation dependent, since the expression
//distinct-values(..) does not have any valid semantics.

Sorry, but that's wrong. The semantics are crystal-clear, just as the
semantics of //name() are crystal clear. The expression might be useless, and
its effect might be non-intuitive, but it's a principle of orthogonal language
design that you don't disallow things merely because they are useless or
non-intuitive. You can't allow some function calls after "//" because you
think they are useful, and disallow others because you think they aren't.

(Having said that, it was probably a mistake in XPath 2.0 to allow expressions
on the rhs of "/" (or "//") that returned atomic values. It would have been
better to require both operands of "/' to return nodes, and to have introduced
the "!" operator for the more general case. I remember Scott Boag arguing
strongly for that approach at the time. Eventually "!" was introduced anyway,
but by then the messy rules for "/" had already found their way into the
language).

Michael Kay
Saxonica
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.