Commit 88c5891a authored by Daniel Veillard's avatar Daniel Veillard
Browse files

more work on Schemas updated the test list Daniel

* Makefile.am xmlschemas.c xmlschemastypes.c: more work on Schemas
* test/schemas result/schemas: updated the test list
Daniel
parent e19fc23b
Tue Apr 23 09:11:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
* Makefile.am xmlschemas.c xmlschemastypes.c: more work on Schemas
* test/schemas result/schemas: updated the test list
Mon Apr 22 17:59:14 CEST 2002 Daniel Veillard <daniel@veillard.com>
* TODO: updated a bit
......
......@@ -637,6 +637,7 @@ Schemastests: testSchemas$(EXEEXT)
res.$$name;\
diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err \
err.$$name;\
grep Unimplemented err.$$name; \
rm res.$$name err.$$name ; \
fi ; \
done; done)
......
......@@ -69,7 +69,8 @@ typedef enum {
XML_SCHEMA_CONTENT_MIXED,
XML_SCHEMA_CONTENT_SIMPLE,
XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
XML_SCHEMA_CONTENT_BASIC
XML_SCHEMA_CONTENT_BASIC,
XML_SCHEMA_CONTENT_ANY
} xmlSchemaContentType;
typedef struct _xmlSchemaVal xmlSchemaVal;
......@@ -206,6 +207,7 @@ struct _xmlSchemaElement {
xmlChar *value;
struct _xmlSchemaElement *refDecl;
xmlRegexpPtr contModel;
xmlSchemaContentType contentType;
};
/**
......
./test/schemas/item_0.xml validates
Type of sequence 3 : ./test/schemas/item_0.xsd:12 :elements
Type of restriction 5 : ./test/schemas/item_0.xsd:16 :empty
Type of simpletype4 : ./test/schemas/item_0.xsd:15 :simple
Type of SKU : ./test/schemas/item_0.xsd:5 :simple
Type of restriction 8 : ./test/schemas/item_0.xsd:30 :empty
Type of simpletype7 : ./test/schemas/item_0.xsd:29 :simple
Type of restriction 1 : ./test/schemas/item_0.xsd:6 :empty
Type of sequence 3 : ./test/schemas/item_0.xsd:12 :elements
Type of anontype2 : ./test/schemas/item_0.xsd:11 :elements
Building content model for Item
Content model of Item:
regexp: '(null)'
5 atoms:
00 atom: string once 'productName'
01 atom: string once 'quantity'
02 atom: string once 'USPrice'
03 atom: string once 'comment'
04 atom: string once 'shipDate'
6 states:
state: 0, 1 transitions:
trans: atom 0, to 1
state: 1, 1 transitions:
trans: atom 1, to 2
state: 2, 1 transitions:
trans: atom 2, to 3
state: FINAL 3, 3 transitions:
trans: atom 3, to 4
trans: removed
trans: atom 4, to 5
state: FINAL 4, 2 transitions:
trans: atom 4, to 5
trans: removed
state: FINAL 5, 0 transitions:
0 counters:
xmlSchemaValidateCallback: productName, productName, productName
xmlSchemaValidateCallback: quantity, quantity, quantity
xmlSchemaValidateCallback: USPrice, USPrice, USPrice
xmlSchemaValidateCallback: comment, comment, comment
Element Item content check succeeded
<Item partNum="926-AA" shipBy="air">
<productName>foo</productName>
<quantity>2</quantity>
<USPrice>1.0</USPrice>
<comment>No comment !</comment>
</Item>
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="comment" type="xsd:string"/>
<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Item" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity">
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
<!-- add weightKg and shipBy attributes -->
<xsd:attribute name="weightKg" type="xsd:decimal"/>
<xsd:attribute name="shipBy">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="air"/>
<xsd:enumeration value="land"/>
<xsd:enumeration value="any"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>
......@@ -642,6 +642,9 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output)
case XML_SCHEMA_CONTENT_SIMPLE:
fprintf(output, "simple ");
break;
case XML_SCHEMA_CONTENT_ANY:
fprintf(output, "any ");
break;
}
fprintf(output, "\n");
if ((type->minOccurs != 1) || (type->maxOccurs != 1)) {
......@@ -1597,7 +1600,7 @@ xmlSchemaParseAttribute(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
child = child->next;
}
if (IS_SCHEMA(child, "simpleType")) {
ret->base = xmlSchemaParseSimpleType(ctxt, schema, child);
ret->subtypes = xmlSchemaParseSimpleType(ctxt, schema, child);
child = child->next;
}
if (child != NULL) {
......@@ -3107,8 +3110,10 @@ xmlSchemaBuildContentModel(xmlSchemaElementPtr elem,
if (elem->contModel != NULL)
return;
if (elem->subtypes == NULL)
if (elem->subtypes == NULL) {
elem->contentType = XML_SCHEMA_CONTENT_ANY;
return;
}
if (elem->subtypes->type != XML_SCHEMA_TYPE_COMPLEX)
return;
if (elem->subtypes->contentType == XML_SCHEMA_CONTENT_BASIC)
......@@ -3823,12 +3828,28 @@ xmlSchemaValidateSimpleValue(xmlSchemaValidCtxtPtr ctxt,
if (ctxt->schema != NULL) {
if (ret == 0) {
facet = type->facets;
while (facet != NULL) {
tmp = xmlSchemaValidateFacet(base, facet, value,
ctxt->value);
if (tmp != 0)
ret = tmp;
facet = facet->next;
if ((type->type == XML_SCHEMA_TYPE_RESTRICTION) &&
(facet != NULL) &&
(facet->type == XML_SCHEMA_FACET_ENUMERATION)) {
while (facet != NULL) {
ret = 1;
tmp = xmlSchemaValidateFacet(base, facet, value,
ctxt->value);
if (tmp == 0) {
ret = 0;
break;
}
facet = facet->next;
}
} else {
while (facet != NULL) {
tmp = xmlSchemaValidateFacet(base, facet, value,
ctxt->value);
if (tmp != 0)
ret = tmp;
facet = facet->next;
}
}
}
}
......@@ -5016,6 +5037,8 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt) {
return;
if (ctxt->attr != NULL)
xmlFree(ctxt->attr);
if (ctxt->value != NULL)
xmlSchemaFreeValue(ctxt->value);
xmlFree(ctxt);
}
......
......@@ -499,6 +499,11 @@ xmlSchemaValidateFacet(xmlSchemaTypePtr base, xmlSchemaFacetPtr facet,
}
TODO /* error code */
return(1);
case XML_SCHEMA_FACET_ENUMERATION:
if ((facet->value != NULL) &&
(xmlStrEqual(facet->value, value)))
return(0);
return(1);
default:
TODO
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment