Project

Profile

Help

DOM wrapper problem in extension function?

Added by Anonymous about 18 years ago

Legacy ID: #3928852 Legacy Poster: Henryk Hecht (henrykhecht)

I've an extension function that receives a W3C DOM Element as a parameter from Saxon, which appears to mostly work, but if I try to import the received Element into another DOM tree, the resulting Element appears to be incomplete. Specifically, there's something odd about the attributes; they appear to be valueless. Specifically, it goes something like this: public static void function(Element e) { ... Element ec = doc.importNode(e, true); ... After this, the following is true: e.getAttribute("someAttr") is "someValue" ec.getAttribute("someAttr") is "" and each item() in getAttributes() has the same getNodeName() but whilst e has sensible values for getNodeValue() ec has "". Using getAttributeNS(null, "someAttr") has similar results, as expected. Is this a small bug in the DOM wrapper code for Saxon, possibly a bug in the DOMImplementation's importNode() (it seems to work between two Documents created in Java, though), or am I simply doing something wrong with the DOM API (again)? Has anyone tried something similar and had this problem? Using SaxonB 8.8 on Java 1.5.0_07, incidentally. -- HH


Replies (4)

Please register to reply

RE: DOM wrapper problem in extension function - Added by Anonymous about 18 years ago

Legacy ID: #3929027 Legacy Poster: Michael Kay (mhkay)

I strongly suspect that importNode() is trying to retrieve the children of the attribute node. In DOM, an Attr node has a text node as its child. The Saxon DOM wrapper doesn't try to simulate this, it only delivers the attribute value via getNodeValue(). So it's a restriction in the design of the Saxon node wrapper. I'll try and fix this in a next release.

RE: DOM wrapper problem in extension function - Added by Anonymous about 18 years ago

Legacy ID: #3929057 Legacy Poster: Michael Kay (mhkay)

Could you possibly construct a small repro of this that I can use as a test case? Thanks.

RE: DOM wrapper problem in extension function - Added by Anonymous about 18 years ago

Legacy ID: #3929106 Legacy Poster: Michael Kay (mhkay)

I managed to reproduce this, and a source fix is now in Subversion.

RE: DOM wrapper problem in extension function - Added by Anonymous about 18 years ago

Legacy ID: #3929532 Legacy Poster: Henryk Hecht (henrykhecht)

Thanks again Michael. I am sorry I wasn't able to supply the requested test case; you simply respond and work too quickly.

    (1-4/4)

    Please register to reply