xsl-list
[Top] [All Lists]

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

2006-06-04 13:15:18
You've got two choices. Either write your function so it can handle an empty
sequence, or don't call it with an empty sequence. One way of doing the
latter is to include string(.....) in the function call - the string()
function never returns an empty sequence.

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

-----Original Message-----
From: cknell(_at_)onebox(_dot_)com [mailto:cknell(_at_)onebox(_dot_)com] 
Sent: 02 June 2006 21:02
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] An empty sequence is not allowed as the first 
argument ...

I've written an XSLT function to format dates fetched from a 
database. This worked well until I pulled some records with 
NULL values for the date I wished to format. When my 
stylesheet encountered this element, Saxon emitted this error 
message and ended with a fatal error:

Fatal Error! An empty sequence is not allowed as the first 
argument of ck:std-date-string-fmt()

You may well ask, "What did you expect?" The answer is that I 
was not expecting anything. I was happily ignorant of the 
lurking danger. I tried to supply a default empty string 
value for the parameter that causes the function to choke 
when no value is supplied, only to be upbraided by Saxon 
telling me that default values are not permitted in function 
parameters.

(I had slipped in an xsl:choose to catch the empty-sting 
cases, but without being able to assign a default value, that failed.)

Does an empty sequence have some kind of xs:type that I could 
cast to an xs:string, and if so, how is it done? If not, how 
do I handle cases when no data comes from my database?
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email

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



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