Commit 0996a162 authored by Daniel Veillard's avatar Daniel Veillard

fixed the namespaces support fixed xmlGetNodePath when namespaces are used

* pattern.c: fixed the namespaces support
* tree.c: fixed xmlGetNodePath when namespaces are used
* result/pattern/multiple result/pattern/namespaces
  test/pattern/multiple.* test/pattern/namespaces.*: added
  more regression tests
Daniel
parent e92bf5d6
Sat Feb 5 14:58:46 CET 2005 Daniel Veillard <daniel@veillard.com>
* pattern.c: fixed the namespaces support
* tree.c: fixed xmlGetNodePath when namespaces are used
* result/pattern/multiple result/pattern/namespaces
test/pattern/multiple.* test/pattern/namespaces.*: added
more regression tests
Fri Feb 4 18:26:43 CET 2005 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c: fixed one internal function
......
......@@ -19,8 +19,6 @@
* currently push(NULL, NULL) means a reset of the streaming context
* and indicating we are on / (the document node), probably need
* something similar for .
* - xmlPatterncompile support of namespaces arguments, I'm not sure
* it's implemented and definitely not tested
* - handling of disjunction "pattern1 | pattern2" mean needed to build
* and check a list internally
* - get rid of the "compile" starting with lowercase
......@@ -882,7 +880,6 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
NEXT;
if (CUR != ':') {
xmlChar *prefix = name;
xmlNsPtr ns;
int i;
/*
......@@ -891,7 +888,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
token = xmlPatScanName(ctxt);
for (i = 0;i < ctxt->nb_namespaces;i++) {
if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) {
URL = xmlStrdup(ctxt->namespaces[2 * i + 1]);
URL = xmlStrdup(ctxt->namespaces[2 * i]);
break;
}
}
......@@ -901,8 +898,6 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
prefix);
ctxt->error = 1;
goto error;
} else {
URL = xmlStrdup(ns->href);
}
xmlFree(prefix);
if (token == NULL) {
......
Node /c/b[1]/a[1] matches pattern a
Node /c/b[1]/a[2] matches pattern a
Node /c/c/b/a[1] matches pattern a
Node /c/c/b/a[2] matches pattern a
Node /c/b[2]/a[1] matches pattern a
Node /c/b[2]/a[2] matches pattern a
Node /c/b[1] matches pattern b
Node /c/c/b matches pattern b
Node /c/b[2] matches pattern b
Node /c matches pattern c
Node /c/c matches pattern c
Node /c/b[1] matches pattern c/b
Node /c/c/b matches pattern c/b
Node /c/b[2] matches pattern c/b
Node /c/b[1]/a[1] matches pattern b/a
Node /c/b[1]/a[2] matches pattern b/a
Node /c/c/b/a[1] matches pattern b/a
Node /c/c/b/a[2] matches pattern b/a
Node /c/b[2]/a[1] matches pattern b/a
Node /c/b[2]/a[2] matches pattern b/a
Node /c/b[1]/a[1] matches pattern c/b/a
Node /c/b[1]/a[2] matches pattern c/b/a
Node /c/c/b/a[1] matches pattern c/b/a
Node /c/c/b/a[2] matches pattern c/b/a
Node /c/b[2]/a[1] matches pattern c/b/a
Node /c/b[2]/a[2] matches pattern c/b/a
Node /c/b[1]/a[1] matches pattern c//a
Node /c/b[1]/a[2] matches pattern c//a
Node /c/c/b/a[1] matches pattern c//a
Node /c/c/b/a[2] matches pattern c//a
Node /c/b[2]/a[1] matches pattern c//a
Node /c/b[2]/a[2] matches pattern c//a
Node /c/b[1] matches pattern c//b
Node /c/c/b matches pattern c//b
Node /c/b[2] matches pattern c//b
Node /c/b[1]/a[1] matches pattern b//a
Node /c/b[1]/a[2] matches pattern b//a
Node /c/c/b/a[1] matches pattern b//a
Node /c/c/b/a[2] matches pattern b//a
Node /c/b[2]/a[1] matches pattern b//a
Node /c/b[2]/a[2] matches pattern b//a
Node /c/b[1]/a[1] matches pattern c//b//a
Node /c/b[1]/a[2] matches pattern c//b//a
Node /c/c/b/a[1] matches pattern c//b//a
Node /c/c/b/a[2] matches pattern c//b//a
Node /c/b[2]/a[1] matches pattern c//b//a
Node /c/b[2]/a[2] matches pattern c//b//a
Node /c/b[1]/a[1] matches pattern c/b//a
Node /c/b[1]/a[2] matches pattern c/b//a
Node /c/c/b/a[1] matches pattern c/b//a
Node /c/c/b/a[2] matches pattern c/b//a
Node /c/b[2]/a[1] matches pattern c/b//a
Node /c/b[2]/a[2] matches pattern c/b//a
Node /c/b[1]/a[1] matches pattern c//b/a
Node /c/b[1]/a[2] matches pattern c//b/a
Node /c/c/b/a[1] matches pattern c//b/a
Node /c/c/b/a[2] matches pattern c//b/a
Node /c/b[2]/a[1] matches pattern c//b/a
Node /c/b[2]/a[2] matches pattern c//b/a
Node /c matches pattern /c
Node /c/b[1] matches pattern /c/b
Node /c/b[2] matches pattern /c/b
Node /c/b[1]/a[1] matches pattern /c/b/a
Node /c/b[1]/a[2] matches pattern /c/b/a
Node /c/b[2]/a[1] matches pattern /c/b/a
Node /c/b[2]/a[2] matches pattern /c/b/a
Node /c/b[1]/a[1] matches pattern /c//a
Node /c/b[1]/a[2] matches pattern /c//a
Node /c/c/b/a[1] matches pattern /c//a
Node /c/c/b/a[2] matches pattern /c//a
Node /c/b[2]/a[1] matches pattern /c//a
Node /c/b[2]/a[2] matches pattern /c//a
Node /c/b[1] matches pattern /c//b
Node /c/c/b matches pattern /c//b
Node /c/b[2] matches pattern /c//b
Node /c/b[1]/a[1] matches pattern /c//b//a
Node /c/b[1]/a[2] matches pattern /c//b//a
Node /c/c/b/a[1] matches pattern /c//b//a
Node /c/c/b/a[2] matches pattern /c//b//a
Node /c/b[2]/a[1] matches pattern /c//b//a
Node /c/b[2]/a[2] matches pattern /c//b//a
Node /c/b[1]/a[1] matches pattern /c/b//a
Node /c/b[1]/a[2] matches pattern /c/b//a
Node /c/b[2]/a[1] matches pattern /c/b//a
Node /c/b[2]/a[2] matches pattern /c/b//a
Node /c/b[1]/a[1] matches pattern /c//b/a
Node /c/b[1]/a[2] matches pattern /c//b/a
Node /c/c/b/a[1] matches pattern /c//b/a
Node /c/c/b/a[2] matches pattern /c//b/a
Node /c/b[2]/a[1] matches pattern /c//b/a
Node /c/b[2]/a[2] matches pattern /c//b/a
Node /a matches pattern //a
Node /a/b:b/a matches pattern //a
Node /a/a/a matches pattern //a
Node /a/a:a matches pattern //a:a
Node /a/b:b/a/a:a matches pattern //a:a
Node /a/a matches pattern //a:a
Node /a/c:a matches pattern //a:a
Node /a/b matches pattern //b
Node /a/a:a/b:b matches pattern //b:b
Node /a/b:b matches pattern //b:b
Node /a/b:b/a/a:a/b:b matches pattern //b:b
Node /a/b:b/a matches pattern /a//a
Node /a/a/a matches pattern /a//a
Node /a/b matches pattern /a/b
Node /a/a:a matches pattern /a/a:a
Node /a/a matches pattern /a/a:a
Node /a/c:a matches pattern /a/a:a
Node /a/a:a matches pattern /a/c:a
Node /a/a matches pattern /a/c:a
Node /a/c:a matches pattern /a/c:a
a
b
c
c/a
c/b
b/a
c/b/a
c//a
c//b
b//a
c//b//a
c/b//a
c//b/a
/a
/b
/c
/c/a
/c/b
/b/a
/c/b/a
/c//a
/c//b
/b//a
/c//b//a
/c/b//a
/c//b/a
<c>
<b><a/><a/></b>
<c><b><a/><a/></b></c>
<b><a/><a/></b>
</c>
//a
//a:a
//b
//b:b
/a//a
/a/a
/a/b
/a/a:a
/a/a:b
/a/c:a
<a xmlns:a="http://a" xmlns:b="http://b" xmlns:c="http://a">
<b/>
<a:a>
<b:b/>
</a:a>
<b:b>
<a>
<a:a>
<b:b/>
</a:a>
</a>
</b:b>
<a xmlns="http://a">
<a xmlns=""/>
</a>
<c:a/>
</a>
......@@ -4307,7 +4307,10 @@ xmlGetNodePath(xmlNodePtr node)
tmp = cur->prev;
while (tmp != NULL) {
if ((tmp->type == XML_ELEMENT_NODE) &&
(xmlStrEqual(cur->name, tmp->name)))
(xmlStrEqual(cur->name, tmp->name)) &&
((tmp->ns == cur->ns) ||
((tmp->ns != NULL) && (cur->ns != NULL) &&
(xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))
occur++;
tmp = tmp->prev;
}
......@@ -4315,7 +4318,10 @@ xmlGetNodePath(xmlNodePtr node)
tmp = cur->next;
while (tmp != NULL && occur == 0) {
if ((tmp->type == XML_ELEMENT_NODE) &&
(xmlStrEqual(cur->name, tmp->name)))
(xmlStrEqual(cur->name, tmp->name)) &&
((tmp->ns == cur->ns) ||
((tmp->ns != NULL) && (cur->ns != NULL) &&
(xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))
occur++;
tmp = tmp->next;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment