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

Function xmlXIncludeIncludeNode

ThirdParty/libxml2/vtklibxml2/xinclude.c:1944–2044  ·  view source on GitHub ↗

* xmlXIncludeIncludeNode: * @ctxt: an XInclude context * @ref: an xmlXIncludeRefPtr * * Implement the infoset replacement for the given node * * Returns 0 if substitution succeeded, -1 if some processing failed */

Source from the content-addressed store, hash-verified

1942 * Returns 0 if substitution succeeded, -1 if some processing failed
1943 */
1944static int
1945xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
1946 xmlNodePtr cur, end, list, tmp;
1947
1948 if ((ctxt == NULL) || (ref == NULL))
1949 return(-1);
1950 cur = ref->elem;
1951 if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
1952 return(-1);
1953
1954 list = ref->inc;
1955 ref->inc = NULL;
1956
1957 /*
1958 * Check against the risk of generating a multi-rooted document
1959 */
1960 if ((cur->parent != NULL) &&
1961 (cur->parent->type != XML_ELEMENT_NODE)) {
1962 int nb_elem = 0;
1963
1964 tmp = list;
1965 while (tmp != NULL) {
1966 if (tmp->type == XML_ELEMENT_NODE)
1967 nb_elem++;
1968 tmp = tmp->next;
1969 }
1970 if (nb_elem > 1) {
1971 xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_MULTIPLE_ROOT,
1972 "XInclude error: would result in multiple root nodes\n",
1973 NULL);
1974 xmlFreeNodeList(list);
1975 return(-1);
1976 }
1977 }
1978
1979 if (ctxt->parseFlags & XML_PARSE_NOXINCNODE) {
1980 /*
1981 * Add the list of nodes
1982 *
1983 * TODO: Coalesce text nodes unless we are streaming mode.
1984 */
1985 while (list != NULL) {
1986 end = list;
1987 list = list->next;
1988
1989 if (xmlAddPrevSibling(cur, end) == NULL) {
1990 xmlUnlinkNode(end);
1991 xmlFreeNode(end);
1992 goto err_memory;
1993 }
1994 }
1995 xmlUnlinkNode(cur);
1996 xmlFreeNode(cur);
1997 } else {
1998 xmlNodePtr child, next;
1999
2000 /*
2001 * Change the current node as an XInclude start one, and add an

Callers 1

xmlXIncludeDoProcessFunction · 0.85

Calls 8

xmlFreeNodeListFunction · 0.85
xmlAddPrevSiblingFunction · 0.85
xmlUnlinkNodeFunction · 0.85
xmlFreeNodeFunction · 0.85
xmlUnsetPropFunction · 0.85
xmlNewDocNodeFunction · 0.85
xmlAddNextSiblingFunction · 0.85
xmlXIncludeErrMemoryFunction · 0.85

Tested by

no test coverage detected