You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Pier Paolo Bortone <pi...@noema.it> on 2005/03/15 17:24:46 UTC

Using function SUM(node-set) - java.lang.ClassCastException

Hi all,
I've written an XSL that contains this part of algorithm:
 
...
<xsl:variable name="sum_values">
  <val><xsl:value-of select="."/></val>
  <val><xsl:value-of select="$sum_value"/></val>
</xsl:variable>
<xsl:value-of select="sum($sum_values/val)"/>
...
 
when I run the XSLT processor I receive this exception:
 
Caused by: java.lang.ClassCastException
        at
org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(FilterE
xprIteratorSimple.java:104)
        at
org.apache.xpath.axes.FilterExprWalker.setRoot(FilterExprWalker.java:168
)
        at
org.apache.xpath.axes.WalkingIterator.setRoot(WalkingIterator.java:138)
        at
org.apache.xpath.axes.NodeSequence.setRoot(NodeSequence.java:253)
        at
org.apache.xpath.axes.LocPathIterator.asIterator(LocPathIterator.java:31
7)
        at org.apache.xpath.functions.FuncSum.execute(FuncSum.java:91)
        at
org.apache.xpath.Expression.executeCharsToContentHandler(Expression.java
:357)
        at
org.apache.xalan.templates.ElemValueOf.execute(ElemValueOf.java:319)
        ... 48 more
 
Could you tell me why I receive this exception? I'd like to know if you
have a better solution to solve this matter. 
 
Thanks in advance.
 
Pier Paolo.
 

Re: Using function SUM(node-set) - java.lang.ClassCastException

Posted by Brian Minchau <mi...@ca.ibm.com>.
Pier,
this is a known restriction of XSLT 1.0. You are not permitted to have
XPath expressions that apply to a result tree fragment.

It would be better if no exception were thrown, and a meaniful error
message was issued. A bug is already opened for this issue (
http://issues.apache.org/jira/browse/XALANJ-1263 )

In your situation you have a work around with the node set extensions of
Xalan, see  http://xml.apache.org/xalan-j/extensionslib.html#nodeset


- Brian
- - - - - - - - - - - - - - - - - - - -
Brian Minchau
XSLT Development, IBM Toronto
e-mail:        minchau@ca.ibm.com

"You want it today? Sorry, I thought tomorrow would be yesterday and I
still had more time." - My daughter Jennifer



                                                                           
             "Pier Paolo                                                   
             Bortone"                                                      
             <pierpaolo.borton                                          To 
             e@noema.it>               <xa...@xml.apache.org>          
                                                                        cc 
             03/15/2005 11:24                                              
             AM                                                    Subject 
                                       Using function SUM(node-set) -      
                                       java.lang.ClassCastException        
             Please respond to                                             
                 xalan-dev                                                 
                                                                           
                                                                           
                                                                           
                                                                           




Hi all,
I've written an XSL that contains this part of algorithm:

...
<xsl:variable name="sum_values">
  <val><xsl:value-of select="."/></val>
  <val><xsl:value-of select="$sum_value"/></val>
</xsl:variable>
<xsl:value-of select="sum($sum_values/val)"/>
...

when I run the XSLT processor I receive this exception:

Caused by: java.lang.ClassCastException
        at
org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(FilterExprIteratorSimple.java:104)

        at
org.apache.xpath.axes.FilterExprWalker.setRoot(FilterExprWalker.java:168)
        at
org.apache.xpath.axes.WalkingIterator.setRoot(WalkingIterator.java:138)
        at
org.apache.xpath.axes.NodeSequence.setRoot(NodeSequence.java:253)
        at
org.apache.xpath.axes.LocPathIterator.asIterator(LocPathIterator.java:317)
        at org.apache.xpath.functions.FuncSum.execute(FuncSum.java:91)
        at
org.apache.xpath.Expression.executeCharsToContentHandler(Expression.java:357)

        at
org.apache.xalan.templates.ElemValueOf.execute(ElemValueOf.java:319)
        ... 48 more

Could you tell me why I receive this exception? I'd like to know if you
have a better solution to solve this matter.

Thanks in advance.

Pier Paolo.



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org