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

Function xmlXIncludeCopyXPointer

ThirdParty/libxml2/vtklibxml2/xinclude.c:1036–1134  ·  view source on GitHub ↗

* xmlXIncludeCopyXPointer: * @ctxt: the XInclude context * @obj: the XPointer result from the evaluation. * * Build a node list tree copy of the XPointer result. * This will drop Attributes and Namespace declarations. * * Returns an xmlNodePtr list or NULL. * the caller has to free the node tree. */

Source from the content-addressed store, hash-verified

1034 * the caller has to free the node tree.
1035 */
1036static xmlNodePtr
1037xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr obj,
1038 const xmlChar *targetBase) {
1039 xmlNodePtr list = NULL, last = NULL, copy;
1040 int i;
1041
1042 if ((ctxt == NULL) || (obj == NULL))
1043 return(NULL);
1044 switch (obj->type) {
1045 case XPATH_NODESET: {
1046 xmlNodeSetPtr set = obj->nodesetval;
1047 if (set == NULL)
1048 break;
1049 for (i = 0;i < set->nodeNr;i++) {
1050 xmlNodePtr node;
1051
1052 if (set->nodeTab[i] == NULL)
1053 continue;
1054 switch (set->nodeTab[i]->type) {
1055 case XML_DOCUMENT_NODE:
1056 case XML_HTML_DOCUMENT_NODE:
1057 node = xmlDocGetRootElement(
1058 (xmlDocPtr) set->nodeTab[i]);
1059 if (node == NULL) {
1060 xmlXIncludeErr(ctxt, set->nodeTab[i],
1061 XML_ERR_INTERNAL_ERROR,
1062 "document without root\n", NULL);
1063 continue;
1064 }
1065 break;
1066 case XML_TEXT_NODE:
1067 case XML_CDATA_SECTION_NODE:
1068 case XML_ELEMENT_NODE:
1069 case XML_PI_NODE:
1070 case XML_COMMENT_NODE:
1071 node = set->nodeTab[i];
1072 break;
1073 default:
1074 xmlXIncludeErr(ctxt, set->nodeTab[i],
1075 XML_XINCLUDE_XPTR_RESULT,
1076 "invalid node type in XPtr result\n",
1077 NULL);
1078 continue; /* for */
1079 }
1080 /*
1081 * OPTIMIZE TODO: External documents should already be
1082 * expanded, so xmlDocCopyNode should work as well.
1083 * xmlXIncludeCopyNode is only required for the initial
1084 * document.
1085 */
1086 copy = xmlXIncludeCopyNode(ctxt, node, 0, targetBase);
1087 if (copy == NULL) {
1088 xmlFreeNodeList(list);
1089 return(NULL);
1090 }
1091 if (last == NULL) {
1092 list = copy;
1093 } else {

Callers 1

xmlXIncludeLoadDocFunction · 0.85

Calls 5

xmlDocGetRootElementFunction · 0.85
xmlXIncludeCopyNodeFunction · 0.85
xmlFreeNodeListFunction · 0.85
xmlAddNextSiblingFunction · 0.85
xmlXIncludeCopyRangeFunction · 0.85

Tested by

no test coverage detected