ELSGestion / els-sie-xsl-lib

A set of XSL libraries
5 stars 1 forks source link

Add els:distinct-values function in els-common_strings.xsl file #1

Open FredericLanic opened 5 years ago

FredericLanic commented 5 years ago

Hello Matthieu,

FRANCAIS J'ai créé la branche "ADD_els_distinct-values_FCT" depuis la branche "master". Cette nouvelle branche contient à présent la fonction "els:distinct-values" qui permet d'obtenir, à partir d'une séquence de string, un nouvelle séquence qui ne contient que les premiers éléments distincts. L'ordre de ces éléments est gardé. Merci de valider cet ajout, buddy :)

ENGLISH I created the "ADD_els_distinct-values_FCT" branch from the "master" branch. This new branch now contains the "els: distinct-values" function which makes it possible to obtain, from a string sequence, a new sequence that contains only the first distinct elements. The order of these elements is kept. Thank you for confirming this add, buddy :)

Fred

mricaud commented 5 years ago

Hi @FredericLanic

Sorry for my late reply. I have a look and just realize the difference with the xpath fn:distinct-values() function: As say the spec here "The order in which the sequence of values is returned is implementation dependent". Your function ensure the same order as the original sequence. Maybe this should appear in the name of the function, what about els:ordered-distinc-values?

Your function only works with strings, whereas fn:distinct-values() works with any atomic types. I would rewrite it that way, using eq operator. But the spec says "Values that cannot be compared, because the eq operator is not defined for their types, are considered to be distinct." So maybe the best way to keep the same bahaviour is to use fn:distinct-values() inside this function?

What do you think ?