[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Coding aroung a "Cannot convert zero-length string to
<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@xxxxxxxxxx - email
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|