1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-27 03:21:26 +03:00

fixed xmlRelaxNGNodeMatchesList augmented the test suite this fixes some

* relaxng.c: fixed xmlRelaxNGNodeMatchesList
* test/relaxng/testsuite.xml: augmented the test suite
* result/relaxng/spec1* result/relaxng/tutor12_1*: this fixes
  some schemas validation tests in the presence of foreign
  namespaces.
Daniel
This commit is contained in:
Daniel Veillard 2003-03-21 12:43:18 +00:00
parent bbb78b5d6d
commit 0e3d3ce267
3 changed files with 126 additions and 35 deletions

View File

@ -1,3 +1,11 @@
Fri Mar 21 13:41:23 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c: fixed xmlRelaxNGNodeMatchesList
* test/relaxng/testsuite.xml: augmented the test suite
* result/relaxng/spec1* result/relaxng/tutor12_1*: this fixes
some schemas validation tests in the presence of foreign
namespaces.
Fri Mar 21 02:23:34 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c: added another interleave speedup.

View File

@ -7533,7 +7533,7 @@ xmlRelaxNGValidateAttributeList(xmlRelaxNGValidCtxtPtr ctxt,
static int
xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr *list) {
xmlRelaxNGDefinePtr cur;
int i = 0;
int i = 0, tmp;
if ((node == NULL) || (list == NULL))
return(0);
@ -7542,25 +7542,9 @@ xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr *list) {
while (cur != NULL) {
if ((node->type == XML_ELEMENT_NODE) &&
(cur->type == XML_RELAXNG_ELEMENT)) {
if (cur->name == NULL) {
if ((cur->ns == NULL) || (cur->ns[0] == 0)) {
if (node->ns == NULL)
return(1);
} else {
if ((node->ns != NULL) &&
(xmlStrEqual(node->ns->href, cur->ns)))
return(1);
}
} else if (xmlStrEqual(cur->name, node->name)) {
if ((cur->ns == NULL) || (cur->ns[0] == 0)) {
if (node->ns == NULL)
return(1);
} else {
if ((node->ns != NULL) &&
(xmlStrEqual(node->ns->href, cur->ns)))
return(1);
}
}
tmp = xmlRelaxNGElementMatch(NULL, cur, node);
if (tmp == 1)
return(1);
} else if (((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) &&
(cur->type == XML_RELAXNG_TEXT)) {
@ -7897,51 +7881,65 @@ xmlRelaxNGElementMatch(xmlRelaxNGValidCtxtPtr ctxt,
define = define->nameClass;
if (define->type == XML_RELAXNG_EXCEPT) {
xmlRelaxNGDefinePtr list;
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
if (ctxt != NULL) {
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
}
list = define->content;
while (list != NULL) {
ret = xmlRelaxNGElementMatch(ctxt, list, elem);
if (ret == 1) {
ctxt->flags = oldflags;
if (ctxt != NULL)
ctxt->flags = oldflags;
return(0);
}
if (ret < 0) {
ctxt->flags = oldflags;
if (ctxt != NULL)
ctxt->flags = oldflags;
return(ret);
}
list = list->next;
}
ret = 1;
ctxt->flags = oldflags;
if (ctxt != NULL) {
ctxt->flags = oldflags;
}
} else if (define->type == XML_RELAXNG_CHOICE) {
xmlRelaxNGDefinePtr list;
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
if (ctxt != NULL) {
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
}
list = define->nameClass;
while (list != NULL) {
ret = xmlRelaxNGElementMatch(ctxt, list, elem);
if (ret == 1) {
ctxt->flags = oldflags;
if (ctxt != NULL)
ctxt->flags = oldflags;
return(1);
}
if (ret < 0) {
ctxt->flags = oldflags;
if (ctxt != NULL)
ctxt->flags = oldflags;
return(ret);
}
list = list->next;
}
if (ret != 0) {
if ((ctxt->flags & FLAGS_IGNORABLE) == 0)
xmlRelaxNGDumpValidError(ctxt);
} else {
if (ctxt->errNr > 0) xmlRelaxNGPopErrors(ctxt, 0);
if (ctxt != NULL) {
if (ret != 0) {
if ((ctxt->flags & FLAGS_IGNORABLE) == 0)
xmlRelaxNGDumpValidError(ctxt);
} else {
if (ctxt->errNr > 0) xmlRelaxNGPopErrors(ctxt, 0);
}
}
ret = 0;
ctxt->flags = oldflags;
if (ctxt != NULL) {
ctxt->flags = oldflags;
}
} else {
TODO
ret = -1;

View File

@ -3,6 +3,91 @@
<email>daniel@veillard.com</email>
<documentation>For libxml2 implementation of Relax NG spec.</documentation>
<testSuite>
<documentation>Test of node matches</documentation>
<testCase>
<correct>
<element xmlns="http://relaxng.org/ns/structure/1.0">
<anyName>
<except>
<nsName ns="http://example.org"/>
</except>
</anyName>
<empty/>
</element>
</correct>
<valid>
<foo/>
</valid>
<valid>
<foo xmlns="http://example.org/"/>
</valid>
<valid>
<foo xmlns="http://EXAMPLE.ORG"/>
</valid>
<invalid>
<foo xmlns="http://example.org"/>
</invalid>
<invalid>
<a:foo xmlns:a="http://example.org"/>
</invalid>
</testCase>
<testCase>
<correct>
<element name="top" xmlns="http://relaxng.org/ns/structure/1.0">
<interleave>
<element name="foo" ns="http://example.org">
<empty/>
</element>
<element>
<anyName>
<except>
<nsName ns="http://example.org"/>
</except>
</anyName>
<empty/>
</element>
</interleave>
</element>
</correct>
<invalid>
<top>
<foo/>
<bar/>
</top>
</invalid>
<invalid>
<top>
<foo xmlns="http://example.org"/>
<bar xmlns="http://example.org"/>
</top>
</invalid>
<valid>
<top>
<foo xmlns="http://example.org"/>
<bar/>
</top>
</valid>
<valid>
<top>
<bar/>
<foo xmlns="http://example.org"/>
</top>
</valid>
<valid>
<top>
<foo xmlns="http://example.org"/>
<bar xmlns="http://example.org/"/>
</top>
</valid>
<valid>
<top>
<bar xmlns="http://example.org/"/>
<foo xmlns="http://example.org"/>
</top>
</valid>
</testCase>
</testSuite>
<testSuite>
<documentation>Test of indeterminism</documentation>
<testCase>
<correct>