/*================================================================ * ixmlDocument_setOwnerDocument * * When this function is called first time, nodeptr is the root * of the subtree, so it is not necessay to do two steps * recursion. * * Internal function called by ixmlDocument_importNode * *=================================================================*/ void ixmlDocument_setOwnerDocument( IN IXML_Document * doc, IN IXML_Node * nodeptr ) { if( nodeptr != NULL ) { nodeptr->ownerDocument = doc; ixmlDocument_setOwnerDocument( doc, ixmlNode_getFirstChild( nodeptr ) ); ixmlDocument_setOwnerDocument( doc, ixmlNode_getNextSibling ( nodeptr ) ); } }
/*! * When this function is called first time, nodeptr is the root of the subtree, * so it is not necessay to do two steps recursion. * * Internal function called by ixmlDocument_importNode */ static void ixmlDocument_setOwnerDocument( /*! [in] The document node. */ IXML_Document *doc, /*! [in] \todo documentation. */ IXML_Node *nodeptr) { if (nodeptr != NULL) { nodeptr->ownerDocument = doc; ixmlDocument_setOwnerDocument( doc, ixmlNode_getFirstChild(nodeptr)); ixmlDocument_setOwnerDocument( doc, ixmlNode_getNextSibling(nodeptr)); } }
/*================================================================ * ixmlDocument_importNode * Imports a node from another document to this document. The * returned node has no parent; (parentNode is null). The source * node is not altered or removed from the original document; * this method creates a new copy of the source node. * For all nodes, importing a node creates a node object owned * by the importing document, with attribute values identical to * the source node's nodeName and nodeType, plus the attributes * related to namespaces (prefix, localName, and namespaceURI). * As in the cloneNode operation on a node, the source node is * not altered. * * External function. * *=================================================================*/ int ixmlDocument_importNode( IN IXML_Document * doc, IN IXML_Node * importNode, IN unsigned char deep, OUT IXML_Node ** rtNode ) { unsigned short nodeType; IXML_Node *newNode; *rtNode = NULL; if( ( doc == NULL ) || ( importNode == NULL ) ) { return IXML_INVALID_PARAMETER; } nodeType = ixmlNode_getNodeType( importNode ); if( nodeType == eDOCUMENT_NODE ) { return IXML_NOT_SUPPORTED_ERR; } newNode = ixmlNode_cloneNode( importNode, deep ); if( newNode == NULL ) { return IXML_FAILED; } ixmlDocument_setOwnerDocument( doc, newNode ); *rtNode = newNode; return IXML_SUCCESS; }