Project

Profile

Help

distinct-values

Added by Anonymous over 18 years ago

Legacy ID: #3452535 Legacy Poster: Jan Van den Bussche (vdbuss)

Using Saxon 8.4. The function fn:distinct-values seems to apply the function fn:data implicitly. The following expression returns "1 2" whereas, reading the specification, I would expect it to return "<a>1</a><a>2</a>". distinct-values(<a>1</a>,<a>2<a/>)


Replies (4)

Please register to reply

RE: distinct-values using Saxon 8-6-1 - Added by Anonymous over 18 years ago

Legacy ID: #3452589 Legacy Poster: Jan Van den Bussche (vdbuss)

Using Saxon 8.6.1, tried the same expression: distinct-values(<a>1</a>,<a>2</a>) Now it tells me: Unknown collation file:/my/current/directory/2

RE: distinct-values - Added by Anonymous over 18 years ago

Legacy ID: #3452661 Legacy Poster: Michael Kay (mhkay)

The signature of distinct-values() is fn:distinct-values($arg as xdt:anyAtomicType*) as xdt:anyAtomicType* The function calling rules (XPath section 3.1.5) say: <quote> If the expected type is a sequence of an atomic type (possibly with an occurrence indicator *, +, or ?), the following conversions are applied: 1. Atomization is applied to the given value, resulting in a sequence of atomic values. </quote> Atomization is defined in terms of the data() function, so Saxon does indeed apply the fn:data() function implicitly. Michael Kay

RE: distinct-values using Saxon 8-6-1 - Added by Anonymous over 18 years ago

Legacy ID: #3452676 Legacy Poster: Michael Kay (mhkay)

>distinct-values(<a>1</a>,<a>2</a>) If distinct-values is called with two arguments, the second argument is taken as a collation. The expected type is xs:anyURI, so the supplied value is atomized, returning the untypedAtomic value "2", which is then cast to an xs:anyURI. Because it is a relative URI (it contains no colon) it is resolved relative to the base URI of the query, which in your case appears to be file:/my/current/directory/, and the resulting URI is used to identify a collation. I suspect you wanted to supply a single argument containing a sequence. To achieve this you need two pairs of parentheses: distinct-values((1,2,3)). Michael Kay

RE: distinct-values - Added by Anonymous over 18 years ago

Legacy ID: #3452818 Legacy Poster: Jan Van den Bussche (vdbuss)

Michael, It is truly admirable how calmly and seriously you are able to reply to stupid questions (like mine)! Thanks a lot, --Jan

    (1-4/4)

    Please register to reply