You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Jan Sundin <ja...@sundin.com> on 2000/01/27 16:55:51 UTC

importNode

Hi,
I’m trying to use importNode() to copy one Document to another. My tries are
unfortunately unsuccessful. The attached code only generates an exception as
below.

Ideas, anybody?

Jan Sundin

_____________________

import java.io.*;
import org.w3c.dom.*;

public class test {

  public test() {

  }

  public static void main(String arg[]) {

    Document mainDoc = new org.apache.xerces.dom.DocumentImpl();
    Element page = mainDoc.createElement("PAGE");
    mainDoc.appendChild(page);


    Document subDoc = new org.apache.xerces.dom.DocumentImpl();
    Element cont = subDoc.createElement("CONTENT");
    subDoc.appendChild(cont);

    ((org.apache.xerces.dom.DocumentImpl)
ainDoc).importNode( subDoc,true);
  }
}
_____________________

org.apache.xerces.dom.DOMExceptionImpl: HIERARCHY_REQUEST_ERR
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Compiled Code)
        at java.lang.RuntimeException.<init>(Compiled Code)
        at org.w3c.dom.DOMException.<init>(Compiled Code)
        at org.apache.xerces.domx.DOMException.<init>(Compiled Code)
        at org.apache.xerces.dom.DOMExceptionImpl.<init>(Compiled Code)
        at org.apache.xerces.dom.DocumentImpl.importNode(Compiled Code)
        at test.main(Compiled Code)