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

Function xmlShellRegisterNamespace

ThirdParty/libxml2/vtklibxml2/debugXML.c:2090–2133  ·  view source on GitHub ↗

* xmlShellRegisterNamespace: * @ctxt: the shell context * @arg: a string in prefix=nsuri format * @node: unused * @node2: unused * * Implements the XML shell function "setns" * register/unregister a prefix=namespace pair * on the XPath context * * Returns 0 on success and a negative value otherwise. */

Source from the content-addressed store, hash-verified

2088 * Returns 0 on success and a negative value otherwise.
2089 */
2090static int
2091xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,
2092 xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr node2 ATTRIBUTE_UNUSED)
2093{
2094 xmlChar* nsListDup;
2095 xmlChar* prefix;
2096 xmlChar* href;
2097 xmlChar* next;
2098
2099 nsListDup = xmlStrdup((xmlChar *) arg);
2100 next = nsListDup;
2101 while(next != NULL) {
2102 /* skip spaces */
2103 /*while((*next) == ' ') next++;*/
2104 if((*next) == '\0') break;
2105
2106 /* find prefix */
2107 prefix = next;
2108 next = (xmlChar*)xmlStrchr(next, '=');
2109 if(next == NULL) {
2110 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");
2111 xmlFree(nsListDup);
2112 return(-1);
2113 }
2114 *(next++) = '\0';
2115
2116 /* find href */
2117 href = next;
2118 next = (xmlChar*)xmlStrchr(next, ' ');
2119 if(next != NULL) {
2120 *(next++) = '\0';
2121 }
2122
2123 /* do register namespace */
2124 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {
2125 fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
2126 xmlFree(nsListDup);
2127 return(-1);
2128 }
2129 }
2130
2131 xmlFree(nsListDup);
2132 return(0);
2133}
2134/**
2135 * xmlShellRegisterRootNamespaces:
2136 * @ctxt: the shell context

Callers 1

xmlShellFunction · 0.85

Calls 4

xmlStrdupFunction · 0.85
xmlStrchrFunction · 0.85
fprintfFunction · 0.85
xmlXPathRegisterNsFunction · 0.85

Tested by

no test coverage detected