mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-03-01 06:56:10 +00:00
stop generating wrong result file with * in name fixing the include bug
* Makefile.am: stop generating wrong result file with * in name * relaxng.c: fixing the include bug raised by Sebastian Rahtz * result/relaxng/demo* test/relaxng/demo: added the tests from Sebastian reproducing the problem. Daniel
This commit is contained in:
parent
5094cb2fbf
commit
5add868b2e
12
ChangeLog
12
ChangeLog
@ -1,8 +1,14 @@
|
||||
Mon Mar 10 14:10:47 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* Makefile.am: stop generating wrong result file with * in name
|
||||
* relaxng.c: fixing the include bug raised by Sebastian Rahtz
|
||||
* result/relaxng/demo* test/relaxng/demo: added the tests from
|
||||
Sebastian reproducing the problem.
|
||||
|
||||
Sun Mar 9 18:02:31 MST 2003 John Fleck <jfleck@inkstain.net>
|
||||
|
||||
* doc/xmllint.1
|
||||
regenerating man page from xmllint.xml to pick up Aleksey's
|
||||
change
|
||||
* doc/xmllint.1: regenerating man page from xmllint.xml to pick
|
||||
up Aleksey's change
|
||||
|
||||
Sun Mar 9 13:53:16 2003 Aleksey Sanin <aleksey@aleksey.com>
|
||||
|
||||
|
@ -665,6 +665,7 @@ Schemastests: testSchemas$(EXEEXT)
|
||||
name=`basename $$i | sed 's+_.*++'`; \
|
||||
sno=`basename $$i | sed 's+.*_\(.*\).xsd+\1+'`; \
|
||||
for j in $(srcdir)/test/schemas/"$$name"_*.xml ; do \
|
||||
if [ -f $$j ] ; then \
|
||||
xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \
|
||||
if [ ! -f $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" ]; \
|
||||
then \
|
||||
@ -683,7 +684,7 @@ Schemastests: testSchemas$(EXEEXT)
|
||||
err.$$name;\
|
||||
grep Unimplemented err.$$name; \
|
||||
rm res.$$name err.$$name ; \
|
||||
fi ; \
|
||||
fi ; fi ;\
|
||||
done; done)
|
||||
|
||||
Relaxtests: xmllint$(EXEEXT)
|
||||
|
122
relaxng.c
122
relaxng.c
@ -53,6 +53,7 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
|
||||
/* #define DEBUG_VALID 1 */
|
||||
/* #define DEBUG_INTERLEAVE 1 */
|
||||
/* #define DEBUG_LIST 1 */
|
||||
/* #define DEBUG_INCLUDE */
|
||||
|
||||
#define UNBOUNDED (1 << 30)
|
||||
#define TODO \
|
||||
@ -966,6 +967,72 @@ xmlRelaxNGIncludePop(xmlRelaxNGParserCtxtPtr ctxt)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlRelaxNGRemoveRedefine:
|
||||
* @ctxt: the parser context
|
||||
* @URL: the normalized URL
|
||||
* @target: the included target
|
||||
* @name: the define name to eliminate
|
||||
*
|
||||
* Applies the elimination algorithm of 4.7
|
||||
*
|
||||
* Returns 0 in case of error, 1 in case of success.
|
||||
*/
|
||||
static int
|
||||
xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
const xmlChar *URL ATTRIBUTE_UNUSED,
|
||||
xmlNodePtr target, const xmlChar *name) {
|
||||
int found = 0;
|
||||
xmlNodePtr tmp, tmp2;
|
||||
xmlChar *name2;
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Elimination of <include> %s from %s\n", name, URL);
|
||||
#endif
|
||||
tmp = target;
|
||||
while (tmp != NULL) {
|
||||
tmp2 = tmp->next;
|
||||
if ((name == NULL) && (IS_RELAXNG(tmp, "start"))) {
|
||||
found = 1;
|
||||
xmlUnlinkNode(tmp);
|
||||
xmlFreeNode(tmp);
|
||||
} else if ((name != NULL) && (IS_RELAXNG(tmp, "define"))) {
|
||||
name2 = xmlGetProp(tmp, BAD_CAST "name");
|
||||
xmlRelaxNGNormExtSpace(name2);
|
||||
if (name2 != NULL) {
|
||||
if (xmlStrEqual(name, name2)) {
|
||||
found = 1;
|
||||
xmlUnlinkNode(tmp);
|
||||
xmlFreeNode(tmp);
|
||||
}
|
||||
xmlFree(name2);
|
||||
}
|
||||
} else if (IS_RELAXNG(tmp, "include")) {
|
||||
xmlChar *href = NULL;
|
||||
xmlRelaxNGDocumentPtr inc = tmp->_private;
|
||||
|
||||
if ((inc != NULL) && (inc->doc != NULL) &&
|
||||
(inc->doc->children != NULL)) {
|
||||
|
||||
if (xmlStrEqual(inc->doc->children->name, BAD_CAST "grammar")) {
|
||||
#ifdef DEBUG_INCLUDE
|
||||
href = xmlGetProp(tmp, BAD_CAST "href");
|
||||
#endif
|
||||
if (xmlRelaxNGRemoveRedefine(ctxt, href,
|
||||
inc->doc->children->children, name) == 1) {
|
||||
found = 1;
|
||||
}
|
||||
if (href != NULL)
|
||||
xmlFree(href);
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp = tmp2;
|
||||
}
|
||||
return(found);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlRelaxNGLoadInclude:
|
||||
* @ctxt: the parser context
|
||||
@ -985,7 +1052,12 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
xmlRelaxNGIncludePtr ret = NULL;
|
||||
xmlDocPtr doc;
|
||||
int i;
|
||||
xmlNodePtr root, tmp, tmp2, cur;
|
||||
xmlNodePtr root, cur;
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlRelaxNGLoadInclude(%s)\n", URL);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* check against recursion in the stack
|
||||
@ -1013,6 +1085,11 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Parsed %s Okay\n", URL);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate the document structures and register it first.
|
||||
*/
|
||||
@ -1052,6 +1129,11 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
* Some preprocessing of the document content, this include recursing
|
||||
* in the include stack.
|
||||
*/
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"cleanup of %s\n", URL);
|
||||
#endif
|
||||
|
||||
doc = xmlRelaxNGCleanupDoc(ctxt, doc);
|
||||
if (doc == NULL) {
|
||||
ctxt->inc = NULL;
|
||||
@ -1063,6 +1145,10 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
*/
|
||||
xmlRelaxNGIncludePop(ctxt);
|
||||
|
||||
#ifdef DEBUG_INCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Checking of %s\n", URL);
|
||||
#endif
|
||||
/*
|
||||
* Check that the top element is a grammar
|
||||
*/
|
||||
@ -1091,16 +1177,7 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
if (IS_RELAXNG(cur, "start")) {
|
||||
int found = 0;
|
||||
|
||||
tmp = root->children;
|
||||
while (tmp != NULL) {
|
||||
tmp2 = tmp->next;
|
||||
if (IS_RELAXNG(tmp, "start")) {
|
||||
found = 1;
|
||||
xmlUnlinkNode(tmp);
|
||||
xmlFreeNode(tmp);
|
||||
}
|
||||
tmp = tmp2;
|
||||
}
|
||||
found = xmlRelaxNGRemoveRedefine(ctxt, URL, root->children, NULL);
|
||||
if (!found) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
@ -1109,7 +1186,7 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
ctxt->nbErrors++;
|
||||
}
|
||||
} else if (IS_RELAXNG(cur, "define")) {
|
||||
xmlChar *name, *name2;
|
||||
xmlChar *name;
|
||||
|
||||
name = xmlGetProp(cur, BAD_CAST "name");
|
||||
if (name == NULL) {
|
||||
@ -1119,26 +1196,11 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar *URL,
|
||||
URL);
|
||||
ctxt->nbErrors++;
|
||||
} else {
|
||||
int found = 0;
|
||||
int found;
|
||||
|
||||
xmlRelaxNGNormExtSpace(name);
|
||||
tmp = root->children;
|
||||
while (tmp != NULL) {
|
||||
tmp2 = tmp->next;
|
||||
if (IS_RELAXNG(tmp, "define")) {
|
||||
name2 = xmlGetProp(tmp, BAD_CAST "name");
|
||||
xmlRelaxNGNormExtSpace(name2);
|
||||
if (name2 != NULL) {
|
||||
if (xmlStrEqual(name, name2)) {
|
||||
found = 1;
|
||||
xmlUnlinkNode(tmp);
|
||||
xmlFreeNode(tmp);
|
||||
}
|
||||
xmlFree(name2);
|
||||
}
|
||||
}
|
||||
tmp = tmp2;
|
||||
}
|
||||
found = xmlRelaxNGRemoveRedefine(ctxt, URL,
|
||||
root->children, name);
|
||||
if (!found) {
|
||||
if (ctxt->error != NULL)
|
||||
ctxt->error(ctxt->userData,
|
||||
|
0
result/relaxng/demo2_err
Normal file
0
result/relaxng/demo2_err
Normal file
1
result/relaxng/demo2_valid
Normal file
1
result/relaxng/demo2_valid
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/demo2.rng validates
|
0
result/relaxng/demo3_err
Normal file
0
result/relaxng/demo3_err
Normal file
1
result/relaxng/demo3_valid
Normal file
1
result/relaxng/demo3_valid
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/demo3.rng validates
|
0
result/relaxng/demo_err
Normal file
0
result/relaxng/demo_err
Normal file
1
result/relaxng/demo_valid
Normal file
1
result/relaxng/demo_valid
Normal file
@ -0,0 +1 @@
|
||||
./test/relaxng/demo.rng validates
|
11
test/relaxng/demo.rng
Normal file
11
test/relaxng/demo.rng
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
|
||||
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||
|
||||
<include href="demo2.rng">
|
||||
<define name="TEI.prose"><ref name="INCLUDE"/></define>
|
||||
</include>
|
||||
</grammar>
|
||||
|
||||
|
||||
|
1
test/relaxng/demo.xml
Normal file
1
test/relaxng/demo.xml
Normal file
@ -0,0 +1 @@
|
||||
<TEI.2>hello</TEI.2>
|
23
test/relaxng/demo2.rng
Normal file
23
test/relaxng/demo2.rng
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:t="http://www.thaiopensource.com/ns/annotations" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||
|
||||
<start>
|
||||
<ref name="TEI.2"/>
|
||||
</start>
|
||||
<define name="IGNORE">
|
||||
<notAllowed/>
|
||||
</define>
|
||||
<define name="INCLUDE">
|
||||
<empty/>
|
||||
</define>
|
||||
|
||||
|
||||
<include href="demo3.rng"/>
|
||||
|
||||
<define name="TEI.2">
|
||||
<element name="TEI.2">
|
||||
<text/>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
</grammar>
|
8
test/relaxng/demo3.rng
Normal file
8
test/relaxng/demo3.rng
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:t="http://www.thaiopensource.com/ns/annotations" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||
|
||||
<define name="TEI.prose" combine="interleave">
|
||||
<ref name="IGNORE"/>
|
||||
</define>
|
||||
|
||||
</grammar>
|
Loading…
x
Reference in New Issue
Block a user