xsl-list
[Top] [All Lists]

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

2020-04-08 08:20:31
One more reason to avoid the // abbreviation completely!

Of course, when designing XPath 1.0 they wouldn't have an idea what was
about to come in the next versions :)


Cheers,
Dimitre

On Wed, Apr 8, 2020 at 5:25 AM Martin Honnen 
martin(_dot_)honnen(_at_)gmx(_dot_)de <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Am 08.04.2020 um 14:19 schrieb Costello, Roger L. 
costello(_at_)mitre(_dot_)org:
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().




-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write
all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.
--~----------------------------------------------------------------
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>