In actual fact that should be:
 <xsl:value-of select="sum(for $i in .//pkg-item[pkg-parent =  $this-pkg/group/@guid]/price-list/upgrade-credit return if ($i castable as xs:double) then xs:double($i) else 1)"/>
You wouldn't want to use the slash operator on upgrade-credit as that still leaves the same problem as trying to convert "" to a double.
Using 'castable as' is much more appropriate than string-length(), not sure about performance though.
Wrapping $i in xs:double($i) for the 'then' part I suspect has little effect other than making the cast explicit rather than implicit.
-----Original Message-----
From: [] On Behalf Of Andrew Welch
Sent: 03 June 2005 08:45
Subject: RE: [saxon] Error message without location

Where I come across this problem I've replaced any occurance of "" with a number, using for-return-if-else:
 <xsl:value-of select="sum(for $i in .//pkg-item[pkg-parent =  $this-pkg/group/@guid]/price-list/upgrade-credit return if (string-length($i)) then $i else 1)"/>
(the number will be either 1 or 0 I would guess, depending what should happen in the case of "")
You may want/need to use the slash operator as well on upgrade-credit eg:
.//pkg-item[pkg-parent =  $this-pkg/group/@guid]/price-list/upgrade-credit/xs:double(.)
All of this is still very new to me so these are only suggestions rather than facts :) 

-----Original Message-----
From: [] On Behalf Of Roger Kovack
Sent: 03 June 2005 00:34
Subject: [saxon] Error message without location

In Saxon 8.4 the following template correctly reports (approximately) 'can't convert string "" to double' but never tells me where the error occurred. Saxon 7.8 correctly reports the location of the error.  The template works correctly if the "" string does not occur. The exact point of the error is commented below:

<xsl:template name="upgrade-points">
    <xsl:param name="this-pkg"/>
    <xsl:message>this pkg: <xsl:copy-of select="$this-pkg/group/name"/></xsl:message>
    <xsl:variable name="fp" select="document(concat('db:doc.', $this-doc/doc/@fp-id))"/>
    <xsl:for-each select="$fp//*[upgrade-credit-point]">
                <!-- the following Xpath param to sum() evaluates to "" for at least one sequence item -->
                <xsl:value-of select="sum(.//pkg-item[pkg-parent =  $this-pkg/group/@guid]/price-list/upgrade-credit)"/>
                <xsl:for-each select="$this-pkg/group">
                    <credit-pkg-id><xsl:value-of select="@guid"/></credit-pkg-id>

Unfortunately, this is another one that's extremely difficult to extract for a specific, small example of the problem. Again, I *do* appreciate all you've done with Saxon.

Roger Kovack
------------------------------------------------------- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit _______________________________________________ saxon-help mailing list