[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

Subject: Coding aroung a "Cannot convert zero-length string to an integer" error
From: cknell@xxxxxxxxxx
Date: Mon, 13 Aug 2007 09:44:24 -0400
 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.