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

more Schemas work added more tests coming from the spec. Daniel

* Makefile.am xmlschemas.c: more Schemas work
* test/schemas/* result/schemas/*: added more tests coming
  from the spec.
Daniel
This commit is contained in:
Daniel Veillard 2002-04-18 14:41:51 +00:00
parent 6231e84559
commit decd64d645
31 changed files with 106 additions and 86 deletions

View File

@ -1,3 +1,9 @@
Thu Apr 18 16:40:42 CEST 2002 Daniel Veillard <daniel@veillard.com>
* Makefile.am xmlschemas.c: more Schemas work
* test/schemas/* result/schemas/*: added more tests coming
from the spec.
Thu Apr 18 13:52:52 CEST 2002 Daniel Veillard <daniel@veillard.com>
* HTMLtree.c: fixed & serialization bug introduced in 2.4.20

View File

@ -5,8 +5,8 @@ SUBDIRS = include . doc example python
INCLUDES = -I@srcdir@/include -I$(top_builddir)/include @THREAD_CFLAGS@ @Z_CFLAGS@
noinst_PROGRAMS=testSAX testHTML testXPath testURI testDocbook testThreads \
testC14N testAutomata testSchemas testRegexp
noinst_PROGRAMS=testSchemas testSAX testHTML testXPath testURI testDocbook \
testThreads testC14N testAutomata testRegexp
bin_PROGRAMS = xmllint xmlcatalog

View File

@ -18,7 +18,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check succeeded

View File

@ -18,7 +18,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: b, b, b
Element doc content check succeeded

View File

@ -18,7 +18,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -18,7 +18,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -18,6 +18,4 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
Element doc content check failed

View File

@ -18,7 +18,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -18,7 +18,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -19,7 +19,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check succeeded

View File

@ -19,7 +19,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: b, b, b
Element doc content check succeeded

View File

@ -19,7 +19,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -19,7 +19,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -19,6 +19,4 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
Element doc content check succeeded

View File

@ -19,7 +19,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -19,7 +19,5 @@ Content model of doc:
state: FINAL 3, 1 transitions:
trans: removed
0 counters:
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check failed

View File

@ -34,7 +34,5 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
Element doc content check succeeded

View File

@ -34,8 +34,6 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
xmlSchemaValidateCallback: b, b, b
Element doc content check succeeded
(nil) : Freed()

View File

@ -34,8 +34,6 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
xmlSchemaValidateCallback: b, b, b
Element doc content check succeeded

View File

@ -34,8 +34,6 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
xmlSchemaValidateCallback: a, a, a
Element doc content check succeeded

View File

@ -34,6 +34,4 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
Element doc content check failed

View File

@ -34,8 +34,6 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
xmlSchemaValidateCallback: b, b, b
xmlSchemaValidateCallback: a, a, a

View File

@ -34,8 +34,6 @@ Content model of doc:
trans: counted 0, atom 1, to 4
1 counters:
0: min 0 max 2
Building content model for a
Building content model for b
xmlSchemaValidateCallback: a, a, a
xmlSchemaValidateCallback: b, b, b
xmlSchemaValidateCallback: a, a, a

View File

@ -0,0 +1 @@
./test/schemas/length1_0.xml validates

View File

@ -0,0 +1,6 @@
Type of nonNegativeInteger :basic
Type of extension 2 : ./test/schemas/length1_0.xsd:5 :basic
Type of complexContent 1 : ./test/schemas/length1_0.xsd:4 :basic
Type of length1 : ./test/schemas/length1_0.xsd:3 :basic
Type of extension 2 : ./test/schemas/length1_0.xsd:5 :basic
Type of complexContent 1 : ./test/schemas/length1_0.xsd:4 :basic

View File

@ -14,9 +14,6 @@ Type of restriction 10 : ./test/schemas/po0_0.xsd:54 :empty
Type of sequence 1 : ./test/schemas/po0_0.xsd:12 :elements
Type of sequence 3 : ./test/schemas/po0_0.xsd:21 :elements
Type of USAddress : ./test/schemas/po0_0.xsd:20 :elements
Building content model for anonelem2
Building content model for street
Building content model for state
Building content model for shipTo
Content model of shipTo:
regexp: '(null)'
@ -39,8 +36,6 @@ Content model of shipTo:
trans: atom 4, to 5
state: FINAL 5, 0 transitions:
0 counters:
Building content model for comment
Building content model for name
Building content model for item
Content model of item:
regexp: '(null)'
@ -66,9 +61,6 @@ Content model of item:
trans: removed
state: FINAL 5, 0 transitions:
0 counters:
Building content model for productName
Building content model for anonelem9
Building content model for quantity
Building content model for purchaseOrder
Content model of purchaseOrder:
regexp: '(null)'
@ -112,8 +104,6 @@ Content model of billTo:
trans: atom 4, to 5
state: FINAL 5, 0 transitions:
0 counters:
Building content model for zip
Building content model for USPrice
Building content model for items
Content model of items:
regexp: '(null)'
@ -127,8 +117,6 @@ Content model of items:
trans: removed
trans: atom 0, to 1
0 counters:
Building content model for city
Building content model for shipDate
xmlSchemaValidateCallback: shipTo, shipTo, shipTo
xmlSchemaValidateCallback: name, name, name
xmlSchemaValidateCallback: street, street, street

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<addressee>
<forename>Albert</forename>
<forename>Arnold</forename>
<surname>Gore</surname>
<generation>Jr</generation>
</addressee>

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="personName">
<xs:sequence>
<xs:element name="title" minOccurs="0"/>
<xs:element name="forename" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="surname"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="extendedName">
<xs:complexContent>
<xs:extension base="personName">
<xs:sequence>
<xs:element name="generation" minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="addressee" type="extendedName"/>
</xs:schema>

View File

@ -0,0 +1 @@
<width unit="cm">25</width>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="length1">
<xs:simpleContent>
<xs:extension base="xs:nonNegativeInteger">
<xs:attribute name="unit" type="xs:NMTOKEN"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:element name="width" type="length1"/>
</xs:schema>

View File

@ -2676,7 +2676,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
child = child->next;
}
if (IS_SCHEMA(child, "simpleContent")) {
subtype = xmlSchemaParseSimpleContent(ctxt, schema, child);
type->subtypes = xmlSchemaParseSimpleContent(ctxt, schema, child);
child = child->next;
} else if (IS_SCHEMA(child, "complexContent")) {
type->subtypes = xmlSchemaParseComplexContent(ctxt, schema, child);
@ -3085,17 +3085,20 @@ xmlSchemaBuildContentModel(xmlSchemaElementPtr elem,
const xmlChar *name) {
xmlAutomataStatePtr start;
#ifdef DEBUG_CONTENT
xmlGenericError(xmlGenericErrorContext,
"Building content model for %s\n", name);
#endif
if (elem->contModel != NULL)
return;
if (elem->subtypes == NULL)
return;
if (elem->subtypes->type != XML_SCHEMA_TYPE_COMPLEX)
return;
if (elem->subtypes->contentType == XML_SCHEMA_CONTENT_BASIC)
return;
#ifdef DEBUG_CONTENT
xmlGenericError(xmlGenericErrorContext,
"Building content model for %s\n", name);
#endif
ctxt->am = xmlNewAutomata();
if (ctxt->am == NULL) {
xmlGenericError(xmlGenericErrorContext,
@ -3351,9 +3354,14 @@ xmlSchemaTypeFixup(xmlSchemaTypePtr typeDecl,
}
}
#ifdef DEBUG_TYPE
xmlGenericError(xmlGenericErrorContext,
"Type of %s : %s:%d :", name, typeDecl->node->doc->URL,
xmlGetLineNo(typeDecl->node));
if (typeDecl->node != NULL) {
xmlGenericError(xmlGenericErrorContext,
"Type of %s : %s:%d :", name, typeDecl->node->doc->URL,
xmlGetLineNo(typeDecl->node));
} else {
xmlGenericError(xmlGenericErrorContext,
"Type of %s :", name);
}
switch (typeDecl->contentType) {
case XML_SCHEMA_CONTENT_SIMPLE:
xmlGenericError(xmlGenericErrorContext,
@ -4465,6 +4473,21 @@ xmlSchemaValidateComplexType(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr node) {
child = xmlSchemaSkipIgnored(ctxt, type, child);
}
break;
case XML_SCHEMA_CONTENT_BASIC: {
if (type->subtypes != NULL) {
ctxt->type = type->subtypes;
xmlSchemaValidateComplexType(ctxt, node);
}
if (type->baseType != NULL) {
ctxt->type = type->baseType;
xmlSchemaValidateBasicType(ctxt, node);
}
if (type->attributes != NULL) {
xmlSchemaValidateAttributes(ctxt, node, type->attributes);
}
ctxt->type = type;
break;
}
default:
TODO
xmlGenericError(xmlGenericErrorContext,
@ -4813,29 +4836,29 @@ xmlSchemaValidateElement(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr elem) {
#endif
}
xmlSchemaValidateType(ctxt, elem, elemDecl, elemDecl->subtypes);
ret = xmlRegExecPushString(ctxt->regexp, NULL, NULL);
if (elemDecl->contModel != NULL) {
ret = xmlRegExecPushString(ctxt->regexp, NULL, NULL);
#ifdef DEBUG_AUTOMATA
xmlGenericError(xmlGenericErrorContext,
"====> %s : %d\n", elem->name, ret);
#endif
if (ret == 0) {
ctxt->err = XML_SCHEMAS_ERR_ELEMCONT;
if (ctxt->error != NULL)
ctxt->error(ctxt->userData, "Element %s content check failed\n",
elem->name);
} else if (ret < 0) {
ctxt->err = XML_SCHEMAS_ERR_ELEMCONT;
if (ctxt->error != NULL)
ctxt->error(ctxt->userData, "Element %s content check failed\n",
elem->name);
#ifdef DEBUG_CONTENT
} else {
xmlGenericError(xmlGenericErrorContext,
"Element %s content check succeeded\n", elem->name);
"====> %s : %d\n", elem->name, ret);
#endif
if (ret == 0) {
ctxt->err = XML_SCHEMAS_ERR_ELEMCONT;
if (ctxt->error != NULL)
ctxt->error(ctxt->userData, "Element %s content check failed\n",
elem->name);
} else if (ret < 0) {
ctxt->err = XML_SCHEMAS_ERR_ELEMCONT;
if (ctxt->error != NULL)
ctxt->error(ctxt->userData, "Element %s content check failed\n",
elem->name);
#ifdef DEBUG_CONTENT
} else {
xmlGenericError(xmlGenericErrorContext,
"Element %s content check succeeded\n", elem->name);
#endif
}
if (elemDecl->contModel != NULL) {
}
xmlRegFreeExecCtxt(ctxt->regexp);
}
/*
@ -4881,8 +4904,7 @@ xmlSchemaValidateDocument(xmlSchemaValidCtxtPtr ctxt, xmlDocPtr doc) {
if (ctxt->error != NULL)
ctxt->error(ctxt->userData, "Element %s not declared\n",
root->name);
}
if ((elemDecl->flags & XML_SCHEMAS_ELEM_TOPLEVEL) == 0) {
} else if ((elemDecl->flags & XML_SCHEMAS_ELEM_TOPLEVEL) == 0) {
ctxt->err = XML_SCHEMAS_ERR_NOTTOPLEVEL;
if (ctxt->error != NULL)
ctxt->error(ctxt->userData, "Root element %s not toplevel\n",