Kbase P181334: Errors when using XML SAVE method after attempting to modify the XML namespace using SET-ATTRIBUTE
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/2/2011 |
|
Status: Unverified
SYMPTOM(s):
Errors when using XML SAVE method after attempting to modify the XML namespace using SET-ATTRIBUTE
X-NODEREF or X-DOCUMENT got an error: . (9082)
X-NODEREF or X-DOCUMENT SAVE got an error: Attempt to re-declare namespace prefix '' for namespace '' in element 'maintainWorkOrder'. It is already declared for namespace 'http://tony66'. (9082)
Sample code to demonstrate the problem:
DEFINE VARIABLE initalXML AS CHAR NO-UNDO.
DEFINE VARIABLE xmlMemptr AS MEMPTR NO-UNDO.
DEFINE VARIABLE xmlDocument AS HANDLE NO-UNDO.
DEFINE VARIABLE rootNode AS HANDLE NO-UNDO.
ASSIGN initalXML = '<maintainWorkOrder></maintainWorkOrder>'.
SET-SIZE(xmlMemptr) = LENGTH(initalXML) + 1.
PUT-STRING(xmlMemptr,1) = initalXML.
CREATE X-DOCUMENT xmlDocument.
xmlDocument:LOAD("memptr",xmlMemptr,FALSE).
CREATE X-NODEREF rootNode.
xmlDocument:GET-DOCUMENT-ELEMENT(rootNode).
rootNode:SET-ATTRIBUTE("xmlns",http://test).
xmlDocument:SAVE("file","wo.xml").
SET-SIZE(xmlMemptr) = 0.
DELETE OBJECT xmlDocument.
FACT(s) (Environment):
Linux
OpenEdge 10.2B
OpenEdge 10.1C
OpenEdge 11.1x
CAUSE:
Bug# OE00204268
FIX:
To work around this issue, add the XML namespace directly off the root node of the XML doc prior to adding any other nodes to the document. Sample code below:
DEFINE VARIABLE xmlDocument AS HANDLE NO-UNDO.
DEFINE VARIABLE hNode AS HANDLE NO-UNDO.
CREATE X-DOCUMENT xmlDocument.
CREATE X-NODEREF hNode.
xmlDocument:CREATE-NODE(hNode,"maintainWorkOrder","element").
hNode:SET-ATTRIBUTE("xmlns",http://test).
xmlDocument:APPEND-CHILD(hNode).
xmlDocument:SAVE("file","wo.xml").
DELETE OBJECT xmlDocument.