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

Subject: Re: [xsl] What does //distinct-values(...) mean?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Apr 2020 13:25:27 -0000
With XPath 2 and later, any path expression selecting nodes can have a
last step applying a function returning non-node values so like you can
use e.g.

 B  //date/xs:dateTime(.)

calling `xs:dateTime` for each `date` element selected earlier

you can use

 B  //distinct-values(...)

to apply the distinct-values function for each node selected in the
previous step. As in your example you have used

//distinct-values(//Row[matches(Advertiser, 'TS3', 'i')]/Subscribers)

you compute the sequence several times.
Seehttps://www.w3.org/TR/xpath-31/#id-path-operator  for E1/E2

If every evaluation of|E2|returns a (possibly empty) sequence of non-nodes,
these sequences are
concatenated, in order,and returned.Thereturned sequence preserves the
orderings within and among the subsequences generated by the evaluations
of|E2|.

On 08.04.2020 15:12, Costello, Roger L. costello@xxxxxxxxx wrote:
> Hi Martin,
>
>
>
> But, but, but, ...
>
>
>
> 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?
>
>
>
> /Roger
>
>
>
> -----Original Message-----
>
> From: Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
>
> Sent: Wednesday, April 8, 2020 8:25 AM
>
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>
> Subject: [EXT] Re: [xsl] What does //distinct-values(...) mean?
>
>
>
> Am 08.04.2020 um 14:19 schrieb Costello, Roger L. costello@xxxxxxxxx:
>
>> Hi Folks,
>> I executed this XPath query in Oxygen:
>> //distinct-values(//Row[matches(Advertiser, 'TS3', 'i')]/Subscribers)
>> The two slashes at the beginning were an accident. At the bottom of the
screen Oxygen shows the matches. All of a sudden it showed 111,000 matches,
then a moment later 438,000 matches, and then finally 525,946 matches.
>> "Yikes!" I thought, "What is going on? There is supposed to be around 17
matches. How can there be half a million matches?"
>> Then I saw the two slashes at the start.
>> "Hmm, what is the meaning of two slashes preceding the distinct-values
function?" I thought.
>> So, I ask you: what is the meaning of two slashes preceding the
distinct-values function? Why does its evaluation result in so many matches?
>
>
> // is short for /descendant-or-self::node()/ so
>
>     //distinct-values(//Row[matches(Advertiser, 'TS3', 'i')]/Subscribers)
>
> is
>
>     /descendant-or-self::node()/distinct-values(//Row[matches(Advertiser,
>
> 'TS3', 'i')]/Subscribers)
>
> meaning it returns
>
>     distinct-values(//Row[matches(Advertiser, 'TS3', 'i')]/Subscribers)
>
> as many times as the document has any nodes selectable by
>
> /descendant-or-self::node().

Current Thread