Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Wendell Piez <wapiez@---------------->
To:
Date: 6/2/2006 9:53:00 PM
Charles,



Mike will probably have the definitive answer on this one. Given how 
it's now late on Friday over in the UK, however, I'll take a guess.



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.



In a simple case, you could declare your function's argument 
(parameter) as "xs:string?" or "element(date)?" or whatever, to allow 
for a missing argument, and then trap that condition.



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"). It's something of a kludge, since I have 
to assume I'll never need the date 0001-01-01 for real. (It's a 
timesheet application, so this is not unfair.) Later in the 
application such undated dates get caught, so as not to be treated 
like my "real" dates. I'd love to know from an actual programmer how 
better to do this in XSLT.



Cheers,
Wendell

At 04:02 PM 6/2/2006, you wrote:
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@xxxxxxxxxx - email


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent