> > or simpler > > distinct-values($values)[let $v := . return $values[. = $v][2]] > I think you need an exists() call there - a value might be 0 or "" or false(). Michael Kay http://www.saxonica.com/