XALAN: ClassCastException: org.apache.xpath.objects.XString -- a bug?

J

Johannes Lebek

Hi there,

I made some changes to my XSL stylesheet and now Xalan 2.5.1 is facing
ClassCastExceptions. I'm pretty sure, that the changes I made should work
(they are quite complicated -- I'd like to not explain them here).

My question is, is a ClassCastException a usual response in case of an error
in a stylesheet or is this a bug? I thought, Xalan would handle exceptions
like this internally.

This is the error message I get:

file:///D:/XSLT/stylesheet.xsl; Line #558; Column #137; XSLT Error
(javax.xml.transform.TransformerException): java.lang.ClassCastExc
eption: org.apache.xpath.objects.XString

Line 558:
<xsl:value-of select="generate-id(//a[@b = $c/@d])"/>

Variable 'c' was defined just two lines above:
<xsl:value-of select="//e[@f = current()/parent::e/@h]"/>

Value of variable 'c' is always a single node. Even if I changed the
assignment to
<xsl:value-of select="//e[@f = current()/parent::e/@h][1]"/>
it did not help. (Please, note '[1]' at the end of the predicate!)

Usually, the error messages I got were something like "this or that is not
allowed" or "character ']' expected, but ')' found" or stuff like that. The
error message I got now is kinda "naked", like unhandled.

What do you think?

Johannes
 
J

Johannes Lebek

Fixed my problem:
Nodes should be assigned to variables using

<xsl:variable name="x" select="node()"/>

but not like that

<xsl:variable name="x">
<xsl:value-of select="node()"/>
<xsl:variable/>

But, nevertheless, there is still the question why Xalan is reporting a
ClassCastException?

Johannes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top