mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-26 10:03:34 +03:00
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
This commit is contained in:
parent
e92bf5d6f4
commit
0996a162c9
@ -1,3 +1,11 @@
|
||||
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) {
|
||||
|
91
result/pattern/multiple
Normal file
91
result/pattern/multiple
Normal file
@ -0,0 +1,91 @@
|
||||
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
|
20
result/pattern/namespaces
Normal file
20
result/pattern/namespaces
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
27
test/pattern/multiple.pat
Normal file
27
test/pattern/multiple.pat
Normal file
@ -0,0 +1,27 @@
|
||||
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
|
||||
|
5
test/pattern/multiple.xml
Normal file
5
test/pattern/multiple.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<c>
|
||||
<b><a/><a/></b>
|
||||
<c><b><a/><a/></b></c>
|
||||
<b><a/><a/></b>
|
||||
</c>
|
10
test/pattern/namespaces.pat
Normal file
10
test/pattern/namespaces.pat
Normal file
@ -0,0 +1,10 @@
|
||||
//a
|
||||
//a:a
|
||||
//b
|
||||
//b:b
|
||||
/a//a
|
||||
/a/a
|
||||
/a/b
|
||||
/a/a:a
|
||||
/a/a:b
|
||||
/a/c:a
|
17
test/pattern/namespaces.xml
Normal file
17
test/pattern/namespaces.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<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>
|
10
tree.c
10
tree.c
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user