* xmlShellRegisterRootNamespaces: * @ctxt: the shell context * @arg: unused * @node: the root element * @node2: unused * * Implements the XML shell function "setrootns" * which registers all namespaces declarations found on the root element. * * Returns 0 on success and a negative value otherwise. */
| 2144 | * Returns 0 on success and a negative value otherwise. |
| 2145 | */ |
| 2146 | static int |
| 2147 | xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED, |
| 2148 | xmlNodePtr root, xmlNodePtr node2 ATTRIBUTE_UNUSED) |
| 2149 | { |
| 2150 | xmlNsPtr ns; |
| 2151 | |
| 2152 | if ((root == NULL) || (root->type != XML_ELEMENT_NODE) || |
| 2153 | (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL)) |
| 2154 | return(-1); |
| 2155 | ns = root->nsDef; |
| 2156 | while (ns != NULL) { |
| 2157 | if (ns->prefix == NULL) |
| 2158 | xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href); |
| 2159 | else |
| 2160 | xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href); |
| 2161 | ns = ns->next; |
| 2162 | } |
| 2163 | return(0); |
| 2164 | } |
| 2165 | #endif |
| 2166 | |
| 2167 | /** |
no test coverage detected