Hi all,

I am building an xml parser and constructor using the XDOM functions in
Universe 10.1.0. Things are going fine until I get to use the XDOMAddChild
function. I can add single elements fine using the handles but I get an
error when adding a tree. The manuals indicate adding a tree is fine.


XDOMAddChild function


Syntax


XDOMAddChild(xmlHandle, xpathString, nsMap, nodeHandle, dupFlag)


Description


The XDOMAddChild function finds the xpathString in the context xmlHandle in
the 
DOM structure and inserts a node nodeHandle as the last child of the found
node. If 
the inserted node type is XDOM.ATTR.NODE, this node is inserted as an
attribute.


Parameters


The following table describes each parameter of the syntax.
Parameter Description


xmlHandle The handle to the context. [IN]
xpathString Relative or absolute Xpath string. [IN]
nsMap The map of namespaces which resolve the prefixes in the xpath string. 
Format is “xmlns=default_url xmlns:prefix1=prefix1_url 
xmlns:prefix2=prefix2_url”


For example:
“xmlns=http://myproject.mycompany.com 
xmlns:a_prefix=a.mycompany.com” [IN]


nodeHandle Handle to a DOM subtree. If nodeHandle points to a DOM document, 
all of its children are inserted, in the same order. [IN]


dupFlag XDOM.DUP: Clones nodeHandle, and inserts the duplicate node.
XDOM.NODUP: Inserts the original node. The subtree is also removed 
from its original location. [IN]

I accept the XDOM faults and flaws (particularly with building namespace
prefixes) and an willing to work with them, But this one may be a show
stopper with the current logic I am using. This is some test code:

    $INCLUDE UNIVERSE.INCLUDE XML.H                                           
    DATA.REQ = '<logonResponse></logonResponse>'
    TEST.CHILD = '<logon>HELP</logon>'
    NSMAP = ''
    *
    ERR$ = XDOMOpen(DATA.REQ, XML.FROM.STRING, DOM$H)                
      Status = XMLGetError(ERR$,errMsg)
      PRINT ERR$:',':errMsg 
    ERR$ = XDOMOpen(TEST.CHILD, XML.FROM.STRING, CHILD$H)                
      Status = XMLGetError(ERR$,errMsg)
      PRINT ERR$:',':errMsg
    ERR$ = XDOMLocate(DOM$H,'//logonResponse',NSMAP,NOD$H)                      
             
      Status = XMLGetError(ERR$,errMsg)
      PRINT ERR$:',':errMsg
    ERR$ = XDOMWrite(NOD$H,JUNK,XML.TO.STRING)
    PRINT JUNK
    ERR$ = XDOMWrite(CHILD$H,JUNK,XML.TO.STRING)
    PRINT JUNK
    ERR$ = XDOMAddChild(DOM$H, '',NSMAP,CHILD$H, XDOM.NODUP)
    IF ERR$ = XML.SUCCESS THEN PRINT 'SUCCESS'
    IF ERR$ = XML.ERROR THEN PRINT 'ERROR'
    IF ERR$ = XML.INVALID.HANDLE THEN PRINT 'INVALID'
      Status = XMLGetError(ERR$,errMsg)
      PRINT ERR$:',':errMsg
    END

I get this back....

1004,A DOM exception occured in function XDOMAddChild, DOM Exception code: 4

If I use XDOMCreateNode to create the TEST.CHILD element, the XDOMAddChild
works fine.
The only difference I can prove ids that the inserted node hanlde is
different between teh 2 examples. The one that works the nodehandle is
XDOM.ELEMENT.NODE (Type 1) and the one that fails in XDOM.DOC.NODE (Type 9).

Not sure where to go from here. Any code snippets, links, pointers; greatly
appreciated


-- 
View this message in context: 
http://old.nabble.com/XDOM-API-Universe-10.1.0---Add-child-tp26332639p26332639.html
Sent from the U2 - Users mailing list archive at Nabble.com.

_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to