more work done in the train augmented/updated the regression tests Daniel

* relaxng: more work done in the train
* test/relaxng/* result/relaxng/*: augmented/updated the
  regression tests
Daniel
This commit is contained in:
Daniel Veillard 2003-01-30 12:17:05 +00:00
parent b711312c78
commit 154877e554
40 changed files with 243 additions and 72 deletions

View File

@ -1,3 +1,9 @@
Thu Jan 30 14:06:55 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng: more work done in the train
* test/relaxng/* result/relaxng/*: augmented/updated the
regression tests
Wed Jan 29 23:44:58 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c: debugging of externalRef

View File

@ -264,7 +264,7 @@ pnode=pxmlDoc-&gt;children-&gt;children;</pre>
<p><em>but it does not work. If I change it to</em></p>
<pre>pnode=pxmlDoc-&gt;children-&gt;children-&gt;next;</pre>
<p><em>then it works. Can someone explain it to me.</em></p>
<p></p>
<p>
<p>In XML all characters in the content of the document are significant
<strong>including blanks and formatting line breaks</strong>.</p>
<p>The extra nodes you are wondering about are just that, text nodes with
@ -367,7 +367,7 @@ xmlDtdPtr dtd = xmlParseDTD(NULL, filename_of_dtd); /* parse the DTD */
</li>
<li>etc ...</li>
</ol>
<p></p>
<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>

View File

@ -113,7 +113,7 @@ of the block interfaces are public. The main components are:</p>
</ul>
<p>Graphically this gives the following:</p>
<p><img src="libxml.gif" alt="a graphical view of the various"></p>
<p></p>
<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>

View File

@ -149,7 +149,7 @@ started.</p>
Catalogs</a> is far more flexible, more recent, uses an XML syntax and
should scale quite better. This is the default option of libxml.</li>
</ul>
<p></p>
<p>
<h3><a name="Simple">Using catalog</a></h3>
<p>In a normal environment libxml will by default check the presence of a
catalog in /etc/xml/catalog, and assuming it has been correctly populated,
@ -388,7 +388,7 @@ provided because this functionality may be useful for client tools.</p>
try to avoid troubles in multithreaded environments. The code is now thread
safe assuming that the libxml library has been compiled with threads
support.</p>
<p></p>
<p>
<h3><a name="Other">Other resources</a></h3>
<p>The XML Catalog specification is relatively recent so there isn't much
literature to point at:</p>

View File

@ -136,7 +136,7 @@ A:link, A:visited, A:active { text-decoration: underline }
Digital Signature</a> <a href="http://www.aleksey.com/xmlsec/">implementations for libxml2</a>
</li>
</ul>
<p></p>
<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>

View File

@ -95,7 +95,7 @@ A:link, A:visited, A:active { text-decoration: underline }
</table>
</td></tr></table></td>
<td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd">
<p></p>
<p>
<p>Libxml is the XML C library developed for the Gnome project. XML itself
is a metalanguage to design markup languages, i.e. text language where
semantic and structure are added to the content using extra &quot;markup&quot;

View File

@ -249,7 +249,7 @@ will just list one for now, others pointers welcome:</p>
<p>I suggest looking at the examples found under test/valid/dtd and any of
the large number of books available on XML. The dia example in test/valid
should be both simple and complete enough to allow you to build your own.</p>
<p></p>
<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>

View File

@ -218,7 +218,7 @@ of a number of things:</p>
validation, DOM, XPath or XPointer, but really need to work fixed memory
requirements, then the SAX interface should be used.</li>
</ul>
<p></p>
<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>

View File

