xsl-list
[Top] [All Lists]

RE: [xsl] An empty sequence is not allowed as the first argument ...

2006-06-04 14:08:47
Mike will probably have the definitive answer on this one. 
Given how it's now late on Friday over in the UK, however, 

Even later in France where I've been taking a holiday...

How about having a wrapper function that will accept any 
argument or none, and does type-checking on it before calling 
your actual formatting function? XPath 2.0 has the "castable 
as" operator to help with this kind of thing.

It all depends what you want to happen when invalid data is encountered. If
you want anything other than a fatal error from the transformation, you have
to code in the checks yourself.

In my XSLT 2.0 dates processing (which like yours, doesn't assume
schema-validity) I have a function that assigns a date of Jan 1, year
1 to things that aren't properly dated (which means "things 
my code can't make a date out of"). 

Two other approaches are to use the empty sequence to signify an invalid
date, and to use a union type. Union types aren't particularly well
supported - but after a week on holiday, I forget exactly what the
limitations are.

Michael Kay


--~------------------------------------------------------------------
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>
--~--