mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-02 04:58:18 +03:00
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
This commit is contained in:
parent
e19fc23b64
commit
88c5891a25
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
Mon Apr 22 17:59:14 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* TODO: updated a bit
|
* TODO: updated a bit
|
||||||
|
@ -637,6 +637,7 @@ Schemastests: testSchemas$(EXEEXT)
|
|||||||
res.$$name;\
|
res.$$name;\
|
||||||
diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err \
|
diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err \
|
||||||
err.$$name;\
|
err.$$name;\
|
||||||
|
grep Unimplemented err.$$name; \
|
||||||
rm res.$$name err.$$name ; \
|
rm res.$$name err.$$name ; \
|
||||||
fi ; \
|
fi ; \
|
||||||
done; done)
|
done; done)
|
||||||
|
@ -69,7 +69,8 @@ typedef enum {
|
|||||||
XML_SCHEMA_CONTENT_MIXED,
|
XML_SCHEMA_CONTENT_MIXED,
|
||||||
XML_SCHEMA_CONTENT_SIMPLE,
|
XML_SCHEMA_CONTENT_SIMPLE,
|
||||||
XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
|
XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
|
||||||
XML_SCHEMA_CONTENT_BASIC
|
XML_SCHEMA_CONTENT_BASIC,
|
||||||
|
XML_SCHEMA_CONTENT_ANY
|
||||||
} xmlSchemaContentType;
|
} xmlSchemaContentType;
|
||||||
|
|
||||||
typedef struct _xmlSchemaVal xmlSchemaVal;
|
typedef struct _xmlSchemaVal xmlSchemaVal;
|
||||||
@ -206,6 +207,7 @@ struct _xmlSchemaElement {
|
|||||||
xmlChar *value;
|
xmlChar *value;
|
||||||
struct _xmlSchemaElement *refDecl;
|
struct _xmlSchemaElement *refDecl;
|
||||||
xmlRegexpPtr contModel;
|
xmlRegexpPtr contModel;
|
||||||
|
xmlSchemaContentType contentType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
1
result/schemas/item_0_0
Normal file
1
result/schemas/item_0_0
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/item_0.xml validates
|
39
result/schemas/item_0_0.err
Normal file
39
result/schemas/item_0_0.err
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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
|
6
test/schemas/item_0.xml
Normal file
6
test/schemas/item_0.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<Item partNum="926-AA" shipBy="air">
|
||||||
|
<productName>foo</productName>
|
||||||
|
<quantity>2</quantity>
|
||||||
|
<USPrice>1.0</USPrice>
|
||||||
|
<comment>No comment !</comment>
|
||||||
|
</Item>
|
39
test/schemas/item_0.xsd
Normal file
39
test/schemas/item_0.xsd
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?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>
|
39
xmlschemas.c
39
xmlschemas.c
@ -642,6 +642,9 @@ xmlSchemaTypeDump(xmlSchemaTypePtr type, FILE * output)
|
|||||||
case XML_SCHEMA_CONTENT_SIMPLE:
|
case XML_SCHEMA_CONTENT_SIMPLE:
|
||||||
fprintf(output, "simple ");
|
fprintf(output, "simple ");
|
||||||
break;
|
break;
|
||||||
|
case XML_SCHEMA_CONTENT_ANY:
|
||||||
|
fprintf(output, "any ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
fprintf(output, "\n");
|
fprintf(output, "\n");
|
||||||
if ((type->minOccurs != 1) || (type->maxOccurs != 1)) {
|
if ((type->minOccurs != 1) || (type->maxOccurs != 1)) {
|
||||||
@ -1597,7 +1600,7 @@ xmlSchemaParseAttribute(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
if (IS_SCHEMA(child, "simpleType")) {
|
if (IS_SCHEMA(child, "simpleType")) {
|
||||||
ret->base = xmlSchemaParseSimpleType(ctxt, schema, child);
|
ret->subtypes = xmlSchemaParseSimpleType(ctxt, schema, child);
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
if (child != NULL) {
|
if (child != NULL) {
|
||||||
@ -3107,8 +3110,10 @@ xmlSchemaBuildContentModel(xmlSchemaElementPtr elem,
|
|||||||
|
|
||||||
if (elem->contModel != NULL)
|
if (elem->contModel != NULL)
|
||||||
return;
|
return;
|
||||||
if (elem->subtypes == NULL)
|
if (elem->subtypes == NULL) {
|
||||||
|
elem->contentType = XML_SCHEMA_CONTENT_ANY;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (elem->subtypes->type != XML_SCHEMA_TYPE_COMPLEX)
|
if (elem->subtypes->type != XML_SCHEMA_TYPE_COMPLEX)
|
||||||
return;
|
return;
|
||||||
if (elem->subtypes->contentType == XML_SCHEMA_CONTENT_BASIC)
|
if (elem->subtypes->contentType == XML_SCHEMA_CONTENT_BASIC)
|
||||||
@ -3823,12 +3828,28 @@ xmlSchemaValidateSimpleValue(xmlSchemaValidCtxtPtr ctxt,
|
|||||||
if (ctxt->schema != NULL) {
|
if (ctxt->schema != NULL) {
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
facet = type->facets;
|
facet = type->facets;
|
||||||
while (facet != NULL) {
|
if ((type->type == XML_SCHEMA_TYPE_RESTRICTION) &&
|
||||||
tmp = xmlSchemaValidateFacet(base, facet, value,
|
(facet != NULL) &&
|
||||||
ctxt->value);
|
(facet->type == XML_SCHEMA_FACET_ENUMERATION)) {
|
||||||
if (tmp != 0)
|
while (facet != NULL) {
|
||||||
ret = tmp;
|
ret = 1;
|
||||||
facet = facet->next;
|
|
||||||
|
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;
|
return;
|
||||||
if (ctxt->attr != NULL)
|
if (ctxt->attr != NULL)
|
||||||
xmlFree(ctxt->attr);
|
xmlFree(ctxt->attr);
|
||||||
|
if (ctxt->value != NULL)
|
||||||
|
xmlSchemaFreeValue(ctxt->value);
|
||||||
xmlFree(ctxt);
|
xmlFree(ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,6 +499,11 @@ xmlSchemaValidateFacet(xmlSchemaTypePtr base, xmlSchemaFacetPtr facet,
|
|||||||
}
|
}
|
||||||
TODO /* error code */
|
TODO /* error code */
|
||||||
return(1);
|
return(1);
|
||||||
|
case XML_SCHEMA_FACET_ENUMERATION:
|
||||||
|
if ((facet->value != NULL) &&
|
||||||
|
(xmlStrEqual(facet->value, value)))
|
||||||
|
return(0);
|
||||||
|
return(1);
|
||||||
default:
|
default:
|
||||||
TODO
|
TODO
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user