Project

Profile

Help

Bug #3164

closed

java.lang.ClassCastException: net.sf.saxon.tree.tiny.TinyAttributeImpl cannot be cast to org.w3c.dom.Attr

Added by Adrian Smith about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Category:
DOM Interface
Sprint/Milestone:
-
Start date:
2017-03-13
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:
Platforms:

Description

While writing an extension function using Saxon PE 9.7.0.15 I get this ClassCastException.

 public static Node foo(Document commandNode) {  

  Element command = commandNode.getDocumentElement();

  System.out.println("xxx get start");

  Attr attributeNode = command.getAttributeNode("width"); 

  System.out.println("xxx get end");

I call the function from XSLT with:

<xsl:value-of select="mycompany:foo($pie)"/>

The output is:

xxx get start

net.sf.saxon.trans.XPathException: Exception thrown by extension function

  {public static org.w3c.dom.Node com.mycompany.MyObject.foo(org.w3c.dom.Document)}: 

  java.lang.ClassCastException: net.sf.saxon.tree.tiny.TinyAttributeImpl cannot be cast to org.w3c.dom.Attr

Within the Saxon source code ElementOverNodeInfo.java method getAttriuteNode line 119 there is:

if (att.getDisplayName().equals(name)) {

  return (Attr) att;

}

I think this is where the ClassCastException is occurring. (The stack backtrace does not show where the ClassCastException is occuring, it only shows from my method calling the XSLT processor back up to the main method.)

As far as I can see the TinyAttributeImpl class is supposed to be the Saxon implementation of the Attr interface for the purposes of converting documents to DOM structures when doing extension methods in Java. Yet TinyAttributeImpl does not implement Attr.

Please register to edit this issue

Also available in: Atom PDF