RE: [xsl] XML Schema union type is evil (for XPath 2.0 processing)

Subject: RE: [xsl] XML Schema union type is evil (for XPath 2.0 processing)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 10 Apr 2008 15:36:02 +0100
or more naturally just


       if (quantity ='out-of-stock') then
          'Bummer'

If the typed value of quantity is an integer, then this comparison will fail
with a type error. You could protect yourself by

If (string(quantity) = 'out-of-stock'))

My own preference was that "=" should return false (rather than error) when
comparing to incomparable values; but the strong typists carried the day.
There are other functions where you do get the "false" behaviour, and you
can exploit this:

If (deep-equal(quantity, 'out-of-stock')) ...

Apologies for the rogue capitalisation, I'm using a reinstalled Outlook, and
I haven't worked out how to switch off Microsoft's random-error-generation
software.

Michael Kay
http://www.saxonica.com/

Current Thread