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

Function xmlXIncludeDoProcess

ThirdParty/libxml2/vtklibxml2/xinclude.c:2132–2203  ·  view source on GitHub ↗

* xmlXIncludeDoProcess: * @ctxt: the XInclude processing context * @tree: the top of the tree to process * * Implement the XInclude substitution on the XML document @doc * * Returns 0 if no substitution were done, -1 if some processing failed * or the number of substitutions done. */

Source from the content-addressed store, hash-verified

2130 * or the number of substitutions done.
2131 */
2132static int
2133xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlNodePtr tree) {
2134 xmlXIncludeRefPtr ref;
2135 xmlNodePtr cur;
2136 int ret = 0;
2137 int i, start;
2138
2139 /*
2140 * First phase: lookup the elements in the document
2141 */
2142 start = ctxt->incNr;
2143 cur = tree;
2144 do {
2145 /* TODO: need to work on entities -> stack */
2146 if (xmlXIncludeTestNode(ctxt, cur) == 1) {
2147 ref = xmlXIncludeExpandNode(ctxt, cur);
2148 /*
2149 * Mark direct includes.
2150 */
2151 if (ref != NULL)
2152 ref->replace = 1;
2153 } else if ((cur->children != NULL) &&
2154 ((cur->type == XML_DOCUMENT_NODE) ||
2155 (cur->type == XML_ELEMENT_NODE))) {
2156 cur = cur->children;
2157 continue;
2158 }
2159 do {
2160 if (cur == tree)
2161 break;
2162 if (cur->next != NULL) {
2163 cur = cur->next;
2164 break;
2165 }
2166 cur = cur->parent;
2167 } while (cur != NULL);
2168 } while ((cur != NULL) && (cur != tree));
2169
2170 /*
2171 * Second phase: extend the original document infoset.
2172 */
2173 for (i = start; i < ctxt->incNr; i++) {
2174 if (ctxt->incTab[i]->replace != 0) {
2175 xmlXIncludeIncludeNode(ctxt, ctxt->incTab[i]);
2176 ctxt->incTab[i]->replace = 0;
2177 } else {
2178 /*
2179 * Ignore includes which were added indirectly, for example
2180 * inside xi:fallback elements.
2181 */
2182 if (ctxt->incTab[i]->inc != NULL) {
2183 xmlFreeNodeList(ctxt->incTab[i]->inc);
2184 ctxt->incTab[i]->inc = NULL;
2185 }
2186 }
2187 ret++;
2188 }
2189

Callers 2

xmlXIncludeRecurseDocFunction · 0.85
xmlXIncludeDoProcessRootFunction · 0.85

Calls 5

xmlXIncludeTestNodeFunction · 0.85
xmlXIncludeExpandNodeFunction · 0.85
xmlXIncludeIncludeNodeFunction · 0.85
xmlFreeNodeListFunction · 0.85
xmlXIncludeFreeRefFunction · 0.85

Tested by

no test coverage detected