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

Function xmlShellLoad

ThirdParty/libxml2/vtklibxml2/debugXML.c:2442–2482  ·  view source on GitHub ↗

* xmlShellLoad: * @ctxt: the shell context * @filename: the file name * @node: unused * @node2: unused * * Implements the XML shell function "load" * loads a new document specified by the filename * * Returns 0 or -1 if loading failed */

Source from the content-addressed store, hash-verified

2440 * Returns 0 or -1 if loading failed
2441 */
2442int
2443xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
2444 xmlNodePtr node ATTRIBUTE_UNUSED,
2445 xmlNodePtr node2 ATTRIBUTE_UNUSED)
2446{
2447 xmlDocPtr doc;
2448 int html = 0;
2449
2450 if ((ctxt == NULL) || (filename == NULL)) return(-1);
2451 if (ctxt->doc != NULL)
2452 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2453
2454 if (html) {
2455#ifdef LIBXML_HTML_ENABLED
2456 doc = htmlParseFile(filename, NULL);
2457#else
2458 fprintf(ctxt->output, "HTML support not compiled in\n");
2459 doc = NULL;
2460#endif /* LIBXML_HTML_ENABLED */
2461 } else {
2462 doc = xmlReadFile(filename,NULL,0);
2463 }
2464 if (doc != NULL) {
2465 if (ctxt->loaded == 1) {
2466 xmlFreeDoc(ctxt->doc);
2467 }
2468 ctxt->loaded = 1;
2469#ifdef LIBXML_XPATH_ENABLED
2470 xmlXPathFreeContext(ctxt->pctxt);
2471#endif /* LIBXML_XPATH_ENABLED */
2472 xmlFree(ctxt->filename);
2473 ctxt->doc = doc;
2474 ctxt->node = (xmlNodePtr) doc;
2475#ifdef LIBXML_XPATH_ENABLED
2476 ctxt->pctxt = xmlXPathNewContext(doc);
2477#endif /* LIBXML_XPATH_ENABLED */
2478 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename);
2479 } else
2480 return (-1);
2481 return (0);
2482}
2483
2484#ifdef LIBXML_OUTPUT_ENABLED
2485/**

Callers 1

xmlShellFunction · 0.85

Calls 7

htmlParseFileFunction · 0.85
fprintfFunction · 0.85
xmlReadFileFunction · 0.85
xmlFreeDocFunction · 0.85
xmlXPathFreeContextFunction · 0.85
xmlXPathNewContextFunction · 0.85
xmlCanonicPathFunction · 0.85

Tested by

no test coverage detected