views:

39

answers:

1

Hi,

The cloneNode() method in the following minimal example works on java 1.6 but throws an DOMException with code 14 under android 5.

Code 14 according to sdk docs means: "NAMESPACE_ERR If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces."

Has anybody an idea why this might be? Thank you in advance!

public class M
{
 public static void main(String[] args)
 {
  try
  {
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder = factory.newDocumentBuilder();

             String text = new String("<blub></blub>");
             Document document = builder.parse(new InputSource( new StringReader(text) ));

             document.getDocumentElement().cloneNode(true);
  }
  catch(DOMException e)
  {}
  catch(ParserConfigurationException e)
  {}
  catch(IOException e)
  {}
  catch(SAXException e)
  {}
 }
}
A: 

You can try to play with factory.setNamespaceAware()

iter
Thanks I checked already, but unfortunately factory.setNamespaceAware() does not have any influence. I wonder if anybody else can reproduce the problem?Btw: I know what exception I get because I use exception breakpoints in eclipse or just single step through the code. If I would "ignore" the exception, how would I know about the state of the code property inside the exception object e?And what line throws the exception is written in the first line of my question: "The cloneNode() method [...] throws [...]"
beutelfuchs
One positive intention of a full stack trace is to aid debugging exceptions when I don't have access to your Eclipse breakpoints. Including a stack trace in your report does not guarantee an answer, but it does convey more information with less ambiguity that an English description. Also, some stack traces come with useful message strigns.
iter