You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by kkumari <kk...@cinoni.com> on 2001/06/12 16:51:50 UTC
DOMException
Hi,
I have a problem while appending nodes to the existing Dom Structure.
I have an XML string which i get from an XML Database. Now i convert that
into a Document node using DomParser. I have one Element called links in the
Domtree. Now if i try to create a new Element called links and try to append
it to the existing DomStructue i get DOM008 Exception. Then i tried using
insertBefore() at the location where this node is supposed to go. This time
i get Dom006 Exception. I tried replaceChild() also. Nothing worked.I don't
undersatnt why i get DOMExceptions when i am trying to do valid operations.
Can anyone help me out?
Thanks,
kusuma
DOMException
Posted by kkumari <kk...@cinoni.com>.
Hi!
I have one more problem with replaceChild() method.
I have 2 Dom trees of the same implementation and having the samestructure.
Now i try to replace a node of the first tree with a node from 2nd tree. It
gives me a Dom exception(Wrong Document).Is this not a valid operation? Any
workaround for this??
thanks,
kusuma
----- Original Message -----
From: "R Tate" <rt...@swbell.net>
To: <kk...@cinoni.com>
Sent: Tuesday, June 12, 2001 9:38 PM
Subject: Re: DOMException
> I usually get the parent node and add the child to it. I use JAXP to get
my
> document object, and DOM to build my document tree (the children). Could
it
> be posible that the XML database is giving you elements that are not
Xerces
> Elements? You could go into your debugger and check that out. If you add
> the Xerces source to your java path and remove the Xerces JAR file, you
> should be able to trace into the Xerces methods "insertBefore" and
> "replaceChild".
>
> Regards,
>
> Roy Tate
> Java Programmer
> Sequoyah Technologies, LLC
>
> ----- Original Message -----
> From: kkumari
> To: xerces-j-dev@xml.apache.org
> Sent: Tuesday, June 12, 2001 9:51 AM
> Subject: DOMException
>
>
> Hi,
> I have a problem while appending nodes to the existing Dom Structure.
> I have an XML string which i get from an XML Database. Now i convert that
> into a Document node using DomParser. I have one Element called links in
the
> Domtree. Now if i try to create a new Element called links and try to
append
> it to the existing DomStructue i get DOM008 Exception. Then i tried using
> insertBefore() at the location where this node is supposed to go. This
time
> i get Dom006 Exception. I tried replaceChild() also. Nothing worked.I
don't
> undersatnt why i get DOMExceptions when i am trying to do valid
operations.
> Can anyone help me out?
> Thanks,
> kusuma
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: DOMException
Posted by kkumari <kk...@cinoni.com>.
I don't think it's the problem with XmlDatabase.
I tried with a constant xml String. I created a DOM Structure with DOM
Parser and then tried to append some child to it.
Still it gave the same problem.
Here is the sample code:
import java.io.*;import org.apache.xerces.dom.*;import org.w3c.dom.*;import
org.apache.xerces.parsers.*;import org.xml.sax.*;
public class Test{
public void testDOM()throws Exception{String xml="<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"+"<lessonplan >\n"+ "<title></title>\n"+
"<objective></objective>\n"+ "<summary></summary>\n"+
"</lessonplan>";InputSource lpIn = new InputSource(new BufferedReader(new
StringReader(xml)));System.out.println("Input source is :"+lpIn);DOMParser
parser = new DOMParser();parser.parse(lpIn);Node lpNode =
parser.getDocument();
Document lpDoc=(Document)lpNode;Element
elem=lpDoc.createElement("test");elem.setAttribute("author","kusuma");lpDoc.
appendChild(elem);}
public static void main(String[] args)throws
Exception{System.out.println(args.length);Test t =new Test();t.testDOM();
}}
this is the eception i get when i run the above code
Exception in thread "main" org.w3c.dom.DOMException: DOM006 Hierarchy
request error at
org.apache.xerces.dom.DocumentImpl.insertBefore(DocumentImpl.java:342)
at org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.java:212) at
Test.testDOM(Test.java:27) at Test.main(Test.java:33)
Any specific reasons for this behaviour??thanks,
kusuma
----- Original Message -----
From: "R Tate" <rt...@swbell.net>
To: <kk...@cinoni.com>
Sent: Tuesday, June 12, 2001 9:38 PM
Subject: Re: DOMException
> I usually get the parent node and add the child to it. I use JAXP to get
my
> document object, and DOM to build my document tree (the children). Could
it
> be posible that the XML database is giving you elements that are not
Xerces
> Elements? You could go into your debugger and check that out. If you add
> the Xerces source to your java path and remove the Xerces JAR file, you
> should be able to trace into the Xerces methods "insertBefore" and
> "replaceChild".
>
> Regards,
>
> Roy Tate
> Java Programmer
> Sequoyah Technologies, LLC
>
> ----- Original Message -----
> From: kkumari
> To: xerces-j-dev@xml.apache.org
> Sent: Tuesday, June 12, 2001 9:51 AM
> Subject: DOMException
>
>
> Hi,
> I have a problem while appending nodes to the existing Dom Structure.
> I have an XML string which i get from an XML Database. Now i convert that
> into a Document node using DomParser. I have one Element called links in
the
> Domtree. Now if i try to create a new Element called links and try to
append
> it to the existing DomStructue i get DOM008 Exception. Then i tried using
> insertBefore() at the location where this node is supposed to go. This
time
> i get Dom006 Exception. I tried replaceChild() also. Nothing worked.I
don't
> undersatnt why i get DOMExceptions when i am trying to do valid
operations.
> Can anyone help me out?
> Thanks,
> kusuma
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org