[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Comparing 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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|