MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / xmlShellLoad

Function xmlShellLoad

Externals/LibXML/debugXML.c:2449–2489  ·  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

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

Callers 2

test_xmlShellLoadFunction · 0.85
xmlShellFunction · 0.85

Calls 6

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

Tested by 1

test_xmlShellLoadFunction · 0.68