mirror of
https://github.com/GNOME/libxml2.git
synced 2025-02-11 18:09:31 +08:00
fixed some problems in the previous commit and finished implementing 4.16
* relaxng.c: fixed some problems in the previous commit and finished implementing 4.16 rules checking found 373 test schemas: 353 success 20 failures found 529 test instances: 519 success 6 failures * result/relaxng/*: updated the results Daniel
This commit is contained in:
parent
4c5cf7092e
commit
c5312d7c76
@ -1,3 +1,11 @@
|
||||
Fri Feb 21 18:12:19 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* relaxng.c: fixed some problems in the previous commit
|
||||
and finished implementing 4.16 rules checking
|
||||
found 373 test schemas: 353 success 20 failures
|
||||
found 529 test instances: 519 success 6 failures
|
||||
* result/relaxng/*: updated the results
|
||||
|
||||
Fri Feb 21 16:37:39 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* relaxng.c: implemented checks from section 7.2
|
||||
|
109
relaxng.c
109
relaxng.c
@ -175,6 +175,8 @@ typedef enum {
|
||||
#define XML_RELAXNG_IN_OOMGROUP (1 << 5)
|
||||
#define XML_RELAXNG_IN_OOMINTERLEAVE (1 << 6)
|
||||
#define XML_RELAXNG_IN_EXTERNALREF (1 << 7)
|
||||
#define XML_RELAXNG_IN_ANYEXCEPT (1 << 8)
|
||||
#define XML_RELAXNG_IN_NSEXCEPT (1 << 9)
|
||||
|
||||
struct _xmlRelaxNGParserCtxt {
|
||||
void *userData; /* user specific data block */
|
||||
@ -4046,8 +4048,6 @@ xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
ret = XML_RELAXNG_CONTENT_EMPTY;
|
||||
if ((cur->type == XML_RELAXNG_REF) ||
|
||||
(cur->type == XML_RELAXNG_PARENTREF)) {
|
||||
ret = XML_RELAXNG_CONTENT_COMPLEX;
|
||||
|
||||
if (flags & XML_RELAXNG_IN_LIST) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
@ -4066,12 +4066,16 @@ xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
"Found forbidden pattern data/except//ref\n");
|
||||
ctxt->nbErrors++;
|
||||
}
|
||||
if (cur->depth != -4) {
|
||||
if (cur->depth > -4) {
|
||||
cur->depth = -4;
|
||||
xmlRelaxNGCheckRules(ctxt, cur->content, flags, cur->type);
|
||||
}
|
||||
if (ret != XML_RELAXNG_CONTENT_ERROR)
|
||||
ret = xmlRelaxNGCheckRules(ctxt, cur->content,
|
||||
flags, cur->type);
|
||||
cur->depth = ret - 15 ;
|
||||
} else if (cur->depth == -4) {
|
||||
ret = XML_RELAXNG_CONTENT_COMPLEX;
|
||||
} else {
|
||||
ret = (xmlRelaxNGContentType) cur->depth + 15;
|
||||
}
|
||||
} else if (cur->type == XML_RELAXNG_ELEMENT) {
|
||||
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
|
||||
if (ctxt->error != NULL)
|
||||
@ -4700,34 +4704,17 @@ xmlRelaxNGCleanupAttributes(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlRelaxNGCleanupDoc:
|
||||
* xmlRelaxNGCleanupTree:
|
||||
* @ctxt: a Relax-NG parser context
|
||||
* @doc: an xmldocPtr document pointer
|
||||
* @root: an xmlNodePtr subtree
|
||||
*
|
||||
* Cleanup the document from unwanted nodes for parsing, resolve
|
||||
* Cleanup the subtree from unwanted nodes for parsing, resolve
|
||||
* Include and externalRef lookups.
|
||||
*
|
||||
* Returns the cleaned up document or NULL in case of error
|
||||
*/
|
||||
static xmlDocPtr
|
||||
xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt, xmlDocPtr doc) {
|
||||
xmlNodePtr root, cur, delete;
|
||||
static void
|
||||
xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root) {
|
||||
xmlNodePtr cur, delete;
|
||||
|
||||
/*
|
||||
* Extract the root
|
||||
*/
|
||||
root = xmlDocGetRootElement(doc);
|
||||
if (root == NULL) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData, "xmlRelaxNGParse: %s is empty\n",
|
||||
ctxt->URL);
|
||||
ctxt->nbErrors++;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all the blank text nodes
|
||||
*/
|
||||
delete = NULL;
|
||||
cur = root;
|
||||
while (cur != NULL) {
|
||||
@ -4968,6 +4955,43 @@ xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt, xmlDocPtr doc) {
|
||||
xmlFree(name);
|
||||
}
|
||||
}
|
||||
if (xmlStrEqual(cur->name, BAD_CAST "nsName")) {
|
||||
if (ctxt->flags & XML_RELAXNG_IN_NSEXCEPT) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
"Found nsName/except//nsName forbidden construct\n");
|
||||
ctxt->nbErrors++;
|
||||
}
|
||||
}
|
||||
} else if ((xmlStrEqual(cur->name, BAD_CAST "except")) &&
|
||||
(cur != root)) {
|
||||
int oldflags = ctxt->flags;
|
||||
|
||||
if ((cur->parent != NULL) &&
|
||||
(xmlStrEqual(cur->parent->name, BAD_CAST "anyName"))) {
|
||||
ctxt->flags |= XML_RELAXNG_IN_ANYEXCEPT;
|
||||
xmlRelaxNGCleanupTree(ctxt, cur);
|
||||
ctxt->flags = oldflags;
|
||||
goto skip_children;
|
||||
} else if ((cur->parent != NULL) &&
|
||||
(xmlStrEqual(cur->parent->name, BAD_CAST "nsName"))) {
|
||||
ctxt->flags |= XML_RELAXNG_IN_NSEXCEPT;
|
||||
xmlRelaxNGCleanupTree(ctxt, cur);
|
||||
ctxt->flags = oldflags;
|
||||
goto skip_children;
|
||||
}
|
||||
} else if (xmlStrEqual(cur->name, BAD_CAST "anyName")) {
|
||||
if (ctxt->flags & XML_RELAXNG_IN_ANYEXCEPT) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
"Found anyName/except//anyName forbidden construct\n");
|
||||
ctxt->nbErrors++;
|
||||
} else if (ctxt->flags & XML_RELAXNG_IN_NSEXCEPT) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
"Found nsName/except//anyName forbidden construct\n");
|
||||
ctxt->nbErrors++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Thisd is not an else since "include" is transformed
|
||||
@ -5058,7 +5082,34 @@ skip_children:
|
||||
xmlFreeNode(delete);
|
||||
delete = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlRelaxNGCleanupDoc:
|
||||
* @ctxt: a Relax-NG parser context
|
||||
* @doc: an xmldocPtr document pointer
|
||||
*
|
||||
* Cleanup the document from unwanted nodes for parsing, resolve
|
||||
* Include and externalRef lookups.
|
||||
*
|
||||
* Returns the cleaned up document or NULL in case of error
|
||||
*/
|
||||
static xmlDocPtr
|
||||
xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt, xmlDocPtr doc) {
|
||||
xmlNodePtr root;
|
||||
|
||||
/*
|
||||
* Extract the root
|
||||
*/
|
||||
root = xmlDocGetRootElement(doc);
|
||||
if (root == NULL) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData, "xmlRelaxNGParse: %s is empty\n",
|
||||
ctxt->URL);
|
||||
ctxt->nbErrors++;
|
||||
return (NULL);
|
||||
}
|
||||
xmlRelaxNGCleanupTree(ctxt, root);
|
||||
return(doc);
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Unimplemented block at relaxng.c:5874
|
||||
Unimplemented block at relaxng.c:6304
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6058
|
||||
error detected at relaxng.c:6488
|
||||
Expecting a namespace for element foo
|
||||
error detected at relaxng.c:6639
|
||||
error detected at relaxng.c:7070
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6063
|
||||
error detected at relaxng.c:6493
|
||||
Expecting element foo has wrong namespace: expecting http://www.example.com
|
||||
error detected at relaxng.c:6639
|
||||
error detected at relaxng.c:7070
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6063
|
||||
error detected at relaxng.c:6493
|
||||
Expecting element foo has wrong namespace: expecting http://www.example.com
|
||||
error detected at relaxng.c:6639
|
||||
error detected at relaxng.c:7070
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6075
|
||||
error detected at relaxng.c:6505
|
||||
Expecting no namespace for element foo
|
||||
error detected at relaxng.c:6639
|
||||
error detected at relaxng.c:7070
|
||||
extra data on the document
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6075
|
||||
error detected at relaxng.c:6505
|
||||
Expecting no namespace for element foo
|
||||
error detected at relaxng.c:6639
|
||||
error detected at relaxng.c:7070
|
||||
extra data on the document
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6282
|
||||
error detected at relaxng.c:6712
|
||||
Invalid attribute foo for element card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6282
|
||||
error detected at relaxng.c:6712
|
||||
Invalid attribute b for element card
|
||||
|
@ -1 +1 @@
|
||||
Unimplemented block at relaxng.c:5874
|
||||
Unimplemented block at relaxng.c:6304
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6050
|
||||
error detected at relaxng.c:6480
|
||||
Expecting element name, got email
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element card: email
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6639
|
||||
error detected at relaxng.c:7070
|
||||
extra data on the document
|
||||
|
@ -1 +0,0 @@
|
||||
./test/relaxng/tutor5_3_1.xml fails to validate
|
@ -1,6 +1 @@
|
||||
error detected at relaxng.c:6433
|
||||
Element bad has child elements
|
||||
error detected at relaxng.c:6216
|
||||
Expecting an element got 3 type
|
||||
error detected at relaxng.c:6269
|
||||
Extra content for element bad: text
|
||||
Element bad has a content type error
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6282
|
||||
error detected at relaxng.c:6712
|
||||
Invalid attribute preferredFormat for element card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element preferredFormat: text
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6282
|
||||
error detected at relaxng.c:6712
|
||||
Invalid attribute preferredFormat for element card
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:5161
|
||||
error detected at relaxng.c:5591
|
||||
Internal: failed to validate type float
|
||||
error detected at relaxng.c:6571
|
||||
error detected at relaxng.c:7002
|
||||
error validating list
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element vector: text
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:5401
|
||||
error detected at relaxng.c:5831
|
||||
Extra data in list: 5.6
|
||||
error detected at relaxng.c:6571
|
||||
error detected at relaxng.c:7002
|
||||
error validating list
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element vector: text
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:5161
|
||||
error detected at relaxng.c:5591
|
||||
Internal: failed to validate type double
|
||||
error detected at relaxng.c:6571
|
||||
error detected at relaxng.c:7002
|
||||
error validating list
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:5401
|
||||
error detected at relaxng.c:5831
|
||||
Extra data in list: 5.6
|
||||
error detected at relaxng.c:6571
|
||||
error detected at relaxng.c:7002
|
||||
error validating list
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element path: text
|
||||
|
@ -1,6 +1,6 @@
|
||||
error detected at relaxng.c:5161
|
||||
error detected at relaxng.c:5591
|
||||
Internal: failed to validate type double
|
||||
error detected at relaxng.c:6571
|
||||
error detected at relaxng.c:7002
|
||||
error validating list
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element path: text
|
||||
|
@ -1,4 +1,4 @@
|
||||
Unimplemented block at relaxng.c:5874
|
||||
Unimplemented block at relaxng.c:5874
|
||||
error detected at relaxng.c:6269
|
||||
Unimplemented block at relaxng.c:6304
|
||||
Unimplemented block at relaxng.c:6304
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element head: meta
|
||||
|
@ -1,4 +1,4 @@
|
||||
error detected at relaxng.c:6210
|
||||
error detected at relaxng.c:6640
|
||||
Expecting an element, got empty
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element head: meta
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element head: base
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
@ -1,2 +1,2 @@
|
||||
error detected at relaxng.c:6269
|
||||
error detected at relaxng.c:6699
|
||||
Extra content for element addressBook: card
|
||||
|
Loading…
Reference in New Issue
Block a user