httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Zanelli/NYT/NYTIMES" <>
Subject Hierarchy request error, don't know why!
Date Tue, 02 Oct 2001 20:15:49 GMT

OK, I'm running into what seems to be a poorly documented quirk for

Using the document builder, I am parsing out and XML file, which is never
more than 1 element deep with attributes.
However, after I set all the attribute values, I need to create extra
elements and append them to the document.  When I use the appendChild
method, the Hierarchy request error is coming up.  Here's a brief example:

     Document walgreensXMLInvoice = null;
     try {
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          DocumentBuilder builder = factory.newDocumentBuilder();
           walgreensXMLInvoice = builder.parse(Constants.PATHTOWALGREENSTEMPLATE);
          fHasBeenInitialized = true;
     catch .....

.......  // Just set the values of all the other attributes by sequentially going through
the nodes...

     for (int i = 0; i < itemList.size; i++) {
          Element item = walgreensXMLInvoice.createElement("Item");
          item.setAttribute("LineNumber", (new Integer(i+1)).toString());
          item.setAttribute("Quantity", (new Integer(itemList[i].quantity)).toString());
          item.setAttribute("ItemDescription", itemList[i].itemDescription);
          item.setAttribute("BIPAD", itemList[i].bipad);
          item.setAttribute("UnitPrice", (new Double(itemList[i].unitPrice)).toString());

          walgreensXMLInvoice.appendChild(item);  // Blows up here!

          // I tried this too
          // walgreensXMLInvoice.adoptNode(item);  ---- No error, but never adds the node
to the document.
Debugger Stack Trace Report:

Thread[main,5,main] (Alive)
Uncaught exception (org.w3c.dom.DOMException: DOM006 Hierarchy request error)

     DeferredDocumentImpl(CoreDocumentImpl).insertBefore(Node, Node)
          this=(org.apache.xerces.dom.DeferredDocumentImpl) [#document: null]
          arg_1=(org.w3c.dom.Node) [Item2: null]
          arg_2=(org.w3c.dom.Node) null
          this=(org.apache.xerces.dom.DeferredDocumentImpl) [#document: null]
          arg_1=(org.w3c.dom.Node) [Item2: null]
          this=(com.cs.invoiceapp.busobj.WalgreensInvoice) com.cs.invoiceapp.busobj.WalgreensInvoice@347e
          workingNode=(org.w3c.dom.Node) [Item: null]
          i=(int) 1
          item=(org.w3c.dom.Element) [Item2: null]
          this=(com.cs.invoiceapp.busobj.WalgreensInvoice) com.cs.invoiceapp.busobj.WalgreensInvoice@347e
     WalgreensInvoice.main(String [])
          args=([Ljava.lang.String;) [Ljava.lang.String;@220e
          newInvoice=(com.cs.invoiceapp.busobj.WalgreensInvoice) com.cs.invoiceapp.busobj.WalgreensInvoice@347e
          doc=(org.w3c.dom.Document) null
          trans=(com.cs.invoiceapp.util.transformer.DocToStringTransformer) com.cs.invoiceapp.util.transformer.DocToStringTransformer@57de

View raw message