1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

more work on name classes, the "validate all" schemas seems to work now.

* relaxng: more work on name classes, the "validate all" schemas
  seems to work now.
* test/relaxng/* result/relaxng/*: augmented/updated the
  regression tests
Daniel
This commit is contained in:
Daniel Veillard
2003-02-03 10:57:45 +00:00
parent 3b2e4e1c14
commit 1ed7f364bd
56 changed files with 7826 additions and 71 deletions

View File

@ -1,3 +1,10 @@
Mon Feb 3 11:56:05 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng: more work on name classes, the "validate all" schemas
seems to work now.
* test/relaxng/* result/relaxng/*: augmented/updated the
regression tests
Mon Feb 3 09:50:26 CET 2003 Daniel Veillard <daniel@veillard.com>
* python/libxml.c: removed an unprotedted debug message Aleksi Suhonen

View File

@ -12,6 +12,7 @@
* - simplification of the resulting compiled trees:
* - NOT_ALLOWED
* - EMPTY
* - handle namespace declarations as attributes.
*/
#define IN_LIBXML
@ -228,6 +229,7 @@ struct _xmlRelaxNGValidState {
xmlNodePtr node; /* the current node */
xmlNodePtr seq; /* the sequence of children left to validate */
int nbAttrs; /* the number of attributes */
int nbAttrLeft; /* the number of attributes left to validate */
xmlChar *value; /* the value when operating on string */
xmlChar *endvalue; /* the end value when operating on string */
xmlAttrPtr attrs[1]; /* the array of attributes */
@ -665,6 +667,7 @@ xmlRelaxNGNewValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node)
}
}
}
ret->nbAttrLeft = ret->nbAttrs;
return (ret);
}
@ -3942,6 +3945,7 @@ xmlRelaxNGSkipIgnored(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
*/
while ((node != NULL) &&
((node->type == XML_COMMENT_NODE) ||
(node->type == XML_PI_NODE) ||
((node->type == XML_TEXT_NODE) &&
(IS_BLANK_NODE(node))))) {
node = node->next;
@ -4292,6 +4296,8 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
xmlChar *value, *oldvalue;
xmlAttrPtr prop = NULL, tmp;
if (ctxt->state->nbAttrLeft <= 0)
return(-1);
if (define->name != NULL) {
for (i = 0;i < ctxt->state->nbAttrs;i++) {
tmp = ctxt->state->attrs[i];
@ -4319,6 +4325,7 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
* flag the attribute as processed
*/
ctxt->state->attrs[i] = NULL;
ctxt->state->nbAttrLeft--;
}
} else {
ret = -1;
@ -4350,6 +4357,7 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
* flag the attribute as processed
*/
ctxt->state->attrs[i] = NULL;
ctxt->state->nbAttrLeft--;
}
} else {
ret = -1;
@ -4381,6 +4389,7 @@ xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,
* flag the attribute as processed
*/
ctxt->state->attrs[i] = NULL;
ctxt->state->nbAttrLeft--;
}
} else {
ret = -1;
@ -4807,6 +4816,8 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
return(0);
while ((node != NULL) &&
((node->type == XML_TEXT_NODE) ||
(node->type == XML_COMMENT_NODE) ||
(node->type == XML_PI_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)))
node = node->next;
if (node == ctxt->state->seq) {
@ -4874,8 +4885,8 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
state->seq = xmlRelaxNGSkipIgnored(ctxt, state->seq);
if (state->seq != NULL) {
VALID_CTXT();
VALID_ERROR("Extra content for element %s\n",
node->name);
VALID_ERROR("Extra content for element %s: %s\n",
node->name, state->seq->name);
ret = -1;
}
}
@ -4921,26 +4932,42 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
}
/* no break on purpose */
case XML_RELAXNG_ZEROORMORE: {
xmlNodePtr cur, temp;
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
cur = ctxt->state->seq;
temp = NULL;
while ((cur != NULL) && (temp != cur)) {
temp = cur;
while (ctxt->state->nbAttrLeft != 0) {
oldstate = xmlRelaxNGCopyValidState(ctxt, ctxt->state);
ret = xmlRelaxNGValidateDefinition(ctxt, define->content);
if (ret != 0) {
xmlRelaxNGFreeValidState(ctxt->state);
ctxt->state = oldstate;
ret = 0;
break;
}
xmlRelaxNGFreeValidState(oldstate);
}
if (ret == 0) {
/*
* There is no attribute left to be consumed,
* we can check the closure by looking at ctxt->state->seq
*/
xmlNodePtr cur, temp;
cur = ctxt->state->seq;
temp = NULL;
while ((cur != NULL) && (temp != cur)) {
temp = cur;
oldstate = xmlRelaxNGCopyValidState(ctxt, ctxt->state);
ret = xmlRelaxNGValidateDefinition(ctxt, define->content);
if (ret != 0) {
xmlRelaxNGFreeValidState(ctxt->state);
ctxt->state = oldstate;
break;
}
xmlRelaxNGFreeValidState(oldstate);
cur = ctxt->state->seq;
}
}
ctxt->flags = oldflags;
ret = 0;
break;
}
case XML_RELAXNG_CHOICE: {

View File

@ -1,2 +1,2 @@
error detected at relaxng.c:4741
error detected at relaxng.c:5027
error detected at relaxng.c:4847
error detected at relaxng.c:5149

View File

@ -1,2 +1,2 @@
error detected at relaxng.c:4746
error detected at relaxng.c:5027
error detected at relaxng.c:4852
error detected at relaxng.c:5149

View File

@ -1,2 +1,2 @@
error detected at relaxng.c:4746
error detected at relaxng.c:5027
error detected at relaxng.c:4852
error detected at relaxng.c:5149

View File

@ -1,2 +1,2 @@
error detected at relaxng.c:4753
error detected at relaxng.c:5027
error detected at relaxng.c:4859
error detected at relaxng.c:5149

View File

@ -1,2 +1,2 @@
error detected at relaxng.c:4753
error detected at relaxng.c:5027
error detected at relaxng.c:4859
error detected at relaxng.c:5149

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor10_7_3.xml validation generated an internal error

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(email): -1
xmlRelaxNGValidateAttribute(name): -1
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor10_8_3.xml validation generated an internal error

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(email): -1
xmlRelaxNGValidateAttribute(name): -1
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -0,0 +1 @@
./test/relaxng/tutor11_1_1.xml validates

View File

@ -0,0 +1,15 @@
xmlRelaxNGValidateAttribute(anyName): 0
xmlRelaxNGValidateDefinition(): validated ref : 0
xmlRelaxNGValidateDefinition(): validated start : 0
xmlRelaxNGValidateAttribute(anyName): 0
xmlRelaxNGValidateDefinition(): validated anyName : 0
xmlRelaxNGValidateDefinition(): validated anyName : 0
xmlRelaxNGValidateDefinition(): validated attribute : 0
xmlRelaxNGValidateDefinition(): validated text : 0
xmlRelaxNGValidateAttribute(anyName): 0
xmlRelaxNGValidateDefinition(): validated ref : 0
xmlRelaxNGValidateDefinition(): validated choice : 0
xmlRelaxNGValidateDefinition(): validated zeroOrMore : 0
xmlRelaxNGValidateDefinition(): validated element : 0
xmlRelaxNGValidateDefinition(): validated define : 0
xmlRelaxNGValidateDefinition(): validated grammar : 0

View File

@ -0,0 +1 @@
./test/relaxng/tutor11_1_2.xml validates

View File

@ -0,0 +1,6 @@
xmlRelaxNGValidateDefinition(): validated name : 0
xmlRelaxNGValidateDefinition(): validated email : 0
xmlRelaxNGValidateDefinition(): validated em : 0
xmlRelaxNGValidateDefinition(): validated note : 0
xmlRelaxNGValidateDefinition(): validated card : 0
xmlRelaxNGValidateDefinition(): validated addressBook : 0

View File

@ -0,0 +1 @@
./test/relaxng/tutor11_1_3.xml validates

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
Expecting element name, got email
Extra content for element card
Extra content for element card: email
./test/relaxng/tutor3_2_1.xml validation generated an internal error

View File

@ -1,3 +1,3 @@
error detected at relaxng.c:4733
error detected at relaxng.c:4781
error detected at relaxng.c:4839
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,6 +1,5 @@
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateAttribute(name): 0
xmlRelaxNGValidateAttribute(note): -1
xmlRelaxNGValidateDefinition(): validated card : 0
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateAttribute(name): 0

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor3_5_2.xml validation generated an internal error

View File

@ -1,5 +1,4 @@
xmlRelaxNGValidateAttribute(name): -1
xmlRelaxNGValidateDefinition(): validated email : 0
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1,5 +1,4 @@
xmlRelaxNGValidateDefinition(): validated italic : 0
xmlRelaxNGValidateDefinition(): validated bold : 0
xmlRelaxNGValidateAttribute(style): -1
xmlRelaxNGValidateDefinition(): validated span : 0
xmlRelaxNGValidateDefinition(): validated p : 0

View File

@ -1,3 +1,3 @@
error detected at relaxng.c:4910
error detected at relaxng.c:5032
xmlRelaxNGValidateDefinition(): validated note : 0
xmlRelaxNGValidateDefinition(): validated bad : -1

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(preferredFormat): -1
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateAttribute(name): 0
error detected at relaxng.c:4789
error detected at relaxng.c:4895
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,2 +1,2 @@
Extra content for element preferredFormat
Extra content for element preferredFormat: text
./test/relaxng/tutor6_2_4.xml validation generated an internal error

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateDefinition(): validated name : 0
xmlRelaxNGValidateDefinition(): validated email : 0
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated preferredFormat : -1
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(preferredFormat): -1
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateAttribute(name): 0
error detected at relaxng.c:4789
error detected at relaxng.c:4895
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,4 +1,4 @@
Internal: failed to validate type float
internal error validating list
Extra content for element vector
Extra content for element vector: text
./test/relaxng/tutor7_1_2.xml validation generated an internal error

View File

@ -1,5 +1,5 @@
Unimplemented block at xmlschemastypes.c:1132
error detected at relaxng.c:3992
error detected at relaxng.c:4964
error detected at relaxng.c:4781
error detected at relaxng.c:4029
error detected at relaxng.c:5086
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated vector : -1

View File

@ -1,4 +1,4 @@
Extra data in list: 5.6
internal error validating list
Extra content for element vector
Extra content for element vector: text
./test/relaxng/tutor7_1_3.xml validation generated an internal error

View File

@ -1,6 +1,6 @@
Unimplemented block at xmlschemastypes.c:1132
Unimplemented block at xmlschemastypes.c:1132
error detected at relaxng.c:4180
error detected at relaxng.c:4964
error detected at relaxng.c:4781
error detected at relaxng.c:4217
error detected at relaxng.c:5086
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated vector : -1

View File

@ -1,3 +1,3 @@
error detected at relaxng.c:4155
error detected at relaxng.c:4964
error detected at relaxng.c:4192
error detected at relaxng.c:5086
xmlRelaxNGValidateDefinition(): validated vector : -1

View File

@ -1,4 +1,4 @@
Extra data in list: 5.6
internal error validating list
Extra content for element path
Extra content for element path: text
./test/relaxng/tutor7_3_4.xml validation generated an internal error

View File

@ -1,7 +1,7 @@
Unimplemented block at xmlschemastypes.c:1135
Unimplemented block at xmlschemastypes.c:1135
Unimplemented block at xmlschemastypes.c:1135
error detected at relaxng.c:4180
error detected at relaxng.c:4964
error detected at relaxng.c:4781
error detected at relaxng.c:4217
error detected at relaxng.c:5086
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated path : -1

View File

@ -1,4 +1,4 @@
Internal: failed to validate type double
internal error validating list
Extra content for element path
Extra content for element path: text
./test/relaxng/tutor7_3_5.xml validation generated an internal error

View File

@ -1,5 +1,5 @@
Unimplemented block at xmlschemastypes.c:1135
error detected at relaxng.c:3992
error detected at relaxng.c:4964
error detected at relaxng.c:4781
error detected at relaxng.c:4029
error detected at relaxng.c:5086
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated path : -1

View File

@ -1,2 +1,2 @@
Extra content for element head
Extra content for element head: meta
./test/relaxng/tutor8_2_4.xml validation generated an internal error

View File

@ -3,5 +3,5 @@ xmlRelaxNGComputeInterleaves(interleave0)
6 groups
xmlRelaxNGValidateDefinition(): validated title : 0
xmlRelaxNGValidateDefinition(): validated title : 0
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated head : -1

View File

@ -1,3 +1,3 @@
Expecting an element
Extra content for element head
Extra content for element head: meta
./test/relaxng/tutor8_2_5.xml validation generated an internal error

View File

@ -1,6 +1,6 @@
xmlRelaxNGComputeInterleaves(interleave0)
6 child
6 groups
error detected at relaxng.c:4727
error detected at relaxng.c:4781
error detected at relaxng.c:4833
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated head : -1

View File

@ -1,2 +1,2 @@
Extra content for element head
Extra content for element head: base
./test/relaxng/tutor8_2_6.xml validation generated an internal error

View File

@ -4,5 +4,5 @@ xmlRelaxNGComputeInterleaves(interleave0)
xmlRelaxNGValidateDefinition(): validated title : 0
xmlRelaxNGValidateDefinition(): validated base : 0
xmlRelaxNGValidateDefinition(): validated base : 0
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated head : -1

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor9_5_2.xml validation generated an internal error

View File

@ -3,7 +3,6 @@ xmlRelaxNGComputeInterleaves(interleave0)
2 child
2 groups
xmlRelaxNGValidateAttribute(name): 0
xmlRelaxNGValidateAttribute(email): -1
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor9_5_3.xml validation generated an internal error

View File

@ -5,5 +5,5 @@ xmlRelaxNGComputeInterleaves(interleave0)
xmlRelaxNGValidateAttribute(name): 0
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor9_6_2.xml validation generated an internal error

View File

@ -1,5 +1,4 @@
xmlRelaxNGValidateAttribute(name): 0
xmlRelaxNGValidateAttribute(email): -1
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1,2 +1,2 @@
Extra content for element addressBook
Extra content for element addressBook: card
./test/relaxng/tutor9_6_3.xml validation generated an internal error

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(name): 0
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4781
error detected at relaxng.c:4887
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -0,0 +1,22 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<ref name="anyElement"/>
</start>
<define name="anyElement">
<element>
<anyName/>
<zeroOrMore>
<choice>
<attribute>
<anyName/>
</attribute>
<text/>
<ref name="anyElement"/>
</choice>
</zeroOrMore>
</element>
</define>
</grammar>

View File

@ -0,0 +1,22 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<ref name="anyElement"/>
</start>
<define name="anyElement">
<element>
<anyName/>
<zeroOrMore>
<choice>
<attribute>
<anyName/>
</attribute>
<text/>
<ref name="anyElement"/>
</choice>
</zeroOrMore>
</element>
</define>
</grammar>

View File

@ -0,0 +1,7 @@
<addressBook>
<card>
<name>foo</name>
<email>bar</email>
<note>this guy is <em>annoying</em> !</note>
</card>
</addressBook>

4197
test/relaxng/tutor11_1_3.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -74,6 +74,7 @@ int main(int argc, char **argv) {
}
}
xmlLineNumbersDefault(1);
xmlSubstituteEntitiesDefault(1);
for (i = 1; i < argc ; i++) {
if (argv[i][0] != '-') {
if (schema == NULL) {