[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Comparing sequences

Subject: Re: Comparing sequences
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 9 Feb 2006 14:44:00 +1100
xpath2 comparing 2 sequences
On 2/9/06, cknell@xxxxxxxxxx <cknell@xxxxxxxxxx> 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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.