MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlDOMWrapAdoptBranch

Function xmlDOMWrapAdoptBranch

ThirdParty/libxml2/vtklibxml2/tree.c:8952–9209  ·  view source on GitHub ↗

* xmlDOMWrapAdoptBranch: * @ctxt: the optional context for custom processing * @sourceDoc: the optional sourceDoc * @node: the element-node to start with * @destDoc: the destination doc for adoption * @destParent: the optional new parent of @node in @destDoc * @options: option flags * * Ensures that ns-references point to @destDoc: either to * elements->nsDef entries if @destParent is given, or to

Source from the content-addressed store, hash-verified

8950* Returns 0 if succeeded, -1 otherwise and on API/internal errors.
8951*/
8952static int
8953xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
8954 xmlDocPtr sourceDoc ATTRIBUTE_UNUSED,
8955 xmlNodePtr node,
8956 xmlDocPtr destDoc,
8957 xmlNodePtr destParent,
8958 int options ATTRIBUTE_UNUSED)
8959{
8960 int ret = 0;
8961 xmlNodePtr cur, curElem = NULL;
8962 xmlNsMapPtr nsMap = NULL;
8963 xmlNsMapItemPtr mi;
8964 xmlNsPtr ns = NULL;
8965 int depth = -1;
8966 /* gather @parent's ns-decls. */
8967 int parnsdone;
8968 /* @ancestorsOnly should be set per option. */
8969 int ancestorsOnly = 0;
8970
8971 /*
8972 * Get the ns-map from the context if available.
8973 */
8974 if (ctxt)
8975 nsMap = (xmlNsMapPtr) ctxt->namespaceMap;
8976 /*
8977 * Disable search for ns-decls in the parent-axis of the
8978 * destination element, if:
8979 * 1) there's no destination parent
8980 * 2) custom ns-reference handling is used
8981 */
8982 if ((destParent == NULL) ||
8983 (ctxt && ctxt->getNsForNodeFunc))
8984 {
8985 parnsdone = 1;
8986 } else
8987 parnsdone = 0;
8988
8989 cur = node;
8990
8991 while (cur != NULL) {
8992 if (cur->doc != destDoc) {
8993 if (xmlNodeSetDoc(cur, destDoc) < 0)
8994 ret = -1;
8995 }
8996
8997 switch (cur->type) {
8998 case XML_XINCLUDE_START:
8999 case XML_XINCLUDE_END:
9000 /*
9001 * TODO
9002 */
9003 ret = -1;
9004 goto leave_node;
9005 case XML_ELEMENT_NODE:
9006 curElem = cur;
9007 depth++;
9008 /*
9009 * Namespace declarations.

Callers 1

xmlDOMWrapAdoptNodeFunction · 0.85

Calls 6

xmlNodeSetDocFunction · 0.85
xmlStrEqualFunction · 0.85
xmlDOMWrapNsMapAddItemFunction · 0.85
xmlDOMWrapNsMapFreeFunction · 0.85

Tested by

no test coverage detected