Thanks, this is a new bug. I've put an explanation at:
 
https://sourceforge.net/tracker/index.php?func=detail&aid=1636174&group_id=29872&atid=397617
 
and I've tested a patch which is going into Subversion.
 
As a workaround, don't use temporary tree variables! Either use the select attribute of xsl:variable, or use an "as" attribute to define the type, e.g.
 
<xsl:variable name="x" as="xs:integer">
  <xsl:choose>
    <xsl:when test="expr">
      <xsl:sequence select="42"/>
    </xsl:when>
etc.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Matt Thomas
Sent: 15 January 2007 17:00
To: saxon-help@lists.sourceforge.net
Subject: [saxon] ClassCastException with xsl:choose in 8.8b

I recently upgraded to Saxon 8.8b (Java) from 8.7 and started getting this error message:

java.lang.ClassCastException: net.sf.saxon.value.StringValue
    at net.sf.saxon.expr.ArithmeticExpression$NumericArithmetic.doArithmetic (ArithmeticExpression.java:737)
    at net.sf.saxon.expr.ArithmeticExpression$NumericArithmetic.evaluateItem(ArithmeticExpression.java:674)
    at net.sf.saxon.instruct.SimpleContentConstructor.evaluateItem(SimpleContentConstructor.java :199)
    at net.sf.saxon.instruct.ValueOf.processLeavingTail(ValueOf.java:198)
    at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:352)
    at net.sf.saxon.instruct.Template.applyLeavingTail (Template.java:99)
    at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:319)
    at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:351)
    at net.sf.saxon.instruct.ApplyTemplates.applyTemplates (ApplyTemplates.java:312)
    at net.sf.saxon.Controller.transformDocument(Controller.java:1602)
    at net.sf.saxon.Controller.transform(Controller.java:1426)
    at net.sf.saxon.Transform.processFile(Transform.java :828)
    at net.sf.saxon.Transform.doTransform(Transform.java:495)
    at net.sf.saxon.Transform.main(Transform.java:60)

I reduced the problem down to this in the stylesheet:

<xsl:variable name="a">
    <xsl:choose>
        <xsl:when test="1=1">4</xsl:when>
    </xsl:choose>
</xsl:variable>

<xsl:value-of select="$a - 1"/>

Using an <xsl:sequence select="4"/> inside the when statement works properly (and I should have done that in the first place). I was just wondering if this should be throwing a Java ClassCastException?

thanks,
Matt Thomas