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
diff --git a/ChangeLog b/ChangeLog
index 5ec83dc..661a51c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
 	* TODO: updated a bit
diff --git a/Makefile.am b/Makefile.am
index 002595e..b507fa2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -637,6 +637,7 @@
 		       res.$$name;\
 	          diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err \
 		       err.$$name;\
+		  grep Unimplemented err.$$name; \
 	          rm res.$$name err.$$name ; \
 	       fi ; \
 	  done; done)
diff --git a/include/libxml/schemasInternals.h b/include/libxml/schemasInternals.h
index 1322c4c..e59e157 100644
--- a/include/libxml/schemasInternals.h
+++ b/include/libxml/schemasInternals.h
@@ -69,7 +69,8 @@
     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 @@
     xmlChar *value;
     struct _xmlSchemaElement *refDecl;
     xmlRegexpPtr contModel;
+    xmlSchemaContentType contentType;
 };
 
 /**
diff --git a/result/schemas/item_0_0 b/result/schemas/item_0_0
new file mode 100644
index 0000000..90fa561
--- /dev/null
+++ b/result/schemas/item_0_0
@@ -0,0 +1 @@
+./test/schemas/item_0.xml validates
diff --git a/result/schemas/item_0_0.err b/result/schemas/item_0_0.err
new file mode 100644
index 0000000..9359011
--- /dev/null
+++ b/result/schemas/item_0_0.err
@@ -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
diff --git a/test/schemas/item_0.xml b/test/schemas/item_0.xml
new file mode 100644
index 0000000..19d0790
--- /dev/null
+++ b/test/schemas/item_0.xml
@@ -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>
diff --git a/test/schemas/item_0.xsd b/test/schemas/item_0.xsd
new file mode 100644
index 0000000..3d95ef3
--- /dev/null
+++ b/test/schemas/item_0.xsd
@@ -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>
diff --git a/xmlschemas.c b/xmlschemas.c
index fb48801..86359ce 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -642,6 +642,9 @@
 	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 @@
 	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 @@
 
     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 @@
 	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 @@
 	return;
     if (ctxt->attr != NULL)
 	xmlFree(ctxt->attr);
+    if (ctxt->value != NULL)
+	xmlSchemaFreeValue(ctxt->value);
     xmlFree(ctxt);
 }
 
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index 200047f..92e71ff 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -499,6 +499,11 @@
 	    }
 	    TODO /* error code */
 	    return(1);
+	case  XML_SCHEMA_FACET_ENUMERATION:
+	    if ((facet->value != NULL) &&
+		(xmlStrEqual(facet->value, value)))
+		return(0);
+	    return(1);
 	default:
 	    TODO
     }