1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-25 23:21:26 +03:00

improved the script accordingly to the XInclude regression tests updates

* check-xinclude-test-suite.py: improved the script accordingly
  to the XInclude regression tests updates
* xpointer.c: Implemented XPointer element() Scheme W3C PR of 13
  November 2002
* result/XPath/xptr/chapterschildseq result/XPath/xptr/vidchildseq
  test/XPath/xptr/chapterschildseq test/XPath/xptr/vidchildseq:
  augmented the Xpointer testsuite for the element() scheme
Daniel
This commit is contained in:
Daniel Veillard 2003-02-13 15:52:58 +00:00
parent f4b4f98839
commit 9a237c9d26
7 changed files with 139 additions and 25 deletions

View File

@ -1,3 +1,13 @@
Thu Feb 13 16:49:24 CET 2003 Daniel Veillard <daniel@veillard.com>
* check-xinclude-test-suite.py: improved the script accordingly
to the XInclude regression tests updates
* xpointer.c: Implemented XPointer element() Scheme W3C PR of 13
November 2002
* result/XPath/xptr/chapterschildseq result/XPath/xptr/vidchildseq
test/XPath/xptr/chapterschildseq test/XPath/xptr/vidchildseq:
augmented the Xpointer testsuite for the element() scheme
Thu Feb 13 12:00:30 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c: added TODO for the DTD compatibility spec

View File

@ -9,11 +9,14 @@ import libxml2
#
# the testsuite description
#
CONF="xinclude-test-suite/testdescr.xml"
DIR="xinclude-test-suite"
CONF="testdescr.xml"
LOG="check-xinclude-test-suite.log"
log = open(LOG, "w")
os.chdir(DIR)
test_nr = 0
test_succeed = 0
test_failed = 0
@ -60,12 +63,16 @@ def runTest(test, basedir):
fatal_error = 0
uri = test.prop('href')
id = test.prop('id')
type = test.prop('type')
if uri == None:
print "Test without ID:", uri
return -1
if id == None:
print "Test without URI:", id
return -1
if type == None:
print "Test without URI:", id
return -1
if basedir != None:
URI = basedir + "/" + uri
else:
@ -74,28 +81,25 @@ def runTest(test, basedir):
print "Test %s missing: base %s uri %s" % (URI, basedir, uri)
return -1
output = test.xpathEval('string(output)')
expected = None
if output == 'No output file.':
output = None
if output == '':
output = None
if output != None:
if basedir != None:
output = basedir + "/" + output
if os.access(output, os.R_OK) == 0:
print "Result for %s missing: %s" % (id, output)
if type != 'error':
output = test.xpathEval('string(output)')
if output == 'No output file.':
output = None
else:
try:
f = open(output)
expected = f.read()
except:
print "Result for %s unreadable: %s" % (id, output)
description = test.xpathEval('string(description)')
if string.find(description, 'fatal error') != -1:
fatal_error = 1
if output == '':
output = None
if output != None:
if basedir != None:
output = basedir + "/" + output
if os.access(output, os.R_OK) == 0:
print "Result for %s missing: %s" % (id, output)
output = None
else:
try:
f = open(output)
expected = f.read()
except:
print "Result for %s unreadable: %s" % (id, output)
try:
# print "testing %s" % (URI)
@ -104,10 +108,15 @@ def runTest(test, basedir):
doc = None
if doc != None:
res = doc.xincludeProcess()
if expected != None and fatal_error != 0:
if res >= 0 and expected != None:
result = doc.serialize()
if result != expected:
print "Result for %s differs" % (id)
print '----'
print result
print '----'
print expected
print '----'
doc.freeDoc()
else:
@ -117,7 +126,7 @@ def runTest(test, basedir):
test_nr = test_nr + 1
if fatal_error == 0 and output != None:
if type == 'success':
if res > 0:
test_succeed = test_succeed + 1
elif res == 0:
@ -126,7 +135,7 @@ def runTest(test, basedir):
elif res < 0:
test_error = test_error + 1
print "Test %s: failed valid XInclude processing" % (id)
else:
elif type == 'error':
if res > 0:
test_error = test_error + 1
print "Test %s: failed to detect invalid XInclude processing" % (id)
@ -135,6 +144,11 @@ def runTest(test, basedir):
print "Test %s: Invalid but no substitution done" % (id)
elif res < 0:
test_succeed = test_succeed + 1
elif type == 'optional':
if res > 0:
test_succeed = test_succeed + 1
else:
print "Test %s: failed optional test" % (id)
# Log the ontext
if res != 1:

