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

Subject: Re: [xsl] What does //distinct-values(...) mean?
From: "Mukul Gandhi gandhi.mukul@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 Apr 2020 04:54:38 -0000
On Wed, Apr 8, 2020 at 6:42 PM Costello, Roger L. costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:


> I thought that // operates on nodes. The distinct-values function doesn't
> return nodes, does it? I thought it returns a sequence of strings. If so,
> then how can // operate on a sequence of strings?
>

The relevant grammar productions from XPath 2.0 spec (ref
https://www.w3.org/TR/xpath20/#nt-bnf), that depict the semantics of '//'
operator are following,

"//" RelativePathExpr

RelativePathExpr   ::=   StepExpr (("/" | "//") StepExpr)*

StepExpr                ::=   FilterExpr | AxisStep

FilterExpr               ::=   PrimaryExpr PredicateList

AxisStep                ::=   (ReverseStep | ForwardStep) PredicateList

PrimaryExpr           ::=   Literal | VarRef | ParenthesizedExpr |
ContextItemExpr | FunctionCall

PredicateList           ::=   Predicate*

Predicate                ::=   "[" Expr "]"

The above XPath productions clearly shows that, the following XPath
expression
//distinct-values(..)

is allowed by the XPath language.

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. In case the argument is
sequence of nodes, then it is converted to sequence of atomic values by the
process of atomization in order for the function to return meaningful
result.

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.




-- 
Regards,
Mukul Gandhi

Current Thread