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

Subject: RE: [xsl] An empty sequence is not allowed as the first argument ...
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 4 Jun 2006 21:14:51 +0100
> 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

Current Thread