diff --git a/ChangeLog b/ChangeLog index 65c0b040..4fea04ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 27 14:06:10 CEST 2005 Kasimier Buchcik + + * test/namespaces/reconcile/tests.xml + test/namespaces/reconcile/tests-to-c.xsl: Added initial tests + for some new DOM-wrapper helping functions. + Mon Jun 27 14:01:06 CEST 2005 Kasimier Buchcik * xstc/xstc-to-python.xsl: Cleanup. diff --git a/test/namespaces/reconcile/tests-to-c.xsl b/test/namespaces/reconcile/tests-to-c.xsl new file mode 100644 index 00000000..9a0d1c66 --- /dev/null +++ b/test/namespaces/reconcile/tests-to-c.xsl @@ -0,0 +1,275 @@ + + + + + + +#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); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/namespaces/reconcile/tests.xml b/test/namespaces/reconcile/tests.xml new file mode 100644 index 00000000..c6f8c542 --- /dev/null +++ b/test/namespaces/reconcile/tests.xml @@ -0,0 +1,249 @@ + + + + + ]]> + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + ]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + + +]]> + + + + + ]]> + ]]> + + + + + + + + + + + + + + + +]]> + + + + + +

+ + + + + + +]]> + + + + + + + + + + +

+ + + + + +

+ +]]> +
+ + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + +]]> + +