#include
#include
#include
]]>
int main(int argc, char **argv) {
/* printf("finished.\n"); */
return (0);
}
nsTest_
();
xmlDocPtr
;
const char *
_str = "
";
const char *
exp_str = "
";
= xmlReadDoc(BAD_CAST
_str, NULL, NULL, 0);
xmlFreeDoc(
);
xmlNodePtr
;
/* Selecting node "". */
xp = xmlXPathNewContext(
);
xmlXPathRegisterNs(xp, BAD_CAST "
", BAD_CAST "
");
= nsSelectNode(xp, "
");
xmlXPathFreeContext(xp);
/* Reconcile node "". */
xmlDOMWrapReconcileNamespaces(NULL,
, 0);
xmlDOMWrapRemoveNode(NULL,
->doc,
, 0);
/* Adopt "". */
xmlDOMWrapAdoptNode(NULL,
->doc,
,
,
NULL
, 0);
xmlAddChild(
,
);
/* Serialize "". */
result_str = nsSerializeNode(xmlDocGetRootElement(
));
/* Compare result. */
if (! xmlStrEqual(BAD_CAST result_str, BAD_CAST exp_str)) {
printf("FAILED\n");
printf("%s\n", (const char *) result_str);
printf("- - -\n");
printf("Expected:\n%s\n", exp_str);
printf("= = =\n");
}
xmlFree(result_str);
void nsTest_
(void) {
xmlChar * result_str;
xmlXPathContextPtr xp;
int memory;
memory = xmlMemUsed();
xmlInitParser();
xmlCleanupParser();
memory = xmlMemUsed() - memory;
if (memory != 0) {
printf("## '%s' MEMORY leak: %d\n", "
", memory);
}
}
xmlChar * nsSerializeNode(xmlNodePtr node) {
xmlChar * ret;
xmlOutputBufferPtr buf;
buf = xmlAllocOutputBuffer(NULL);
xmlNodeDumpOutput(buf, node->doc, node, 0, 0, NULL);
xmlOutputBufferFlush(buf);
ret = (xmlChar *) buf->buffer->content;
buf->buffer->content = NULL;
(void) xmlOutputBufferClose(buf);
return (ret);
}
xmlNodePtr nsSelectNode(xmlXPathContextPtr xp, const char * xpath) {
xmlXPathObjectPtr xpres;
xmlNodePtr ret;
xpres = xmlXPathEval(BAD_CAST xpath, xp);
ret = xpres->nodesetval->nodeTab[0];
xmlXPathFreeObject(xpres);
return (ret);
}