classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML strictness


From: Chris Burdess
Subject: Re: XML strictness
Date: Tue, 31 May 2005 07:22:27 +0100
User-agent: Mutt/1.3.28i

Robert Schuster wrote:
> When run as 'echo "<a/>" | jamvm -cp . xmlfilter.XMLFilter' you get the
> following exception:
> 
> gnu.xml.dom.DomDOMException: The node doesn't belong here.
> More Information: document element already present:
> gnu.xml.dom.DomElement[a]
> Node Name: new
>    at gnu.xml.dom.DomDocument.checkNewChild (DomDocument.java:294)
>    at gnu.xml.dom.DomDocument.appendChild (DomDocument.java:317)
>    at xmlfilter.XMLFilter.main (XMLFilter.java:42)
> 
> You get the same message with all proprietary JDKs prior to 1.5 . The
> latest incarnation however accepts creating the <new> node and generates
> the following XML upon calling 'echo "<a/>" |
> /opt/sun-jdk-1.5.0/bin/java xmlfilter.XMLFilter':
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <a/>
> <new/>
> 
> AFAIK there should/must be only one top-level node which is named <xml>.
> 
> I am confused ...
> Is Sun breaking the rules here?

According to

  
http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Node.html#appendChild(org.w3c.dom.Node)

  HIERARCHY_REQUEST_ERR: Raised ... if this node is of type Document and
  the DOM application attempts to append a second DocumentType or Element
  node.

If you want to add arbitrary node types, use a DocumentFragment.
-- 
Chris Burdess




reply via email to

[Prev in Thread] Current Thread [Next in Thread]