View File

@ -8,7 +8,46 @@ Set contains 1 nodes:
TEXT
content=linus.gif
========================
Expression: element(/1/2/3)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT image
ATTRIBUTE href
TEXT
content=linus.gif
========================
Expression: element(foo)element(/1/2/3)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT image
ATTRIBUTE href
TEXT
content=linus.gif
========================
Expression: element(/1/2/3)element(foo)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT image
ATTRIBUTE href
TEXT
content=linus.gif
========================
Expression: chapter1/3
Object is a Node Set :
Set contains 0 nodes:
========================
Expression: element(chapter1/3)
Object is empty (NULL)
========================
Expression: element(foo)element(chapter1/3)
Object is empty (NULL)
========================
Expression: element(chapter1/3)element(foo)
Object is empty (NULL)

View File

@ -8,6 +8,15 @@ Set contains 1 nodes:
TEXT
content=linus.gif
========================
Expression: element(/1/2/3)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT image
ATTRIBUTE href
TEXT
content=linus.gif
========================
Expression: chapter1/3
Object is a Node Set :
@ -16,3 +25,12 @@ Set contains 1 nodes:
ATTRIBUTE href
TEXT
content=linus.gif
========================
Expression: element(chapter1/3)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT image
ATTRIBUTE href
TEXT
content=linus.gif

View File

@ -1,2 +1,8 @@
/1/2/3
element(/1/2/3)
element(foo)element(/1/2/3)
element(/1/2/3)element(foo)
chapter1/3
element(chapter1/3)
element(foo)element(chapter1/3)
element(chapter1/3)element(foo)

View File

@ -1,2 +1,4 @@
/1/2/3
element(/1/2/3)
chapter1/3
element(chapter1/3)

View File

@ -1,9 +1,14 @@
/*
* xpointer.c : Code to handle XML Pointer
*
* World Wide Web Consortium Working Draft 03-March-1998
* Base implementation was made accordingly to
* W3C Candidate Recommendation 7 June 2000
* http://www.w3.org/TR/2000/CR-xptr-20000607
*
* Added support for the element() scheme described in:
* W3C Proposed Recommendation 13 November 2002
* http://www.w3.org/TR/2002/PR-xptr-element-20021113/
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
@ -815,6 +820,8 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
* *
************************************************************************/
static void xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name);
/*
* Macros for accessing the content. Those should be used only by the parser,
* and not exported.
@ -978,6 +985,24 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
CUR_PTR = buffer;
xmlXPathEvalExpr(ctxt);
CUR_PTR=left;
} else if (xmlStrEqual(name, (xmlChar *) "element")) {
const xmlChar *left = CUR_PTR;
xmlChar *name2;
CUR_PTR = buffer;
if (buffer[0] == '/') {
xmlXPathRoot(ctxt);
xmlXPtrEvalChildSeq(ctxt, NULL);
} else {
name2 = xmlXPathParseName(ctxt);
if (name2 == NULL) {
CUR_PTR = left;
xmlFree(buffer);
XP_ERROR(XPATH_EXPR_ERROR);
}
xmlXPtrEvalChildSeq(ctxt, name2);
}
CUR_PTR = left;
#ifdef XPTR_XMLNS_SCHEME
} else if (xmlStrEqual(name, (xmlChar *) "xmlns")) {
const xmlChar *left = CUR_PTR;