mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
fixing the loop bug, fixing schematron text error rendering started
* schematron.c xmllint.c: fixing the loop bug, fixing schematron text error rendering * Makefile.am result/schematron/* test/schematron/zvon1*.sct: started integrating within "make tests" Daniel
This commit is contained in:
parent
22cce34629
commit
c740a17f45
@ -1,3 +1,10 @@
|
||||
Sun Jul 31 14:15:31 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* schematron.c xmllint.c: fixing the loop bug, fixing schematron
|
||||
text error rendering
|
||||
* Makefile.am result/schematron/* test/schematron/zvon1*.sct:
|
||||
started integrating within "make tests"
|
||||
|
||||
Sat Jul 30 17:26:58 EDT 2005 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* test/schematron/*: a few first tests from Zvon unfortunately
|
||||
|
31
Makefile.am
31
Makefile.am
@ -159,7 +159,7 @@ check-local: all tests
|
||||
|
||||
testall : tests SVGtests SAXtests
|
||||
|
||||
tests: XMLtests XMLenttests NStests IDtests Errtests APItests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @TEST_VALID@ URItests @TEST_PATTERN@ @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@ @PYTHON_TESTS@ @TEST_MODULES@
|
||||
tests: XMLtests XMLenttests NStests IDtests Errtests APItests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @TEST_VALID@ URItests @TEST_PATTERN@ @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_SCHEMATRON@ @TEST_THREADS@ Timingtests @TEST_VTIME@ @PYTHON_TESTS@ @TEST_MODULES@
|
||||
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; \
|
||||
$(MAKE) MAKEFLAGS+=--silent tests ; fi)
|
||||
@(cd doc/examples ; $(MAKE) MAKEFLAGS+=--silent tests)
|
||||
@ -1007,6 +1007,35 @@ Relaxtests: xmllint$(EXEEXT)
|
||||
fi ; fi ; \
|
||||
done; done)
|
||||
|
||||
Schematrontests: xmllint$(EXEEXT)
|
||||
@(echo > .memdump)
|
||||
@echo "## Schematron regression tests"
|
||||
-@(for i in $(srcdir)/test/schematron/*.sct ; do \
|
||||
name=`basename $$i | sed 's+\.sct++'`; \
|
||||
for j in $(srcdir)/test/schematron/"$$name"_*.xml ; do \
|
||||
if [ -f $$j ] ; then \
|
||||
xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \
|
||||
if [ ! -f $(srcdir)/result/schematron/"$$name"_"$$xno" ]; \
|
||||
then \
|
||||
echo New test file "$$name"_"$$xno" ; \
|
||||
$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --schematron $$i $$j \
|
||||
> $(srcdir)/result/schematron/"$$name"_"$$xno" \
|
||||
2> $(srcdir)/result/schematron/"$$name"_"$$xno".err; \
|
||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||
else \
|
||||
log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --schematron $$i $$j \
|
||||
> res.$$name 2> err.$$name;\
|
||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||
diff $(srcdir)/result/schematron/"$$name"_"$$xno" \
|
||||
res.$$name;\
|
||||
diff $(srcdir)/result/schematron/"$$name"_"$$xno".err \
|
||||
err.$$name | grep -v "error detected at";\
|
||||
grep Unimplemented err.$$name`; \
|
||||
if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo $$log ; fi ; \
|
||||
rm res.$$name err.$$name ; \
|
||||
fi ; fi ; \
|
||||
done; done)
|
||||
|
||||
RelaxNGPythonTests:
|
||||
@(if [ -x $(PYTHON) ] ; then \
|
||||
PYTHONPATH=$(top_builddir)/python:$(top_builddir)/python/.libs:$$PYTHONPATH ; \
|
||||
|
4
result/schematron/zvon1_0
Normal file
4
result/schematron/zvon1_0
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB/>
|
||||
</AAA>
|
8
result/schematron/zvon1_0.err
Normal file
8
result/schematron/zvon1_0.err
Normal file
@ -0,0 +1,8 @@
|
||||
Pattern: Print both cases
|
||||
/AAA line 1: BBB element is present.
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
Pattern: Print positive result only
|
||||
/AAA line 1: BBB element is present.
|
||||
Pattern: Print negative result only
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_0.xml fails to validate
|
4
result/schematron/zvon1_1
Normal file
4
result/schematron/zvon1_1
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<CCC/>
|
||||
</AAA>
|
8
result/schematron/zvon1_1.err
Normal file
8
result/schematron/zvon1_1.err
Normal file
@ -0,0 +1,8 @@
|
||||
Pattern: Print both cases
|
||||
/AAA line 1: BBB element is missing.
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
Pattern: Print positive result only
|
||||
Pattern: Print negative result only
|
||||
/AAA line 1: BBB element is missing.
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_1.xml fails to validate
|
89
schematron.c
89
schematron.c
@ -332,8 +332,16 @@ xmlSchematronAddTest(xmlSchematronParserCtxtPtr ctxt,
|
||||
ret->test = test;
|
||||
ret->comp = comp;
|
||||
ret->report = report;
|
||||
ret->next = rule->tests;
|
||||
rule->tests = ret;
|
||||
ret->next = NULL;
|
||||
if (rule->tests == NULL) {
|
||||
rule->tests = ret;
|
||||
} else {
|
||||
xmlSchematronTestPtr prev = rule->tests;
|
||||
|
||||
while (prev->next != NULL)
|
||||
prev = prev->next;
|
||||
prev->next = ret;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@ -406,10 +414,26 @@ xmlSchematronAddRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema,
|
||||
ret->context = context;
|
||||
ret->pattern = pattern;
|
||||
ret->report = report;
|
||||
ret->next = schema->rules;
|
||||
schema->rules = ret;
|
||||
ret->patnext = pat->rules;
|
||||
pat->rules = ret;
|
||||
ret->next = NULL;
|
||||
if (schema->rules == NULL) {
|
||||
schema->rules = ret;
|
||||
} else {
|
||||
xmlSchematronRulePtr prev = schema->rules;
|
||||
|
||||
while (prev->next != NULL)
|
||||
prev = prev->next;
|
||||
prev->next = ret;
|
||||
}
|
||||
ret->patnext = NULL;
|
||||
if (pat->rules == NULL) {
|
||||
pat->rules = ret;
|
||||
} else {
|
||||
xmlSchematronRulePtr prev = pat->rules;
|
||||
|
||||
while (prev->patnext != NULL)
|
||||
prev = prev->patnext;
|
||||
prev->patnext = ret;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@ -465,8 +489,16 @@ xmlSchematronAddPattern(xmlSchematronParserCtxtPtr ctxt,
|
||||
}
|
||||
memset(ret, 0, sizeof(xmlSchematronPattern));
|
||||
ret->name = name;
|
||||
ret->next = schema->patterns;
|
||||
schema->patterns = ret;
|
||||
ret->next = NULL;
|
||||
if (schema->patterns == NULL) {
|
||||
schema->patterns = ret;
|
||||
} else {
|
||||
xmlSchematronPatternPtr prev = schema->patterns;
|
||||
|
||||
while (prev->next != NULL)
|
||||
prev = prev->next;
|
||||
prev->next = ret;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@ -1197,7 +1229,7 @@ exit:
|
||||
static void
|
||||
xmlSchematronReportOutput(xmlSchematronValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
||||
xmlNodePtr cur ATTRIBUTE_UNUSED,
|
||||
const char *msg ATTRIBUTE_UNUSED) {
|
||||
const char *msg) {
|
||||
/* TODO */
|
||||
fprintf(stderr, "%s", msg);
|
||||
}
|
||||
@ -1220,8 +1252,7 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
|
||||
/* if quiet and not SVRL report only failures */
|
||||
if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) &&
|
||||
((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) &&
|
||||
(((test->type == XML_SCHEMATRON_REPORT) & (!success)) ||
|
||||
((test->type == XML_SCHEMATRON_ASSERT) & (success))))
|
||||
(test->type == XML_SCHEMATRON_REPORT))
|
||||
return;
|
||||
if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
|
||||
TODO
|
||||
@ -1253,6 +1284,33 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSchematronReportPattern:
|
||||
* @ctxt: the validation context
|
||||
* @pattern: the current pattern
|
||||
*
|
||||
* called from the validation engine when starting to check a pattern
|
||||
*/
|
||||
static void
|
||||
xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
|
||||
xmlSchematronPatternPtr pattern) {
|
||||
if ((ctxt == NULL) || (pattern == NULL))
|
||||
return;
|
||||
if (ctxt->flags & XML_SCHEMATRON_OUT_QUIET)
|
||||
return;
|
||||
if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
|
||||
TODO
|
||||
} else {
|
||||
char msg[1000];
|
||||
|
||||
if (pattern->name == NULL)
|
||||
return;
|
||||
snprintf(msg, 999, "Pattern: %s\n", (const char *) pattern->name);
|
||||
xmlSchematronReportOutput(ctxt, NULL, &msg[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Validation against a Schematrontron *
|
||||
@ -1274,9 +1332,7 @@ xmlSchematronNewValidCtxt(xmlSchematronPtr schema, int options)
|
||||
int i;
|
||||
xmlSchematronValidCtxtPtr ret;
|
||||
|
||||
ret =
|
||||
(xmlSchematronValidCtxtPtr)
|
||||
xmlMalloc(sizeof(xmlSchematronValidCtxt));
|
||||
ret = (xmlSchematronValidCtxtPtr) xmlMalloc(sizeof(xmlSchematronValidCtxt));
|
||||
if (ret == NULL) {
|
||||
xmlSchematronVErrMemory(NULL, "allocating validation context",
|
||||
NULL);
|
||||
@ -1432,7 +1488,6 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
|
||||
xmlSchematronPatternPtr pattern;
|
||||
xmlSchematronRulePtr rule;
|
||||
xmlSchematronTestPtr test;
|
||||
int matched;
|
||||
|
||||
if ((ctxt == NULL) || (ctxt->schema == NULL) ||
|
||||
(ctxt->schema->rules == NULL) || (instance == NULL))
|
||||
@ -1473,7 +1528,8 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
|
||||
pattern = ctxt->schema->patterns;
|
||||
|
||||
while (pattern != NULL) {
|
||||
matched = 0;
|
||||
xmlSchematronReportPattern(ctxt, pattern);
|
||||
|
||||
/*
|
||||
* TODO convert the pattern rule to a direct XPath and
|
||||
* compute directly instead of using the pattern matching
|
||||
@ -1496,6 +1552,7 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
|
||||
|
||||
cur = xmlSchematronNextNode(cur);
|
||||
}
|
||||
pattern = pattern->next;
|
||||
}
|
||||
}
|
||||
return(ctxt->nberrors);
|
||||
|
@ -2591,7 +2591,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||
if (wxschematron != NULL) {
|
||||
xmlSchematronValidCtxtPtr ctxt;
|
||||
int ret;
|
||||
int flag = XML_SCHEMATRON_OUT_TEXT;
|
||||
int flag;
|
||||
|
||||
if ((timing) && (!repeat)) {
|
||||
startTimer();
|
||||
@ -2599,6 +2599,10 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||
|
||||
if (debug)
|
||||
flag = XML_SCHEMATRON_OUT_XML;
|
||||
else
|
||||
flag = XML_SCHEMATRON_OUT_TEXT;
|
||||
if (noout)
|
||||
flag |= XML_SCHEMATRON_OUT_QUIET;
|
||||
ctxt = xmlSchematronNewValidCtxt(wxschematron, flag);
|
||||
#if 0
|
||||
xmlSchematronSetValidErrors(ctxt,
|
||||
|
Loading…
x
Reference in New Issue
Block a user