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

Function xmlXIncludeParseFile

ThirdParty/libxml2/vtklibxml2/xinclude.c:305–367  ·  view source on GitHub ↗

* xmlXIncludeParseFile: * @ctxt: the XInclude context * @URL: the URL or file path * * parse a document for XInclude */

Source from the content-addressed store, hash-verified

303 * parse a document for XInclude
304 */
305static xmlDocPtr
306xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
307 xmlDocPtr ret = NULL;
308 xmlParserCtxtPtr pctxt;
309 xmlParserInputPtr inputStream;
310
311 xmlInitParser();
312
313 pctxt = xmlNewParserCtxt();
314 if (pctxt == NULL) {
315 xmlXIncludeErrMemory(ctxt);
316 return(NULL);
317 }
318 if (ctxt->errorHandler != NULL)
319 xmlCtxtSetErrorHandler(pctxt, ctxt->errorHandler, ctxt->errorCtxt);
320
321 /*
322 * pass in the application data to the parser context.
323 */
324 pctxt->_private = ctxt->_private;
325
326 /*
327 * try to ensure that new documents included are actually
328 * built with the same dictionary as the including document.
329 */
330 if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL)) {
331 if (pctxt->dict != NULL)
332 xmlDictFree(pctxt->dict);
333 pctxt->dict = ctxt->doc->dict;
334 xmlDictReference(pctxt->dict);
335 }
336
337 /*
338 * We set DTDLOAD to make sure that ID attributes declared in
339 * external DTDs are detected.
340 */
341 xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD);
342
343 inputStream = xmlLoadExternalEntity(URL, NULL, pctxt);
344 if (inputStream == NULL)
345 goto error;
346
347 inputPush(pctxt, inputStream);
348
349 xmlParseDocument(pctxt);
350
351 if (pctxt->wellFormed) {
352 ret = pctxt->myDoc;
353 }
354 else {
355 ret = NULL;
356 if (pctxt->myDoc != NULL)
357 xmlFreeDoc(pctxt->myDoc);
358 pctxt->myDoc = NULL;
359 }
360
361error:
362 if (pctxt->errNo == XML_ERR_NO_MEMORY)

Callers 1

xmlXIncludeLoadDocFunction · 0.85

Calls 12

xmlInitParserFunction · 0.85
xmlNewParserCtxtFunction · 0.85
xmlXIncludeErrMemoryFunction · 0.85
xmlCtxtSetErrorHandlerFunction · 0.85
xmlDictFreeFunction · 0.85
xmlDictReferenceFunction · 0.85
xmlCtxtUseOptionsFunction · 0.85
xmlLoadExternalEntityFunction · 0.85
inputPushFunction · 0.85
xmlParseDocumentFunction · 0.85
xmlFreeDocFunction · 0.85
xmlFreeParserCtxtFunction · 0.85

Tested by

no test coverage detected