mirror of
https://github.com/GNOME/libxml2.git
synced 2025-03-25 19:01:31 +08:00
more work on Relax-NG augmented/updated the regression tests Daniel
* relaxng.c: more work on Relax-NG * test/relaxng/* result/relaxng/*: augmented/updated the regression tests Daniel
This commit is contained in:
parent
edc91928dc
commit
ea3f398c39
@ -1,3 +1,9 @@
|
||||
Sun Jan 26 20:38:43 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* relaxng.c: more work on Relax-NG
|
||||
* test/relaxng/* result/relaxng/*: augmented/updated the
|
||||
regression tests
|
||||
|
||||
Sun Jan 26 01:49:58 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* relaxng.c: more work on Relax-NG
|
||||
|
94
relaxng.c
94
relaxng.c
@ -653,6 +653,8 @@ xmlRelaxNGErrorContext(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGPtr schema,
|
||||
* Type library hooks *
|
||||
* *
|
||||
************************************************************************/
|
||||
static xmlChar *xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
const xmlChar *str);
|
||||
|
||||
/**
|
||||
* xmlRelaxNGSchemaTypeHave:
|
||||
@ -767,8 +769,31 @@ xmlRelaxNGDefaultTypeCompare(void *data ATTRIBUTE_UNUSED,
|
||||
const xmlChar *type ATTRIBUTE_UNUSED,
|
||||
const xmlChar *value1 ATTRIBUTE_UNUSED,
|
||||
const xmlChar *value2 ATTRIBUTE_UNUSED) {
|
||||
TODO
|
||||
return(1);
|
||||
int ret = -1;
|
||||
|
||||
if (xmlStrEqual(type, BAD_CAST "string")) {
|
||||
ret = xmlStrEqual(value1, value2);
|
||||
} else if (xmlStrEqual(type, BAD_CAST "token")) {
|
||||
if (!xmlStrEqual(value1, value2)) {
|
||||
xmlChar *nval, *nvalue;
|
||||
|
||||
/*
|
||||
* TODO: trivial optimizations are possible by
|
||||
* computing at compile-time
|
||||
*/
|
||||
nval = xmlRelaxNGNormalize(NULL, value1);
|
||||
nvalue = xmlRelaxNGNormalize(NULL, value2);
|
||||
|
||||
if ((nval == NULL) || (nvalue == NULL) ||
|
||||
(!xmlStrEqual(nval, nvalue)))
|
||||
ret = -1;
|
||||
if (nval != NULL)
|
||||
xmlFree(nval);
|
||||
if (nvalue != NULL)
|
||||
xmlFree(nvalue);
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int xmlRelaxNGTypeInitialized = 0;
|
||||
@ -2656,8 +2681,13 @@ xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar *str) {
|
||||
|
||||
ret = (xmlChar *) xmlMalloc((len + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
VALID_CTXT();
|
||||
VALID_ERROR("xmlRelaxNGNormalize: out of memory\n");
|
||||
if (ctxt != NULL) {
|
||||
VALID_CTXT();
|
||||
VALID_ERROR("xmlRelaxNGNormalize: out of memory\n");
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGNormalize: out of memory\n");
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
p = ret;
|
||||
@ -2756,7 +2786,24 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
case XML_RELAXNG_VALUE: {
|
||||
if (!xmlStrEqual(value, define->value)) {
|
||||
if (define->name != NULL) {
|
||||
TODO /* value validation w.r.t. the type */
|
||||
xmlRelaxNGTypeLibraryPtr lib;
|
||||
|
||||
lib = (xmlRelaxNGTypeLibraryPtr) define->data;
|
||||
if ((lib != NULL) && (lib->comp != NULL))
|
||||
ret = lib->comp(lib->data, define->name, value,
|
||||
define->value);
|
||||
else
|
||||
ret = -1;
|
||||
if (ret < 0) {
|
||||
VALID_CTXT();
|
||||
VALID_ERROR("Internal: failed to compare type %s\n",
|
||||
define->name);
|
||||
return(-1);
|
||||
} else if (ret == 1) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
} else {
|
||||
xmlChar *nval, *nvalue;
|
||||
|
||||
@ -2767,7 +2814,8 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
nval = xmlRelaxNGNormalize(ctxt, define->value);
|
||||
nvalue = xmlRelaxNGNormalize(ctxt, value);
|
||||
|
||||
if (!xmlStrEqual(nval, nvalue))
|
||||
if ((nval == NULL) || (nvalue == NULL) ||
|
||||
(!xmlStrEqual(nval, nvalue)))
|
||||
ret = -1;
|
||||
if (nval != NULL)
|
||||
xmlFree(nval);
|
||||
@ -3036,7 +3084,7 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
for (i = 0;i < state->nbAttrs;i++) {
|
||||
if (state->attrs[i] != NULL) {
|
||||
VALID_CTXT();
|
||||
VALID_ERROR("Extra attribute %s for element %s\n",
|
||||
VALID_ERROR("Invalid attribute %s for element %s\n",
|
||||
state->attrs[i]->name, node->name);
|
||||
ret = -1;
|
||||
}
|
||||
@ -3169,7 +3217,37 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlFree(content);
|
||||
break;
|
||||
}
|
||||
case XML_RELAXNG_VALUE:
|
||||
case XML_RELAXNG_VALUE: {
|
||||
xmlChar *content;
|
||||
xmlChar *oldvalue;
|
||||
|
||||
content = xmlNodeGetContent(node);
|
||||
oldvalue = ctxt->state->value;
|
||||
ctxt->state->value = content;
|
||||
ret = xmlRelaxNGValidateValue(ctxt, define);
|
||||
ctxt->state->value = oldvalue;
|
||||
if (ret == -1) {
|
||||
VALID_CTXT();
|
||||
VALID_ERROR("internal error validating %s\n", define->name);
|
||||
} else if (ret == 0) {
|
||||
ctxt->state->seq = node->next;
|
||||
}
|
||||
/*
|
||||
* TODO cover the problems with
|
||||
* <p>12<!-- comment -->34</p>
|
||||
* TODO detect full element coverage at compilation time.
|
||||
*/
|
||||
if ((node != NULL) && (node->next != NULL)) {
|
||||
VALID_CTXT();
|
||||
VALID_ERROR("The data does not cover the full element %s\n",
|
||||
node->parent->name);
|
||||
ret = -1;
|
||||
}
|
||||
if (content != NULL)
|
||||
xmlFree(content);
|
||||
break;
|
||||
}
|
||||
|
||||
TODO
|
||||
break;
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
error detected at relaxng.c:2982
|
||||
error detected at relaxng.c:3030
|
||||
error detected at relaxng.c:3078
|
||||
xmlRelaxNGValidateDefinition(): validated card : -1
|
||||
|
@ -1,5 +1,5 @@
|
||||
xmlRelaxNGValidateAttribute(name): -1
|
||||
xmlRelaxNGValidateDefinition(): validated email : 0
|
||||
xmlRelaxNGValidateDefinition(): validated card : -1
|
||||
error detected at relaxng.c:3030
|
||||
error detected at relaxng.c:3078
|
||||
xmlRelaxNGValidateDefinition(): validated addressBook : -1
|
||||
|
@ -1,3 +1,3 @@
|
||||
Unimplemented block at relaxng.c:670
|
||||
Unimplemented block at relaxng.c:689
|
||||
Unimplemented block at relaxng.c:672
|
||||
Unimplemented block at relaxng.c:691
|
||||
xmlRelaxNGValidateDefinition(): validated number : 0
|
||||
|
@ -1,7 +1,7 @@
|
||||
Unimplemented block at relaxng.c:670
|
||||
Unimplemented block at relaxng.c:670
|
||||
Unimplemented block at relaxng.c:689
|
||||
Unimplemented block at relaxng.c:672
|
||||
Unimplemented block at relaxng.c:672
|
||||
Unimplemented block at relaxng.c:691
|
||||
xmlRelaxNGValidateDefinition(): validated x : 0
|
||||
Unimplemented block at relaxng.c:689
|
||||
Unimplemented block at relaxng.c:691
|
||||
xmlRelaxNGValidateDefinition(): validated y : 0
|
||||
xmlRelaxNGValidateDefinition(): validated point : 0
|
||||
|
@ -1,3 +1,3 @@
|
||||
error detected at relaxng.c:3163
|
||||
error detected at relaxng.c:3211
|
||||
xmlRelaxNGValidateDefinition(): validated note : 0
|
||||
xmlRelaxNGValidateDefinition(): validated bad : -1
|
||||
|
@ -1,2 +1,2 @@
|
||||
Extra attribute preferredFormat for element card
|
||||
Invalid attribute preferredFormat for element card
|
||||
./test/relaxng/tutor6_1_3.xml validation generated an internal error
|
||||
|
@ -1,5 +1,5 @@
|
||||
xmlRelaxNGValidateAttribute(preferredFormat): -1
|
||||
xmlRelaxNGValidateAttribute(email): 0
|
||||
xmlRelaxNGValidateAttribute(name): 0
|
||||
error detected at relaxng.c:3038
|
||||
error detected at relaxng.c:3086
|
||||
xmlRelaxNGValidateDefinition(): validated card : -1
|
||||
|
1
result/relaxng/tutor6_1_4
Normal file
1
result/relaxng/tutor6_1_4
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/tutor6_1_4.xml validates
|
4
result/relaxng/tutor6_1_4.err
Normal file
4
result/relaxng/tutor6_1_4.err
Normal file
@ -0,0 +1,4 @@
|
||||
xmlRelaxNGValidateAttribute(preferredFormat): 0
|
||||
xmlRelaxNGValidateAttribute(email): 0
|
||||
xmlRelaxNGValidateAttribute(name): 0
|
||||
xmlRelaxNGValidateDefinition(): validated card : 0
|
1
result/relaxng/tutor6_1_5
Normal file
1
result/relaxng/tutor6_1_5
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/tutor6_1_5.xml validates
|
4
result/relaxng/tutor6_1_5.err
Normal file
4
result/relaxng/tutor6_1_5.err
Normal file
@ -0,0 +1,4 @@
|
||||
xmlRelaxNGValidateAttribute(preferredFormat): 0
|
||||
xmlRelaxNGValidateAttribute(email): 0
|
||||
xmlRelaxNGValidateAttribute(name): 0
|
||||
xmlRelaxNGValidateDefinition(): validated card : 0
|
1
result/relaxng/tutor6_2_1
Normal file
1
result/relaxng/tutor6_2_1
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/tutor6_2_1.xml validates
|
4
result/relaxng/tutor6_2_1.err
Normal file
4
result/relaxng/tutor6_2_1.err
Normal file
@ -0,0 +1,4 @@
|
||||
xmlRelaxNGValidateDefinition(): validated name : 0
|
||||
xmlRelaxNGValidateDefinition(): validated email : 0
|
||||
xmlRelaxNGValidateDefinition(): validated preferredFormat : 0
|
||||
xmlRelaxNGValidateDefinition(): validated card : 0
|
1
result/relaxng/tutor6_2_2
Normal file
1
result/relaxng/tutor6_2_2
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/tutor6_2_2.xml validates
|
4
result/relaxng/tutor6_2_2.err
Normal file
4
result/relaxng/tutor6_2_2.err
Normal file
@ -0,0 +1,4 @@
|
||||
xmlRelaxNGValidateDefinition(): validated name : 0
|
||||
xmlRelaxNGValidateDefinition(): validated email : 0
|
||||
xmlRelaxNGValidateDefinition(): validated preferredFormat : 0
|
||||
xmlRelaxNGValidateDefinition(): validated card : 0
|
1
result/relaxng/tutor6_2_3
Normal file
1
result/relaxng/tutor6_2_3
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/tutor6_2_3.xml validates
|
4
result/relaxng/tutor6_2_3.err
Normal file
4
result/relaxng/tutor6_2_3.err
Normal file
@ -0,0 +1,4 @@
|
||||
xmlRelaxNGValidateDefinition(): validated name : 0
|
||||
xmlRelaxNGValidateDefinition(): validated email : 0
|
||||
xmlRelaxNGValidateDefinition(): validated preferredFormat : 0
|
||||
xmlRelaxNGValidateDefinition(): validated card : 0
|
2
result/relaxng/tutor6_2_4
Normal file
2
result/relaxng/tutor6_2_4
Normal file
@ -0,0 +1,2 @@
|
||||
Extra content for element preferredFormat
|
||||
./test/relaxng/tutor6_2_4.xml validation generated an internal error
|
5
result/relaxng/tutor6_2_4.err
Normal file
5
result/relaxng/tutor6_2_4.err
Normal file
@ -0,0 +1,5 @@
|
||||
xmlRelaxNGValidateDefinition(): validated name : 0
|
||||
xmlRelaxNGValidateDefinition(): validated email : 0
|
||||
error detected at relaxng.c:3078
|
||||
xmlRelaxNGValidateDefinition(): validated preferredFormat : -1
|
||||
xmlRelaxNGValidateDefinition(): validated card : -1
|
2
result/relaxng/tutor6_3_1
Normal file
2
result/relaxng/tutor6_3_1
Normal file
@ -0,0 +1,2 @@
|
||||
Invalid attribute preferredFormat for element card
|
||||
./test/relaxng/tutor6_3_1.xml validation generated an internal error
|
5
result/relaxng/tutor6_3_1.err
Normal file
5
result/relaxng/tutor6_3_1.err
Normal file
@ -0,0 +1,5 @@
|
||||
xmlRelaxNGValidateAttribute(preferredFormat): -1
|
||||
xmlRelaxNGValidateAttribute(email): 0
|
||||
xmlRelaxNGValidateAttribute(name): 0
|
||||
error detected at relaxng.c:3086
|
||||
xmlRelaxNGValidateDefinition(): validated card : -1
|
1
test/relaxng/tutor6_1_4.xml
Normal file
1
test/relaxng/tutor6_1_4.xml
Normal file
@ -0,0 +1 @@
|
||||
<card name="John Smith" email="js@example.com" preferredFormat=" html "/>
|
2
test/relaxng/tutor6_1_5.xml
Normal file
2
test/relaxng/tutor6_1_5.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<card name="John Smith" email="js@example.com" preferredFormat="html"/>
|
||||
|
5
test/relaxng/tutor6_2_1.xml
Normal file
5
test/relaxng/tutor6_2_1.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<card>
|
||||
<name>John Smith</name>
|
||||
<email>js@example.com</email>
|
||||
<preferredFormat>text</preferredFormat>
|
||||
</card>
|
5
test/relaxng/tutor6_2_2.xml
Normal file
5
test/relaxng/tutor6_2_2.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<card>
|
||||
<name>John Smith</name>
|
||||
<email>js@example.com</email>
|
||||
<preferredFormat>html</preferredFormat>
|
||||
</card>
|
5
test/relaxng/tutor6_2_3.xml
Normal file
5
test/relaxng/tutor6_2_3.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<card>
|
||||
<name>John Smith</name>
|
||||
<email>js@example.com</email>
|
||||
<preferredFormat> html </preferredFormat>
|
||||
</card>
|
5
test/relaxng/tutor6_2_4.xml
Normal file
5
test/relaxng/tutor6_2_4.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<card>
|
||||
<name>John Smith</name>
|
||||
<email>js@example.com</email>
|
||||
<preferredFormat>error</preferredFormat>
|
||||
</card>
|
1
test/relaxng/tutor6_3_1.xml
Normal file
1
test/relaxng/tutor6_3_1.xml
Normal file
@ -0,0 +1 @@
|
||||
<card name="John Smith" email="js@example.com" preferredFormat=" html "/>
|
Loading…
x
Reference in New Issue
Block a user