added merlin-c14n-two.tar.gz tests for c14n/exc-c14n and slightly modified
* result/c14n/exc-without-comments/merlin-c14n-two-*
result/c14n/without-comments/merlin-c14n-two-*
test/c14n/exc-without-comments/merlin-c14n-two-*
test/c14n/without-comments/merlin-c14n-two-*
testC14N.c Makefile.am: added merlin-c14n-two.tar.gz tests for
c14n/exc-c14n and slightly modified test script to handle
these test cases
* c14n.c: fixed bugs for complicated nodes set (namespace
without node and others from merlin-c14n-two.tar.gz)
* include/libxml/xpathInternals.h win32/dsp/libxml2.def.src
win32/libxml2.def.src: "opened" xmlXPathNodeSetFreeNs() function
for xmlsec performance patch
* xpath.c: fixed self::node() for namespaces and attributes
diff --git a/testC14N.c b/testC14N.c
index 9bd9e43..14236fa 100644
--- a/testC14N.c
+++ b/testC14N.c
@@ -46,8 +46,7 @@
xmlChar **parse_list(xmlChar *str);
-void
-print_xpath_nodes(xmlXPathObjectPtr ptr);
+void print_xpath_nodes(xmlNodeSetPtr nodes);
static int
test_c14n(const char* xml_filename, int with_comments, int exclusive,
@@ -184,11 +183,18 @@
xmlChar **buffer;
xmlChar **out = NULL;
int buffer_size = 0;
+ int len;
if(str == NULL) {
return(NULL);
}
+ len = strlen(str);
+ if((str[0] == '\'') && (str[len - 1] == '\'')) {
+ str[len - 1] = '\0';
+ str++;
+ len -= 2;
+ }
/*
* allocate an translation buffer.
*/
@@ -298,7 +304,7 @@
return(NULL);
}
- /* print_xpath_nodes(xpath); */
+ /* print_xpath_nodes(xpath->nodesetval); */
xmlFree(expr);
xmlXPathFreeContext(ctx);
@@ -307,21 +313,40 @@
}
void
-print_xpath_nodes(xmlXPathObjectPtr ptr) {
+print_xpath_nodes(xmlNodeSetPtr nodes) {
xmlNodePtr cur;
int i;
- if(ptr == NULL || ptr->nodesetval == NULL ){
+ if(nodes == NULL ){
fprintf(stderr, "Error: no nodes set defined\n");
return;
}
- for(i = 0; i < ptr->nodesetval->nodeNr; ++i) {
- cur = ptr->nodesetval->nodeTab[i];
- fprintf(stderr, "node %s. type %d\n", cur->name, cur->type);
+ fprintf(stderr, "Nodes Set:\n-----\n");
+ for(i = 0; i < nodes->nodeNr; ++i) {
+ if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
+ xmlNsPtr ns;
+
+ ns = (xmlNsPtr)nodes->nodeTab[i];
+ cur = (xmlNodePtr)ns->next;
+ fprintf(stderr, "namespace \"%s\"=\"%s\" for node %s:%s\n",
+ ns->prefix, ns->href,
+ (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name);
+ } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
+ cur = nodes->nodeTab[i];
+ fprintf(stderr, "element node \"%s:%s\"\n",
+ (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name);
+ } else {
+ cur = nodes->nodeTab[i];
+ fprintf(stderr, "node \"%s\": type %d\n", cur->name, cur->type);
+ }
}
}
+
+
+
+
#else
#include <stdio.h>
int main(int argc, char **argv) {