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

Function xmlXIncludeBaseFixup

ThirdParty/libxml2/vtklibxml2/xinclude.c:615–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613 ************************************************************************/
614
615static void
616xmlXIncludeBaseFixup(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur, xmlNodePtr copy,
617 const xmlChar *targetBase) {
618 xmlChar *base = NULL;
619 xmlChar *relBase = NULL;
620 xmlNs ns;
621 int res;
622
623 if (cur->type != XML_ELEMENT_NODE)
624 return;
625
626 if (xmlNodeGetBaseSafe(cur->doc, cur, &base) < 0)
627 xmlXIncludeErrMemory(ctxt);
628
629 if ((base != NULL) && !xmlStrEqual(base, targetBase)) {
630 if (xmlBuildRelativeURISafe(base, targetBase, &relBase) < 0) {
631 xmlXIncludeErrMemory(ctxt);
632 goto done;
633 }
634 if (relBase == NULL) {
635 xmlXIncludeErr(ctxt, cur,
636 XML_XINCLUDE_HREF_URI,
637 "Building relative URI failed: %s\n",
638 base);
639 goto done;
640 }
641
642 /*
643 * If the new base doesn't contain a slash, it can be omitted.
644 */
645 if (xmlStrchr(relBase, '/') != NULL) {
646 res = xmlNodeSetBase(copy, relBase);
647 if (res < 0)
648 xmlXIncludeErrMemory(ctxt);
649 goto done;
650 }
651 }
652
653 /*
654 * Delete existing xml:base if bases are equal
655 */
656 memset(&ns, 0, sizeof(ns));
657 ns.href = XML_XML_NAMESPACE;
658 xmlUnsetNsProp(copy, &ns, BAD_CAST "base");
659
660done:
661 xmlFree(base);
662 xmlFree(relBase);
663}
664
665/**
666 * xmlXIncludeCopyNode:

Callers 2

xmlXIncludeCopyNodeFunction · 0.85
xmlXIncludeLoadDocFunction · 0.85

Calls 7

xmlNodeGetBaseSafeFunction · 0.85
xmlXIncludeErrMemoryFunction · 0.85
xmlStrEqualFunction · 0.85
xmlBuildRelativeURISafeFunction · 0.85
xmlStrchrFunction · 0.85
xmlNodeSetBaseFunction · 0.85
xmlUnsetNsPropFunction · 0.85

Tested by

no test coverage detected