xsl-list
[Top] [All Lists]

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

2020-04-08 23:54:45
On Wed, Apr 8, 2020 at 6:42 PM Costello, Roger L. costello(_at_)mitre(_dot_)org 
<
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>