Commit d2298791 authored by Daniel Veillard's avatar Daniel Veillard

more testing on the Relax-NG front, cleaning up the regression tests

* check-relaxng-test-suite.py relaxng.c: more testing on the
  Relax-NG front, cleaning up the regression tests failures
  current state and I forgot support for "mixed":
  found 373 test schemas: 280 success 93 failures
  found 529 test instances: 401 success 68 failures
* tree.c include/libxml/tree.h xmlschemastypes.c: finished and
  moved the Name, NCName and QName validation routine in tree.c
* uri.c: fixed handling of URI ending up with #, i.e. having
  an empty fragment ID.
* result/relaxng/*: updated the results
Daniel
parent 9a237c9d
Fri Feb 14 17:49:26 CET 2003 Daniel Veillard <daniel@veillard.com>
* check-relaxng-test-suite.py relaxng.c: more testing on the
Relax-NG front, cleaning up the regression tests failures
current state and I forgot support for "mixed":
found 373 test schemas: 280 success 93 failures
found 529 test instances: 401 success 68 failures
* tree.c include/libxml/tree.h xmlschemastypes.c: finished and
moved the Name, NCName and QName validation routine in tree.c
* uri.c: fixed handling of URI ending up with #, i.e. having
an empty fragment ID.
* result/relaxng/*: updated the results
Thu Feb 13 16:49:24 CET 2003 Daniel Veillard <daniel@veillard.com>
* check-xinclude-test-suite.py: improved the script accordingly
......
......@@ -45,7 +45,6 @@ def resolver(URL, ID, ctxt):
log.write("resources: %s\n" % (resources))
return None
libxml2.setEntityLoader(resolver)
#
# handle a valid instance
......@@ -235,7 +234,6 @@ def handle_dir(node, dir):
for r in res:
handle_resource(r, name)
#
# handle a testCase element
#
......@@ -285,7 +283,17 @@ def handle_testCase(node):
#
# handle a testSuite element
#
def handle_testSuite(node):
def handle_testSuite(node, level = 0):
global nb_schemas_tests, nb_schemas_success, nb_schemas_failed
global nb_instances_tests, nb_instances_success, nb_instances_failed
if level >= 1:
old_schemas_tests = nb_schemas_tests
old_schemas_success = nb_schemas_success
old_schemas_failed = nb_schemas_failed
old_instances_tests = nb_instances_tests
old_instances_success = nb_instances_success
old_instances_failed = nb_instances_failed
docs = node.xpathEval('documentation')
authors = node.xpathEval('author')
if docs != []:
......@@ -306,13 +314,26 @@ def handle_testSuite(node):
for test in node.xpathEval('testCase'):
handle_testCase(test)
for test in node.xpathEval('testSuite'):
handle_testSuite(test)
handle_testSuite(test, level + 1)
if level >= 1 and sections != []:
if nb_schemas_tests != old_schemas_tests:
print "found %d test schemas: %d success %d failures" % (
nb_schemas_tests - old_schemas_tests,
nb_schemas_success - old_schemas_success,
nb_schemas_failed - old_schemas_failed)
if nb_instances_tests != old_instances_tests:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests - old_instances_tests,
nb_instances_success - old_instances_success,
nb_instances_failed - old_instances_failed)
#
# Parse the conf file
#
libxml2.substituteEntitiesDefault(1);
testsuite = libxml2.parseFile(CONF)
libxml2.setEntityLoader(resolver)
root = testsuite.getRootElement()
if root.name != 'testSuite':
print "%s doesn't start with a testSuite element, aborting" % (CONF)
......
......@@ -538,6 +538,9 @@ LIBXML_DLL_IMPORT extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></
LIBXML_DLL_IMPORT extern int xmlDefaultBufferSize; /* default buffer size */
#endif
int xmlValidateNCName (const xmlChar *value, int space);
int xmlValidateQName (const xmlChar *value, int space);
int xmlValidateName (const xmlChar *value, int space);
/*
* Handling Buffers.
*/
......
This diff is collapsed.
Unimplemented block at relaxng.c:4849
Unimplemented block at relaxng.c:5196
error detected at relaxng.c:5108
error detected at relaxng.c:5455
Expecting a namespace for element foo
error detected at relaxng.c:5461
error detected at relaxng.c:5812
extra data on the document
error detected at relaxng.c:5114
Expecting element foo has wrong namespace: expecting http://www.example.com
error detected at relaxng.c:5461
Expecting element foo has wrong namespace: expecting http://www.example.com
error detected at relaxng.c:5812
extra data on the document
error detected at relaxng.c:5114
Expecting element foo has wrong namespace: expecting http://www.example.com
error detected at relaxng.c:5461
Expecting element foo has wrong namespace: expecting http://www.example.com
error detected at relaxng.c:5812
extra data on the document
error detected at relaxng.c:5122
error detected at relaxng.c:5469
Expecting no namespace for element foo
error detected at relaxng.c:5461
error detected at relaxng.c:5812
extra data on the document
error detected at relaxng.c:5122
error detected at relaxng.c:5469
Expecting no namespace for element foo
error detected at relaxng.c:5461
error detected at relaxng.c:5812
extra data on the document
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
error detected at relaxng.c:5177
error detected at relaxng.c:5524
Invalid attribute foo for element card
error detected at relaxng.c:5177
error detected at relaxng.c:5524
Invalid attribute b for element card
Unimplemented block at relaxng.c:4849
Unimplemented block at relaxng.c:5196
error detected at relaxng.c:5099
error detected at relaxng.c:5446
Expecting element name, got email
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element card: email
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
error detected at relaxng.c:5461
error detected at relaxng.c:5812
extra data on the document
error detected at relaxng.c:5330
error detected at relaxng.c:5677
The data does not cover the full element bad
error detected at relaxng.c:5177
error detected at relaxng.c:5524
Invalid attribute preferredFormat for element card
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element preferredFormat: text
error detected at relaxng.c:5177
error detected at relaxng.c:5524
Invalid attribute preferredFormat for element card
error detected at relaxng.c:4217
error detected at relaxng.c:4564
Internal: failed to validate type float
error detected at relaxng.c:5384
error detected at relaxng.c:5735
internal error validating list
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element vector: text
error detected at relaxng.c:4406
error detected at relaxng.c:4753
Extra data in list: 5.6
error detected at relaxng.c:5384
error detected at relaxng.c:5735
internal error validating list
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element vector: text
error detected at relaxng.c:4381
error detected at relaxng.c:4728
Internal: no state
error detected at relaxng.c:5384
error detected at relaxng.c:5735
internal error validating list
error detected at relaxng.c:4406
error detected at relaxng.c:4753
Extra data in list: 5.6
error detected at relaxng.c:5384
error detected at relaxng.c:5735
internal error validating list
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element path: text
error detected at relaxng.c:4217
error detected at relaxng.c:4564
Internal: failed to validate type double
error detected at relaxng.c:5384
error detected at relaxng.c:5735
internal error validating list
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element path: text
Unimplemented block at relaxng.c:4849
Unimplemented block at relaxng.c:4849
error detected at relaxng.c:5164
Unimplemented block at relaxng.c:5196
Unimplemented block at relaxng.c:5196
error detected at relaxng.c:5511
Extra content for element head: meta
error detected at relaxng.c:5080
error detected at relaxng.c:5427
Expecting an element, got empty
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element head: meta
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element head: base
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
error detected at relaxng.c:5164
error detected at relaxng.c:5511
Extra content for element addressBook: card
......@@ -123,6 +123,246 @@ xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
return(NULL);
}
/************************************************************************
* *
* Check Name, NCName and QName strings *
* *
************************************************************************/
#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
/**
* xmlValidateNCName:
* @value: the value to check
* @space: allow spaces in front and end of the string
*
* Check that a value conforms to the lexical space of NCName
*
* Returns 0 if this validates, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlValidateNCName(const xmlChar *value, int space) {
const xmlChar *cur = value;
int c,l;
/*
* First quick algorithm for ASCII range
*/
if (space)
while (IS_BLANK(*cur)) cur++;
if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
(*cur == '_'))
cur++;
else
goto try_complex;
while (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
((*cur >= '0') && (*cur <= '9')) ||
(*cur == '_') || (*cur == '-') || (*cur == '.'))
cur++;
if (space)
while (IS_BLANK(*cur)) cur++;
if (*cur == 0)
return(0);
try_complex:
/*
* Second check for chars outside the ASCII range
*/
cur = value;
c = CUR_SCHAR(cur, l);
if (space) {
while (IS_BLANK(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if ((!xmlIsLetter(c)) && (c != '_'))
return(1);
cur += l;
c = CUR_SCHAR(cur, l);
while (xmlIsLetter(c) || xmlIsDigit(c) || (c == '.') ||
(c == '-') || (c == '_') || xmlIsCombining(c) ||
xmlIsExtender(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
if (space) {
while (IS_BLANK(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if (c != 0)
return(1);
return(0);
}
/**
* xmlValidateQName:
* @value: the value to check
* @space: allow spaces in front and end of the string
*
* Check that a value conforms to the lexical space of QName
*
* Returns 0 if this validates, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlValidateQName(const xmlChar *value, int space) {
const xmlChar *cur = value;
int c,l;
/*
* First quick algorithm for ASCII range
*/
if (space)
while (IS_BLANK(*cur)) cur++;
if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
(*cur == '_'))
cur++;
else
goto try_complex;
while (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
((*cur >= '0') && (*cur <= '9')) ||
(*cur == '_') || (*cur == '-') || (*cur == '.'))
cur++;
if (*cur == ':') {
cur++;
if (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
(*cur == '_'))
cur++;
else
goto try_complex;
while (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
((*cur >= '0') && (*cur <= '9')) ||
(*cur == '_') || (*cur == '-') || (*cur == '.'))
cur++;
}
if (space)
while (IS_BLANK(*cur)) cur++;
if (*cur == 0)
return(0);
try_complex:
/*
* Second check for chars outside the ASCII range
*/
cur = value;
c = CUR_SCHAR(cur, l);
if (space) {
while (IS_BLANK(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if ((!xmlIsLetter(c)) && (c != '_'))
return(1);
cur += l;
c = CUR_SCHAR(cur, l);
while (xmlIsLetter(c) || xmlIsDigit(c) || (c == '.') ||
(c == '-') || (c == '_') || xmlIsCombining(c) ||
xmlIsExtender(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
if (c == ':') {
cur += l;
c = CUR_SCHAR(cur, l);
if ((!xmlIsLetter(c)) && (c != '_'))
return(1);
cur += l;
c = CUR_SCHAR(cur, l);
while (xmlIsLetter(c) || xmlIsDigit(c) || (c == '.') ||
(c == '-') || (c == '_') || xmlIsCombining(c) ||
xmlIsExtender(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if (space) {
while (IS_BLANK(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if (c != 0)
return(1);
return(0);
}
/**
* xmlValidateName:
* @value: the value to check
* @space: allow spaces in front and end of the string
*
* Check that a value conforms to the lexical space of Name
*
* Returns 0 if this validates, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
int
xmlValidateName(const xmlChar *value, int space) {
const xmlChar *cur = value;
int c,l;
/*
* First quick algorithm for ASCII range
*/
if (space)
while (IS_BLANK(*cur)) cur++;
if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
(*cur == '_') || (*cur == ':'))
cur++;
else
goto try_complex;
while (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
((*cur >= '0') && (*cur <= '9')) ||
(*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':'))
cur++;
if (space)
while (IS_BLANK(*cur)) cur++;
if (*cur == 0)
return(0);
try_complex:
/*
* Second check for chars outside the ASCII range
*/
cur = value;
c = CUR_SCHAR(cur, l);
if (space) {
while (IS_BLANK(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if ((!xmlIsLetter(c)) && (c != '_') && (c != ':'))
return(1);
cur += l;
c = CUR_SCHAR(cur, l);
while (xmlIsLetter(c) || xmlIsDigit(c) || (c == '.') || (c == ':') ||
(c == '-') || (c == '_') || xmlIsCombining(c) || xmlIsExtender(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
if (space) {
while (IS_BLANK(c)) {
cur += l;
c = CUR_SCHAR(cur, l);
}
}
if (c != 0)
return(1);
return(0);
}
/************************************************************************
* *
* Allocation and deallocation of basic structures *
......
......@@ -803,7 +803,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
if (str == NULL)
return(NULL);
if (len <= 0) len = strlen(str);
if (len <= 0) return(NULL);
if (len < 0) return(NULL);
if (target == NULL) {
ret = (char *) xmlMalloc(len + 1);
......
......@@ -975,136 +975,6 @@ error:
}
/**
* xmlSchemaValidateNCName:
* @value: the value to check
*
* Check that a value conforms to the lexical space of NCName
*
* Returns 0 if this validates, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
static int
xmlSchemaValidateNCName(const xmlChar *value) {
const xmlChar *cur = value;
/*
* First quick algorithm for ASCII range
*/
while (IS_BLANK(*cur)) cur++;
if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
(*cur == '_'))
cur++;
else
goto try_complex;
while (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
((*cur >= '0') && (*cur <= '9')) ||
(*cur == '_') || (*cur == '-') || (*cur == '.'))
cur++;
while (IS_BLANK(*cur)) cur++;
if (*cur == 0)
return(0);
try_complex:
/*
* Second check for chars outside the ASCII range
*/
TODO
return(0);
}
/**
* xmlSchemaValidateQName:
* @value: the value to check
*
* Check that a value conforms to the lexical space of QName
*
* Returns 0 if this validates, a positive error code number otherwise
* and -1 in case of internal or API error.
*/
static int
xmlSchemaValidateQName(const xmlChar *value) {
const xmlChar *cur = value;
/*
* First quick algorithm for ASCII range
*/
while (IS_BLANK(*cur)) cur++;
if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
(*cur == '_'))
cur++;
else
goto try_complex;
while (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||
((*cur >= '0') && (*cur <= '9')) ||
(*cur == '_') || (*cur == '-') || (*cur == '.'))
cur++;
if (*cur == ':') {
cur++;
if (((*cur >= 'a') && (*cur <= 'z')) ||
((*cur >= 'A') && (*cur <= 'Z')) ||