#309 getElementsByTagName() doesn't wrap nodes

v8.3
closed
Michael Kay
5
2012-10-08
2005-02-14
Michael Kay
No

When a node is passed to an extension function that
views it as a DOM node, and the extension function then
calls the DOM method getElementsByTagName or
getElementsByTagNameNS, Saxon creates a DOM NodeList in
which the items are Saxon NodeInfo objects without
wrapping them as DOM Nodes. The likely result is a
ClassCastException when accessing items in the NodeList.

Source fix: in lines 176 and 262 of
net.sf.saxon.dom.DocumentOverNodeInfo.java, change

nodes.add(node)

to

nodes.add(NodeOverNodeInfo.wrap(node))

Discussion

  • Michael Kay
    Michael Kay
    2005-04-11

    Logged In: YES
    user_id=251681

    The patch is incorrect, the new code should be

    nodes.add(NodeOverNodeInfo.wrap(next))