<xsl:function name="ck:excel-serial-date" as="xs:string?">
<xsl:param name="input-date" as="xs:string?"/>
<xsl:value-of select="if($input-date = '') then '' else
xs:string(xs:integer(translate(xs:string(xs:date($input-date)-xs:date('1900-01-01')),'PD','')))"/>
</xsl:function>
This is a function I wrote (am writing?) to compute an integer that represents
the a date to Excel 2000.
There may or may not be a value in the input document that corresponds to a
cell in the output. In that case, I want the function to return an empty string.
So you can see here that I tell the function to expect a string, and that an
empty string (zero-length string) is acceptable input.
I also tell it that it should return a string, and that a zero-length string is
acceptable output.
In the body of the function, I state that if the input is a zero-length string,
it should return a zero-length string, otherwise it is to compute the number of
days between January 1, 1900 and the input date, convert the result to a
string, and return that.
Anyway, that's what I thought I was doing, but when I attempt a transformation,
I get the following error message:
"Fatal Error! Cannot convert zero-length string to an integer"
I thought that this fragment "if($input-date = '') then '' ..." would
short-circuit any attempt to convert a zero-length string to an integer, but
apparently I have misapprehended something key here. Can anyone point out where
I've gone wrong and suggest a fix?
Thanks.
--
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>
--~--