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

Function xmlXIncludeCopyNode

ThirdParty/libxml2/vtklibxml2/xinclude.c:675–784  ·  view source on GitHub ↗

* xmlXIncludeCopyNode: * @ctxt: the XInclude context * @elem: the element * @copyChildren: copy children instead of node if true * * Make a copy of the node while expanding nested XIncludes. * * Returns a node list, not a single node. */

Source from the content-addressed store, hash-verified

673 * Returns a node list, not a single node.
674 */
675static xmlNodePtr
676xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr elem,
677 int copyChildren, const xmlChar *targetBase) {
678 xmlNodePtr result = NULL;
679 xmlNodePtr insertParent = NULL;
680 xmlNodePtr insertLast = NULL;
681 xmlNodePtr cur;
682 xmlNodePtr item;
683 int depth = 0;
684
685 if (copyChildren) {
686 cur = elem->children;
687 if (cur == NULL)
688 return(NULL);
689 } else {
690 cur = elem;
691 }
692
693 while (1) {
694 xmlNodePtr copy = NULL;
695 int recurse = 0;
696
697 if ((cur->type == XML_DOCUMENT_NODE) ||
698 (cur->type == XML_DTD_NODE)) {
699 ;
700 } else if ((cur->type == XML_ELEMENT_NODE) &&
701 (cur->ns != NULL) &&
702 (xmlStrEqual(cur->name, XINCLUDE_NODE)) &&
703 ((xmlStrEqual(cur->ns->href, XINCLUDE_NS)) ||
704 (xmlStrEqual(cur->ns->href, XINCLUDE_OLD_NS)))) {
705 xmlXIncludeRefPtr ref = xmlXIncludeExpandNode(ctxt, cur);
706
707 if (ref == NULL)
708 goto error;
709 /*
710 * TODO: Insert XML_XINCLUDE_START and XML_XINCLUDE_END nodes
711 */
712 for (item = ref->inc; item != NULL; item = item->next) {
713 copy = xmlStaticCopyNode(item, ctxt->doc, insertParent, 1);
714 if (copy == NULL) {
715 xmlXIncludeErrMemory(ctxt);
716 goto error;
717 }
718
719 if (result == NULL)
720 result = copy;
721 if (insertLast != NULL) {
722 insertLast->next = copy;
723 copy->prev = insertLast;
724 } else if (insertParent != NULL) {
725 insertParent->children = copy;
726 }
727 insertLast = copy;
728
729 if ((depth == 0) && (targetBase != NULL))
730 xmlXIncludeBaseFixup(ctxt, item, copy, targetBase);
731 }
732 } else {

Callers 2

xmlXIncludeCopyXPointerFunction · 0.85
xmlXIncludeLoadFallbackFunction · 0.85

Calls 6

xmlStrEqualFunction · 0.85
xmlXIncludeExpandNodeFunction · 0.85
xmlStaticCopyNodeFunction · 0.85
xmlXIncludeErrMemoryFunction · 0.85
xmlXIncludeBaseFixupFunction · 0.85
xmlFreeNodeListFunction · 0.85

Tested by

no test coverage detected