xsl-list
[Top] [All Lists]

Re: Comparing sequences

2006-02-08 20:44:00
On 2/9/06, cknell(_at_)onebox(_dot_)com <cknell(_at_)onebox(_dot_)com> wrote:
Given two sequences where:

$seq-a = 001,030,021,008
and
$seq-b = 005,030,026,009

How do I write an expression that returns true if any item in $seq-a is found 
in $seq-b?

One possible XPath expression is:

    empty($vS1[not(. = $vS2)])

However, this may sometimes raise an exception, depending on the types
of the two sequences.

Evaluating this expression (with Saxon8.6.1) on:

    5.0,030,026,009
and
  005,005,030,026,009,'xxx'

produces:
                 true()

However, evaluating the expression on:

   5.0,030,026,009
and
  '005',005,030,026,009,'xxx'

raises an exception (with Saxon8.6.1):

  "  XPTY0004: Cannot compare xs:string to xs:decimal
Transformation failed: Run-time errors were reported"

Obviously, getting true() in the first case above is not reliable, as
it depends on a given XPath2.0 processor support for lazy evaluation
and is most probably going to vary wildly accross different
processors.

This poses a new challenge in trying to write portable XPath 2.0
expressions -- people will need to evaluate their expressions on a
"dumb-enough" engine...


Let me predict:

  "Beaware of types"

will be one of the most popular sayings in the XPath2.0 era.


--
Cheers,
Dimitre Novatchev
---------------------------------------
The significant problems we have cannot be solved at the same level of
thinking with which we created them.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>