mirror of
https://github.com/GNOME/libxml2.git
synced 2025-03-31 19:10:28 +08:00
implemented the 4.20 and 4.21 simplification rules. updated the results
* relaxng.c: implemented the 4.20 and 4.21 simplification rules. * result/relaxng/*: updated the results Daniel
This commit is contained in:
parent
ce14fa545f
commit
1c745ade5d
@ -1,3 +1,8 @@
|
||||
Thu Feb 20 01:09:24 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* relaxng.c: implemented the 4.20 and 4.21 simplification rules.
|
||||
* result/relaxng/*: updated the results
|
||||
|
||||
Wed Feb 19 18:30:30 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* relaxng.c: more bugfixes
|
||||
|
177
relaxng.c
177
relaxng.c
@ -3776,6 +3776,182 @@ xmlRelaxNGCheckCycles(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlRelaxNGCheckRules:
|
||||
* @ctxt: a Relax-NG parser context
|
||||
* @nodes: grammar children nodes
|
||||
*
|
||||
* Check for simplification of empty and notAllowed
|
||||
*/
|
||||
static void
|
||||
xmlRelaxNGSimplify(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
xmlRelaxNGDefinePtr cur,
|
||||
xmlRelaxNGDefinePtr parent) {
|
||||
xmlRelaxNGDefinePtr prev = NULL;
|
||||
|
||||
while (cur != NULL) {
|
||||
if ((cur->type == XML_RELAXNG_REF) ||
|
||||
(cur->type == XML_RELAXNG_PARENTREF)) {
|
||||
if (cur->depth != -3) {
|
||||
cur->depth = -3;
|
||||
xmlRelaxNGSimplify(ctxt, cur->content, cur);
|
||||
}
|
||||
} else if (cur->type == XML_RELAXNG_NOT_ALLOWED) {
|
||||
if ((parent != NULL) &&
|
||||
((parent->type == XML_RELAXNG_ATTRIBUTE) ||
|
||||
(parent->type == XML_RELAXNG_LIST) ||
|
||||
(parent->type == XML_RELAXNG_GROUP) ||
|
||||
(parent->type == XML_RELAXNG_INTERLEAVE) ||
|
||||
(parent->type == XML_RELAXNG_ONEORMORE) ||
|
||||
(parent->type == XML_RELAXNG_ZEROORMORE))) {
|
||||
parent->type = XML_RELAXNG_NOT_ALLOWED;
|
||||
break;
|
||||
}
|
||||
if ((parent != NULL) &&
|
||||
(parent->type == XML_RELAXNG_CHOICE)) {
|
||||
if (prev == NULL) {
|
||||
if (parent != NULL)
|
||||
parent->content = cur->next;
|
||||
} else
|
||||
prev->next = cur->next;
|
||||
} else
|
||||
prev = cur;
|
||||
} else if (cur->type == XML_RELAXNG_EMPTY){
|
||||
if ((parent != NULL) &&
|
||||
((parent->type == XML_RELAXNG_ONEORMORE) ||
|
||||
(parent->type == XML_RELAXNG_ZEROORMORE))) {
|
||||
parent->type = XML_RELAXNG_EMPTY;
|
||||
break;
|
||||
}
|
||||
if ((parent != NULL) &&
|
||||
((parent->type == XML_RELAXNG_GROUP) ||
|
||||
(parent->type == XML_RELAXNG_INTERLEAVE))) {
|
||||
if (prev == NULL) {
|
||||
if (parent != NULL)
|
||||
parent->content = cur->next;
|
||||
} else
|
||||
prev->next = cur->next;
|
||||
} else
|
||||
prev = cur;
|
||||
} else {
|
||||
if (cur->content != NULL)
|
||||
xmlRelaxNGSimplify(ctxt, cur->content, cur);
|
||||
/*
|
||||
* This may result in a simplification
|
||||
*/
|
||||
if ((cur->type == XML_RELAXNG_GROUP) ||
|
||||
(cur->type == XML_RELAXNG_INTERLEAVE)) {
|
||||
if (cur->content == NULL)
|
||||
cur->type = XML_RELAXNG_EMPTY;
|
||||
else if (cur->content->next == NULL) {
|
||||
cur->content->next = cur->next;
|
||||
if (prev == NULL) {
|
||||
if (parent != NULL)
|
||||
parent->content = cur->content;
|
||||
} else {
|
||||
prev->next = cur->content;
|
||||
}
|
||||
cur = cur->content;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* the current node may have been transformed back
|
||||
*/
|
||||
if ((cur->type == XML_RELAXNG_EXCEPT) &&
|
||||
(cur->content != NULL) &&
|
||||
(cur->content->type == XML_RELAXNG_NOT_ALLOWED)) {
|
||||
if (prev == NULL) {
|
||||
if (parent != NULL)
|
||||
parent->content = cur->next;
|
||||
} else
|
||||
prev->next = cur->next;
|
||||
} else if (cur->type == XML_RELAXNG_NOT_ALLOWED) {
|
||||
if ((parent != NULL) &&
|
||||
((parent->type == XML_RELAXNG_ATTRIBUTE) ||
|
||||
(parent->type == XML_RELAXNG_LIST) ||
|
||||
(parent->type == XML_RELAXNG_GROUP) ||
|
||||
(parent->type == XML_RELAXNG_INTERLEAVE) ||
|
||||
(parent->type == XML_RELAXNG_ONEORMORE) ||
|
||||
(parent->type == XML_RELAXNG_ZEROORMORE))) {
|
||||
parent->type = XML_RELAXNG_NOT_ALLOWED;
|
||||
break;
|
||||
}
|
||||
if ((parent != NULL) &&
|
||||
(parent->type == XML_RELAXNG_CHOICE)) {
|
||||
if (prev == NULL) {
|
||||
if (parent != NULL)
|
||||
parent->content = cur->next;
|
||||
} else
|
||||
prev->next = cur->next;
|
||||
} else
|
||||
prev = cur;
|
||||
} else if (cur->type == XML_RELAXNG_EMPTY){
|
||||
if ((parent != NULL) &&
|
||||
((parent->type == XML_RELAXNG_ONEORMORE) ||
|
||||
(parent->type == XML_RELAXNG_ZEROORMORE))) {
|
||||
parent->type = XML_RELAXNG_EMPTY;
|
||||
break;
|
||||
}
|
||||
if ((parent != NULL) &&
|
||||
((parent->type == XML_RELAXNG_GROUP) ||
|
||||
(parent->type == XML_RELAXNG_INTERLEAVE) ||
|
||||
(parent->type == XML_RELAXNG_CHOICE))) {
|
||||
if (prev == NULL) {
|
||||
if (parent != NULL)
|
||||
parent->content = cur->next;
|
||||
} else
|
||||
prev->next = cur->next;
|
||||
} else
|
||||
prev = cur;
|
||||
} else {
|
||||
prev = cur;
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* xmlRelaxNGCheckRules:
|
||||
* @ctxt: a Relax-NG parser context
|
||||
* @nodes: grammar children nodes
|
||||
* @state: a state
|
||||
*
|
||||
* Check for rules in
|
||||
*
|
||||
* Returns 0 if check passed, and -1 in case of error
|
||||
*/
|
||||
static int
|
||||
xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
xmlRelaxNGDefinePtr cur, int depth) {
|
||||
int ret = 0;
|
||||
|
||||
while ((ret == 0) && (cur != NULL)) {
|
||||
if ((cur->type == XML_RELAXNG_REF) ||
|
||||
(cur->type == XML_RELAXNG_PARENTREF)) {
|
||||
if (cur->depth == -1) {
|
||||
cur->depth = depth;
|
||||
ret = xmlRelaxNGCheckCycles(ctxt, cur->content, depth);
|
||||
cur->depth = -2;
|
||||
} else if (depth == cur->depth) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
"Detected a cycle in %s references\n", cur->name);
|
||||
ctxt->nbErrors++;
|
||||
return(-1);
|
||||
}
|
||||
} else if (cur->type == XML_RELAXNG_ELEMENT) {
|
||||
ret = xmlRelaxNGCheckCycles(ctxt, cur->content, depth + 1);
|
||||
} else {
|
||||
ret = xmlRelaxNGCheckCycles(ctxt, cur->content, depth);
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlRelaxNGParseGrammar:
|
||||
* @ctxt: a Relax-NG parser context
|
||||
@ -3888,6 +4064,7 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
|
||||
ctxt->define = olddefine;
|
||||
if (schema->topgrammar->start != NULL) {
|
||||
xmlRelaxNGCheckCycles(ctxt, schema->topgrammar->start, 0);
|
||||
xmlRelaxNGSimplify(ctxt, schema->topgrammar->start, NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1 +1 @@
|
||||
Unimplemented block at relaxng.c:5697
|
||||
Unimplemented block at relaxng.c:5874
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5881
|
||||
error detected at relaxng.c:6058
|
||||
Expecting a namespace for element foo
|
||||
error detected at relaxng.c:6462
|
||||
error detected at relaxng.c:6639
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5886
|
||||
error detected at relaxng.c:6063
|
||||
Expecting element foo has wrong namespace: expecting http://www.example.com
|
||||
error detected at relaxng.c:6462
|
||||
error detected at relaxng.c:6639
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5886
|
||||
error detected at relaxng.c:6063
|
||||
Expecting element foo has wrong namespace: expecting http://www.example.com
|
||||
error detected at relaxng.c:6462
|
||||
error detected at relaxng.c:6639
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5898
|
||||
error detected at relaxng.c:6075
|
||||
Expecting no namespace for element foo
|
||||
error detected at relaxng.c:6462
|
||||
error detected at relaxng.c:6639
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5898
|
||||
error detected at relaxng.c:6075
|
||||
Expecting no namespace for element foo
|
||||
error detected at relaxng.c:6462
|
||||
error detected at relaxng.c:6639
|
||||
extra data on the document
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6105
|
||||
error detected at relaxng.c:6282
|
||||
Invalid attribute foo for element card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6105
|
||||
error detected at relaxng.c:6282
|
||||
Invalid attribute b for element card
|
||||
|
@ -1 +1 @@
|
||||
Unimplemented block at relaxng.c:5697
|
||||
Unimplemented block at relaxng.c:5874
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5873
|
||||
error detected at relaxng.c:6050
|
||||
Expecting element name, got email
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element card: email
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6462
|
||||
error detected at relaxng.c:6639
|
||||
extra data on the document
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:6256
|
||||
error detected at relaxng.c:6433
|
||||
Element bad has child elements
|
||||
error detected at relaxng.c:6039
|
||||
error detected at relaxng.c:6216
|
||||
Expecting an element got 3 type
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element bad: text
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6105
|
||||
error detected at relaxng.c:6282
|
||||
Invalid attribute preferredFormat for element card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element preferredFormat: text
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6105
|
||||
error detected at relaxng.c:6282
|
||||
Invalid attribute preferredFormat for element card
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:4984
|
||||
error detected at relaxng.c:5161
|
||||
Internal: failed to validate type float
|
||||
error detected at relaxng.c:6394
|
||||
error detected at relaxng.c:6571
|
||||
error validating list
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element vector: text
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:5224
|
||||
error detected at relaxng.c:5401
|
||||
Extra data in list: 5.6
|
||||
error detected at relaxng.c:6394
|
||||
error detected at relaxng.c:6571
|
||||
error validating list
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element vector: text
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:4984
|
||||
error detected at relaxng.c:5161
|
||||
Internal: failed to validate type double
|
||||
error detected at relaxng.c:6394
|
||||
error detected at relaxng.c:6571
|
||||
error validating list
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:5224
|
||||
error detected at relaxng.c:5401
|
||||
Extra data in list: 5.6
|
||||
error detected at relaxng.c:6394
|
||||
error detected at relaxng.c:6571
|
||||
error validating list
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element path: text
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:4984
|
||||
error detected at relaxng.c:5161
|
||||
Internal: failed to validate type double
|
||||
error detected at relaxng.c:6394
|
||||
error detected at relaxng.c:6571
|
||||
error validating list
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element path: text
|
||||
|
@ -1,4 +1,4 @@
|
||||
Unimplemented block at relaxng.c:5697
|
||||
Unimplemented block at relaxng.c:5697
|
||||
error detected at relaxng.c:6092
|
||||
Unimplemented block at relaxng.c:5874
|
||||
Unimplemented block at relaxng.c:5874
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element head: meta
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6033
|
||||
error detected at relaxng.c:6210
|
||||
Expecting an element, got empty
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element head: meta
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element head: base
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6092
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element addressBook: card
|
||||
|
Loading…
x
Reference in New Issue
Block a user