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

Discussion in 'XML' started by Johannes Lebek, Jul 9, 2003.

  1. 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
    Johannes Lebek, Jul 9, 2003
    #1
    1. Advertising

  2. 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
    Johannes Lebek, Jul 9, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    922
  2. Volker Jordan

    Xpath apache xerces/xalan dom3

    Volker Jordan, Jan 22, 2004, in forum: XML
    Replies:
    0
    Views:
    542
    Volker Jordan
    Jan 22, 2004
  3. Meikel
    Replies:
    0
    Views:
    487
    Meikel
    Jan 17, 2005
  4. Scott Harper
    Replies:
    0
    Views:
    398
    Scott Harper
    May 25, 2006
  5. Replies:
    4
    Views:
    582
    Joseph Kesselman
    Aug 10, 2006
Loading...

Share This Page