@ -1248,7 +1248,7 @@ static xmlRelaxNGDefinePtr xmlRelaxNGParseAttribute(
static xmlRelaxNGDefinePtr xmlRelaxNGParseElement(
xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node);
static xmlRelaxNGDefinePtr xmlRelaxNGParsePatterns(
xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes);
xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes, int group);
static xmlRelaxNGDefinePtr xmlRelaxNGParsePattern(
xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node);
static xmlRelaxNGPtr xmlRelaxNGParseDocument(
@ -1494,6 +1494,8 @@ xmlRelaxNGCompareElemDefLists(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlRelaxNGDefinePtr *def2) {
xmlRelaxNGDefinePtr *basedef2 = def2;
if ((def1 == NULL) || (def2 == NULL))
return(1);
if ((*def1 == NULL) || (*def2 == NULL))
return(1);
while (*def1 != NULL) {
@ -1584,7 +1586,8 @@ xmlRelaxNGGetElements(xmlRelaxNGParserCtxtPtr ctxt,
continue;
}
}
if (cur == def) return(ret);
if (cur == def)
return(ret);
if (cur->next != NULL) {
cur = cur->next;
continue;
@ -1651,16 +1654,13 @@ xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def,
goto error;
cur = def->content;
while (cur != NULL) {
list = xmlRelaxNGGetElements(ctxt, cur);
if (list != NULL) {
groups[nbgroups] = (xmlRelaxNGInterleaveGroupPtr)
xmlMalloc(sizeof(xmlRelaxNGInterleaveGroup));
if (groups[nbgroups] == NULL)
goto error;
groups[nbgroups]->rule = cur;
groups[nbgroups]->defs = list;
nbgroups++;
}
groups[nbgroups] = (xmlRelaxNGInterleaveGroupPtr)
xmlMalloc(sizeof(xmlRelaxNGInterleaveGroup));
if (groups[nbgroups] == NULL)
goto error;
groups[nbgroups]->rule = cur;
groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur);
nbgroups++;
cur = cur->next;
}
list = NULL;
@ -1817,8 +1817,7 @@ xmlRelaxNGParseDefine(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
} else {
olddefine = ctxt->define;
ctxt->define = name;
def->content = xmlRelaxNGParsePatterns(ctxt,
node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0);
ctxt->define = olddefine;
}
if (ctxt->grammar->defs == NULL)
@ -1833,11 +1832,22 @@ xmlRelaxNGParseDefine(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
} else {
tmp = xmlHashAddEntry(ctxt->grammar->defs, name, def);
if (tmp < 0) {
TODO
/* store and implement 4.17 on combining */
ctxt->nbErrors++;
ret = -1;
xmlRelaxNGFreeDefine(def);
xmlRelaxNGDefinePtr prev;
prev = xmlHashLookup(ctxt->grammar->defs, name);
if (prev == NULL) {
if (ctxt->error != NULL)
ctxt->error(ctxt->userData,
"Internal error on define aggregation of %s\n",
name);
ctxt->nbErrors++;
ret = -1;
xmlRelaxNGFreeDefine(def);
} else {
while (prev->nextHash != NULL)
prev = prev->nextHash;
prev->nextHash = def;
}
}
}
}
@ -1882,31 +1892,31 @@ xmlRelaxNGParsePattern(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
if (def == NULL)
return(NULL);
def->type = XML_RELAXNG_ZEROORMORE;
def->content = xmlRelaxNGParsePatterns(ctxt, node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 1);
} else if (IS_RELAXNG(node, "oneOrMore")) {
def = xmlRelaxNGNewDefine(ctxt, node);
if (def == NULL)
return(NULL);
def->type = XML_RELAXNG_ONEORMORE;
def->content = xmlRelaxNGParsePatterns(ctxt, node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 1);
} else if (IS_RELAXNG(node, "optional")) {
def = xmlRelaxNGNewDefine(ctxt, node);
if (def == NULL)
return(NULL);
def->type = XML_RELAXNG_OPTIONAL;
def->content = xmlRelaxNGParsePatterns(ctxt, node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 1);
} else if (IS_RELAXNG(node, "choice")) {
def = xmlRelaxNGNewDefine(ctxt, node);
if (def == NULL)
return(NULL);
def->type = XML_RELAXNG_CHOICE;
def->content = xmlRelaxNGParsePatterns(ctxt, node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0);
} else if (IS_RELAXNG(node, "group")) {
def = xmlRelaxNGNewDefine(ctxt, node);
if (def == NULL)
return(NULL);
def->type = XML_RELAXNG_GROUP;
def->content = xmlRelaxNGParsePatterns(ctxt, node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0);
} else if (IS_RELAXNG(node, "ref")) {
def = xmlRelaxNGNewDefine(ctxt, node);
if (def == NULL)
@ -1978,7 +1988,7 @@ xmlRelaxNGParsePattern(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
if (def == NULL)
return(NULL);
def->type = XML_RELAXNG_LIST;
def->content = xmlRelaxNGParsePatterns(ctxt, node->children);
def->content = xmlRelaxNGParsePatterns(ctxt, node->children, 0);
} else if (IS_RELAXNG(node, "interleave")) {
def = xmlRelaxNGParseInterleave(ctxt, node);
} else if (IS_RELAXNG(node, "externalRef")) {
@ -2244,13 +2254,15 @@ xmlRelaxNGParseElement(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
* xmlRelaxNGParsePatterns:
* @ctxt: a Relax-NG parser context
* @nodes: list of nodes
* @group: use an implicit <group> for elements
*
* parse the content of a RelaxNG start node.
*
* Returns the definition pointer or NULL in case of error.
*/
static xmlRelaxNGDefinePtr
xmlRelaxNGParsePatterns(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes) {
xmlRelaxNGParsePatterns(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes,
int group) {
xmlRelaxNGDefinePtr def = NULL, last = NULL, cur, parent;
parent = ctxt->def;
@ -2260,7 +2272,8 @@ xmlRelaxNGParsePatterns(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes) {
if (def == NULL) {
def = last = cur;
} else {
if ((def->type == XML_RELAXNG_ELEMENT) && (def == last)) {
if ((group == 1) && (def->type == XML_RELAXNG_ELEMENT) &&
(def == last)) {
def = xmlRelaxNGNewDefine(ctxt, nodes);
def->type = XML_RELAXNG_GROUP;
def->content = last;
@ -2306,7 +2319,7 @@ xmlRelaxNGParseStart(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes) {
TODO
xmlElemDump(stdout, nodes->doc, nodes);
} else {
def = xmlRelaxNGParsePatterns(ctxt, nodes);
def = xmlRelaxNGParsePatterns(ctxt, nodes, 1);
ctxt->grammar->start = def;
}
nodes = nodes->next;
@ -2450,7 +2463,7 @@ xmlRelaxNGCheckCombine(xmlRelaxNGDefinePtr define,
name);
ctxt->nbErrors++;
}
} else if (xmlStrEqual(combine, BAD_CAST "choice")) {
} else if (xmlStrEqual(combine, BAD_CAST "interleave")) {
if (choiceOrInterleave == -1)
choiceOrInterleave = 0;
else if (choiceOrInterleave == 1) {
@ -2493,9 +2506,9 @@ xmlRelaxNGCheckCombine(xmlRelaxNGDefinePtr define,
if (cur == NULL)
return;
if (choiceOrInterleave == 0)
cur->type = XML_RELAXNG_CHOICE;
else
cur->type = XML_RELAXNG_INTERLEAVE;
else
cur->type = XML_RELAXNG_CHOICE;
tmp = define;
last = NULL;
while (tmp != NULL) {
@ -2523,6 +2536,26 @@ xmlRelaxNGCheckCombine(xmlRelaxNGDefinePtr define,
tmp = tmp->nextHash;
}
define->content = cur;
if (choiceOrInterleave == 0) {
if (ctxt->interleaves == NULL)
ctxt->interleaves = xmlHashCreate(10);
if (ctxt->interleaves == NULL) {
if (ctxt->error != NULL)
ctxt->error(ctxt->userData,
"Failed to create interleaves hash table\n");
ctxt->nbErrors++;
} else {
char tmpname[32];
snprintf(tmpname, 32, "interleave%d", ctxt->nbInterleaves++);
if (xmlHashAddEntry(ctxt->interleaves, BAD_CAST tmpname, cur) < 0) {
if (ctxt->error != NULL)
ctxt->error(ctxt->userData,
"Failed to add %s to hash table\n", tmpname);
ctxt->nbErrors++;
}
}
}
}
/**

View File

@ -1,3 +1,3 @@
error detected at relaxng.c:4260
error detected at relaxng.c:4308
error detected at relaxng.c:4293
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(name): -1
xmlRelaxNGValidateDefinition(): validated email : 0
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4308
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1 +1,2 @@
./test/relaxng/tutor4_1_1.xml validates
Extra content for element addressBook
./test/relaxng/tutor4_1_1.xml validation generated an internal error

View File

@ -1,7 +1,4 @@
xmlRelaxNGValidateDefinition(): validated name : 0
xmlRelaxNGValidateDefinition(): validated email : 0
xmlRelaxNGValidateDefinition(): validated card : 0
xmlRelaxNGValidateDefinition(): validated name : 0
xmlRelaxNGValidateDefinition(): validated email : 0
xmlRelaxNGValidateDefinition(): validated card : 0
xmlRelaxNGValidateDefinition(): validated addressBook : 0
xmlRelaxNGValidateDefinition(): validated card : -1
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated addressBook : -1

View File

@ -1,3 +1,3 @@
error detected at relaxng.c:4439
error detected at relaxng.c:4472
xmlRelaxNGValidateDefinition(): validated note : 0
xmlRelaxNGValidateDefinition(): validated bad : -1

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(preferredFormat): -1
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateAttribute(name): 0
error detected at relaxng.c:4316
error detected at relaxng.c:4349
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateDefinition(): validated name : 0
xmlRelaxNGValidateDefinition(): validated email : 0
error detected at relaxng.c:4308
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated preferredFormat : -1
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,5 +1,5 @@
xmlRelaxNGValidateAttribute(preferredFormat): -1
xmlRelaxNGValidateAttribute(email): 0
xmlRelaxNGValidateAttribute(name): 0
error detected at relaxng.c:4316
error detected at relaxng.c:4349
xmlRelaxNGValidateDefinition(): validated card : -1

View File

@ -1,5 +1,5 @@
Unimplemented block at xmlschemastypes.c:1132
error detected at relaxng.c:3518
error detected at relaxng.c:4493
error detected at relaxng.c:4308
error detected at relaxng.c:3551
error detected at relaxng.c:4526
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated vector : -1

View File

@ -1,6 +1,6 @@
Unimplemented block at xmlschemastypes.c:1132
Unimplemented block at xmlschemastypes.c:1132
error detected at relaxng.c:3706
error detected at relaxng.c:4493
error detected at relaxng.c:4308
error detected at relaxng.c:3739
error detected at relaxng.c:4526
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated vector : -1

View File

@ -1,3 +1,3 @@
error detected at relaxng.c:3681
error detected at relaxng.c:4493
error detected at relaxng.c:3714
error detected at relaxng.c:4526
xmlRelaxNGValidateDefinition(): validated vector : -1

View File

@ -1,7 +1,7 @@
Unimplemented block at xmlschemastypes.c:1135
Unimplemented block at xmlschemastypes.c:1135
Unimplemented block at xmlschemastypes.c:1135
error detected at relaxng.c:3706
error detected at relaxng.c:4493
error detected at relaxng.c:4308
error detected at relaxng.c:3739
error detected at relaxng.c:4526
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated path : -1

View File

@ -1,5 +1,5 @@
Unimplemented block at xmlschemastypes.c:1135
error detected at relaxng.c:3518
error detected at relaxng.c:4493
error detected at relaxng.c:4308
error detected at relaxng.c:3551
error detected at relaxng.c:4526
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated path : -1

View File

@ -3,5 +3,5 @@ xmlRelaxNGComputeInterleaves(interleave0)
6 groups
xmlRelaxNGValidateDefinition(): validated title : 0
xmlRelaxNGValidateDefinition(): validated title : 0
error detected at relaxng.c:4308
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated head : -1

View File

@ -1,6 +1,6 @@
xmlRelaxNGComputeInterleaves(interleave0)
6 child
6 groups
error detected at relaxng.c:4254
error detected at relaxng.c:4308
error detected at relaxng.c:4287
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated head : -1

View File

@ -4,5 +4,5 @@ xmlRelaxNGComputeInterleaves(interleave0)
xmlRelaxNGValidateDefinition(): validated title : 0
xmlRelaxNGValidateDefinition(): validated base : 0
xmlRelaxNGValidateDefinition(): validated base : 0
error detected at relaxng.c:4308
error detected at relaxng.c:4341
xmlRelaxNGValidateDefinition(): validated head : -1

View File

@ -0,0 +1 @@
./test/relaxng/tutor9_3_1.xml validates

View File

@ -0,0 +1,7 @@
xmlRelaxNGCheckCombine(): merging inline.class defines: 1
xmlRelaxNGComputeInterleaves(interleave0)
2 child
2 groups
xmlRelaxNGValidateDefinition(): validated em : 0
xmlRelaxNGValidateDefinition(): validated bold : 0
xmlRelaxNGValidateDefinition(): validated data : 0

View File

@ -0,0 +1 @@
./test/relaxng/tutor9_3_2.xml validates

View File

@ -0,0 +1,8 @@
xmlRelaxNGCheckCombine(): merging inline.class defines: 1
xmlRelaxNGComputeInterleaves(interleave0)
2 child
2 groups
xmlRelaxNGValidateDefinition(): validated code : 0
xmlRelaxNGValidateDefinition(): validated em : 0
xmlRelaxNGValidateDefinition(): validated italic : 0
xmlRelaxNGValidateDefinition(): validated data : 0

View File

@ -0,0 +1 @@
./test/relaxng/tutor9_4_1.xml validates

View File

@ -0,0 +1,6 @@
xmlRelaxNGComputeInterleaves(interleave0)
2 child
2 groups
xmlRelaxNGValidateDefinition(): validated em : 0
xmlRelaxNGValidateDefinition(): validated bold : 0
xmlRelaxNGValidateDefinition(): validated data : 0

View File

@ -0,0 +1 @@
./test/relaxng/tutor9_4_2.xml validates

View File

@ -0,0 +1,7 @@
xmlRelaxNGComputeInterleaves(interleave0)
2 child
2 groups
xmlRelaxNGValidateDefinition(): validated code : 0
xmlRelaxNGValidateDefinition(): validated em : 0
xmlRelaxNGValidateDefinition(): validated italic : 0
xmlRelaxNGValidateDefinition(): validated data : 0

37
test/relaxng/tutor9_3.rng Normal file
View File

@ -0,0 +1,37 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="data">
<interleave>
<text/>
<ref name="inline.class"/>
</interleave>
</element>
</start>
<define name="inline.class" combine="choice">
<element name="bold">
<ref name="inline"/>
</element>
</define>
<define name="inline.class" combine="choice">
<element name="italic">
<ref name="inline"/>
</element>
</define>
<define name="inline">
<zeroOrMore>
<choice>
<text/>
<element name="code">
<ref name="inline"/>
</element>
<element name="em">
<ref name="inline"/>
</element>
<!-- etc -->
</choice>
</zeroOrMore>
</define>
</grammar>

View File

@ -0,0 +1 @@
<data> a <bold> b <em> c </em> d </bold> e </data>

View File

@ -0,0 +1 @@
<data> a <italic> b <code> c </code> d <em>foo</em> </italic> e </data>

36
test/relaxng/tutor9_4.rng Normal file
View File

@ -0,0 +1,36 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="data">
<interleave>
<text/>
<ref name="inline.class"/>
</interleave>
</element>
</start>
<define name="inline.class">
<choice>
<element name="bold">
<ref name="inline"/>
</element>
<element name="italic">
<ref name="inline"/>
</element>
</choice>
</define>
<define name="inline">
<zeroOrMore>
<choice>
<text/>
<element name="code">
<ref name="inline"/>
</element>
<element name="em">
<ref name="inline"/>
</element>
<!-- etc -->
</choice>
</zeroOrMore>
</define>
</grammar>

View File

@ -0,0 +1 @@
<data> a <bold> b <em> c </em> d </bold> e </data>

View File

@ -0,0 +1 @@
<data> a <italic> b <code> c </code> d <em>foo</em> </italic> e </data>

25
test/relaxng/tutor9_5.rng Normal file
View File

@ -0,0 +1,25 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="addressBook">
<zeroOrMore>
<element name="card">
<ref name="card.attlist"/>
</element>
</zeroOrMore>
</element>
</start>
<define name="card.attlist" combine="interleave">
<attribute name="name">
<text/>
</attribute>
</define>
<define name="card.attlist" combine="interleave">
<attribute name="email">
<text/>
</attribute>
</define>
</grammar>