Consultor Eletrônico



Kbase 21898: XML -- Error 9082 with APPEND-CHILD
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   18/03/2002
SUMMARY:

When using a DTD with an XML document you might see the following error when trying to append the first child to the XML document:

X-NODEREF or X-DOCUMENT APPEND-CHILD got an error: A node was
inserted where it doesn't belong (9082)

EXPLANATION:

The problem is that INITIALIZE-DOCUMENT-TYPE creates a
document with a root node. Since XML can only have 1 root node, you cannot do an APPEND-CHILD on the document, unless it is a COMMENT node or PI node.

SOLUTION:

Get the root node by calling GET-DOCUMENT-ELEMENT on the hDocument handle and then appending it to the children, as shown in this example:

DEF VAR hDocument AS HANDLE.
DEF VAR hOrder AS HANDLE.
DEF VAR hRoot AS HANDLE.

CREATE X-DOCUMENT hDocument.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hOrder.

hDocument:INITIALIZE-DOCUMENT-TYPE("" /*namespaceURI*/, "EXAMPLE" /*rootNodeName*/,
"" /*publicId*/,
"http://mydtd_for_myxmldoc.dtd" /*systemId*/ ).

hDocument:GET-DOCUMENT-ELEMENT(hRoot).
hDocument:CREATE-NODE(hOrder, "ORDER", "ELEMENT").
hRoot:APPEND-CHILD(hOrder).

/* rest of code */