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

Function xmlXIncludeTestNode

ThirdParty/libxml2/vtklibxml2/xinclude.c:2055–2120  ·  view source on GitHub ↗

* xmlXIncludeTestNode: * @ctxt: the XInclude processing context * @node: an XInclude node * * test if the node is an XInclude node * * Returns 1 true, 0 otherwise */

Source from the content-addressed store, hash-verified

2053 * Returns 1 true, 0 otherwise
2054 */
2055static int
2056xmlXIncludeTestNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
2057 if (node == NULL)
2058 return(0);
2059 if (node->type != XML_ELEMENT_NODE)
2060 return(0);
2061 if (node->ns == NULL)
2062 return(0);
2063 if ((xmlStrEqual(node->ns->href, XINCLUDE_NS)) ||
2064 (xmlStrEqual(node->ns->href, XINCLUDE_OLD_NS))) {
2065 if (xmlStrEqual(node->ns->href, XINCLUDE_OLD_NS)) {
2066 if (ctxt->legacy == 0) {
2067#if 0 /* wait for the XML Core Working Group to get something stable ! */
2068 xmlXIncludeWarn(ctxt, node, XML_XINCLUDE_DEPRECATED_NS,
2069 "Deprecated XInclude namespace found, use %s",
2070 XINCLUDE_NS);
2071#endif
2072 ctxt->legacy = 1;
2073 }
2074 }
2075 if (xmlStrEqual(node->name, XINCLUDE_NODE)) {
2076 xmlNodePtr child = node->children;
2077 int nb_fallback = 0;
2078
2079 while (child != NULL) {
2080 if ((child->type == XML_ELEMENT_NODE) &&
2081 (child->ns != NULL) &&
2082 ((xmlStrEqual(child->ns->href, XINCLUDE_NS)) ||
2083 (xmlStrEqual(child->ns->href, XINCLUDE_OLD_NS)))) {
2084 if (xmlStrEqual(child->name, XINCLUDE_NODE)) {
2085 xmlXIncludeErr(ctxt, node,
2086 XML_XINCLUDE_INCLUDE_IN_INCLUDE,
2087 "%s has an 'include' child\n",
2088 XINCLUDE_NODE);
2089 return(0);
2090 }
2091 if (xmlStrEqual(child->name, XINCLUDE_FALLBACK)) {
2092 nb_fallback++;
2093 }
2094 }
2095 child = child->next;
2096 }
2097 if (nb_fallback > 1) {
2098 xmlXIncludeErr(ctxt, node, XML_XINCLUDE_FALLBACKS_IN_INCLUDE,
2099 "%s has multiple fallback children\n",
2100 XINCLUDE_NODE);
2101 return(0);
2102 }
2103 return(1);
2104 }
2105 if (xmlStrEqual(node->name, XINCLUDE_FALLBACK)) {
2106 if ((node->parent == NULL) ||
2107 (node->parent->type != XML_ELEMENT_NODE) ||
2108 (node->parent->ns == NULL) ||
2109 ((!xmlStrEqual(node->parent->ns->href, XINCLUDE_NS)) &&
2110 (!xmlStrEqual(node->parent->ns->href, XINCLUDE_OLD_NS))) ||
2111 (!xmlStrEqual(node->parent->name, XINCLUDE_NODE))) {
2112 xmlXIncludeErr(ctxt, node,

Callers 1

xmlXIncludeDoProcessFunction · 0.85

Calls 1

xmlStrEqualFunction · 0.85

Tested by

no test coverage detected