Click to See Complete Forum and Search --> : Having trouble with Element setAttribute()


ColdGin
06-26-2008, 09:59 AM
Hi. I am executing this simple statement:

import org.w3c.dom.Element;

...

Element xmlElem

// Set xmlElem to first node of document here...

...

xmlElem.setAttribute("counter",Integer.toString(counterInt));

On the setAttribute() statement, I receive the following exception:

org.apache.xml.dtm.DTMDOMException: at org.apache.xml.dtm.ref.DTMNodeProxy.setAttribute(DTMNodeProxy.java:1109)

I ruled out the attribute being null by doing a xmlElem.getAttribute("counter") and checking the result. The method does not return null, and the attribute exists in the XML file.

When I looked up the open source code for DTMNodeProxy, the setAttribute method of that class raises a DTMDOMException (just as I am getting), and does nothing else. This makes me think:

1.) That I am missing an implementation jar somewhere, as it appears that Element's setAttribute method is not implemented (???)

2.) There is a permissions issue with the XML file (but I did a chmod 777 on the file to rule this out).

Any insight would be greatly appreciated. Thank you.