* xmlNsCheckScope: * @node: the node * @ns: the namespace node * * Check that a given namespace is in scope on a node. * * Returns 1 if in scope, -1 in case of argument error, * -2 if the namespace is not in scope, and -3 if not on * an ancestor node. */
| 86 | * an ancestor node. |
| 87 | */ |
| 88 | static int |
| 89 | xmlNsCheckScope(xmlNodePtr node, xmlNsPtr ns) |
| 90 | { |
| 91 | xmlNsPtr cur; |
| 92 | |
| 93 | if ((node == NULL) || (ns == NULL)) |
| 94 | return(-1); |
| 95 | |
| 96 | if ((node->type != XML_ELEMENT_NODE) && |
| 97 | (node->type != XML_ATTRIBUTE_NODE) && |
| 98 | (node->type != XML_DOCUMENT_NODE) && |
| 99 | (node->type != XML_TEXT_NODE) && |
| 100 | (node->type != XML_HTML_DOCUMENT_NODE) && |
| 101 | (node->type != XML_XINCLUDE_START)) |
| 102 | return(-2); |
| 103 | |
| 104 | while ((node != NULL) && |
| 105 | ((node->type == XML_ELEMENT_NODE) || |
| 106 | (node->type == XML_ATTRIBUTE_NODE) || |
| 107 | (node->type == XML_TEXT_NODE) || |
| 108 | (node->type == XML_XINCLUDE_START))) { |
| 109 | if ((node->type == XML_ELEMENT_NODE) || |
| 110 | (node->type == XML_XINCLUDE_START)) { |
| 111 | cur = node->nsDef; |
| 112 | while (cur != NULL) { |
| 113 | if (cur == ns) |
| 114 | return(1); |
| 115 | if (xmlStrEqual(cur->prefix, ns->prefix)) |
| 116 | return(-2); |
| 117 | cur = cur->next; |
| 118 | } |
| 119 | } |
| 120 | node = node->parent; |
| 121 | } |
| 122 | /* the xml namespace may be declared on the document node */ |
| 123 | if ((node != NULL) && |
| 124 | ((node->type == XML_DOCUMENT_NODE) || |
| 125 | (node->type == XML_HTML_DOCUMENT_NODE))) { |
| 126 | xmlNsPtr oldNs = ((xmlDocPtr) node)->oldNs; |
| 127 | if (oldNs == ns) |
| 128 | return(1); |
| 129 | } |
| 130 | return(-3); |
| 131 | } |
| 132 | |
| 133 | static void |
| 134 | xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt) |
no test coverage detected