2002-05-25 Dwivedi, Ajay kumar <adwiv@yahoo.com>
authorAjay kumar Dwivedi <ajay@mono-cvs.ximian.com>
Sat, 25 May 2002 00:02:55 +0000 (00:02 -0000)
committerAjay kumar Dwivedi <ajay@mono-cvs.ximian.com>
Sat, 25 May 2002 00:02:55 +0000 (00:02 -0000)
* BUGS.txt: New file to keep track of bugs

* ALL: All classes are initialized exactly as in .NET except
       1. inclusion of language attribute in schema
       2. ComplexContent's Particle is initialized to null whereas .NET
          to some internal implementation. IMO Null is more appropriate

* ALL: Changed the Compile methods to return the count of errors.

* ALL: Complile methods are almost complete. Pass 1453 of 3061 tests.
       This number should shoot up if we write a parser to read the
       Schema instead of using reflection (which is slower too)

svn path=/trunk/mcs/; revision=4926

38 files changed:
mcs/class/System.XML/System.Xml.Schema/BUGS.txt [new file with mode: 0755]
mcs/class/System.XML/System.Xml.Schema/ChangeLog
mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs

diff --git a/mcs/class/System.XML/System.Xml.Schema/BUGS.txt b/mcs/class/System.XML/System.Xml.Schema/BUGS.txt
new file mode 100755 (executable)
index 0000000..8cea098
--- /dev/null
@@ -0,0 +1,8 @@
+Bugs in Implementation:\r
+\r
+1. XmlSchema.Read Fails if there is a wrong value for a enum type. Eg form="none" will throw an exception.\r
+   The only conformant solution to this is using our own Deserializer or parser.\r
+2. Schema Compile ignores errors where a name or id (or any other attribute) is empty. Eg if a schama has name="",\r
+   it will not throw an exception but will be silently ignored. Again the solution is to write own parser.\r
+3. Not all Compile methods check for the Id attribute. Trivial but needs to be done.\r
+4. Need to check if errorCount is calculted correctly, and all of the error() methods increase it.\r
index 2aef56d1e2273106c288fe6f889b171c81b06891..49425367bc7674a1515cec64c7491d89cc87665f 100755 (executable)
@@ -1,3 +1,17 @@
+2002-05-25  Dwivedi, Ajay kumar <adwiv@yahoo.com>
+       * BUGS.txt: New file to keep track of bugs
+
+       * ALL: All classes are initialized exactly as in .NET except
+              1. inclusion of language attribute in schema
+              2. ComplexContent's Particle is initialized to null whereas .NET 
+                 to some internal implementation. IMO Null is more appropriate
+
+       * ALL: Changed the Compile methods to return the count of errors.
+
+       * ALL: Complile methods are almost complete. Pass 1453 of 3061 tests.
+              This number should shoot up if we write a parser to read the
+              Schema instead of using reflection (which is slower too)
+
 2002-05-04  Dwivedi, Ajay kumar <adwiv@yahoo.com>
        * XmlSchemaUtil.cs: New file added. 
        
index fced85e9f3a0885c45a9472a72ff888737c26b7b..438de0cf7f01def3f692ed0adbf8e30b73f47e95 100755 (executable)
@@ -204,8 +204,7 @@ namespace System.Xml.Schema
                /// </summary>\r
                /// <remarks>\r
                ///             1. blockDefault must be one of #all | List of (extension | restriction | substitution)\r
-               ///             2. finalDefault must be one of (#all | List of (extension | restriction))\r
-               ///                     BUGS: MS Implementation allows union and list on finaldefault. Why?\r
+               ///             2. finalDefault must be one of (#all | List of (extension | restriction| union| list))\r
                ///             3. id must be of type ID\r
                ///             4. targetNamespace should be any uri\r
                ///             5. version should be a token\r
@@ -223,18 +222,14 @@ namespace System.Xml.Schema
                                if((this.blockDefault & XmlSchemaDerivationMethod.Union)!=0 )\r
                                        error(handler, "union is not allowed in blockDefault attribute");\r
                        }\r
-                       //2. List, Union and Substitution are not allowed in finaldefault.\r
+                       //2. Substitution is not allowed in finaldefault.\r
                        if(this.finalDefault != XmlSchemaDerivationMethod.All)\r
                        {\r
-                               if((this.finalDefault & XmlSchemaDerivationMethod.List)!=0 )\r
-                                       error(handler, "list is not allowed in finalDefault attribute");\r
-                               if((this.finalDefault & XmlSchemaDerivationMethod.Union)!=0 )\r
-                                       error(handler, "union is not allowed in finalDefault attribute");\r
                                if((this.finalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )\r
                                        error(handler, "substitution is not allowed in finalDefault attribute");\r
                        }\r
                        //3. id must be of type ID\r
-                       if(!XmlSchemaUtil.CheckID(this.id))\r
+                       if(this.id != null && !XmlSchemaUtil.CheckID(this.id))\r
                                error(handler, "id attribute is not a valid ID");\r
 \r
                        //4. targetNamespace should be of type anyURI\r
@@ -253,9 +248,22 @@ namespace System.Xml.Schema
                        info = new XmlSchemaInfo();\r
                        if(this.targetNamespace != null && XmlSchemaUtil.CheckAnyUri(this.targetNamespace))\r
                                info.targetNS = this.TargetNamespace;\r
-                       info.finalDefault = (FinalDefault & XmlSchemaDerivationMethod.Extension & XmlSchemaDerivationMethod.Restriction);\r
-                       info.blockDefault = (blockDefault & XmlSchemaDerivationMethod.Extension & \r
-                                                                       XmlSchemaDerivationMethod.Restriction & XmlSchemaDerivationMethod.Substitution);\r
+                       \r
+                       if(this.ElementFormDefault != XmlSchemaForm.Qualified)\r
+                               info.formDefault = XmlSchemaForm.Unqualified;\r
+                       else\r
+                               info.formDefault = XmlSchemaForm.Qualified;\r
+\r
+                       if(FinalDefault == XmlSchemaDerivationMethod.All)\r
+                               info.finalDefault = XmlSchemaDerivationMethod.All;\r
+                       else // If finalDefault is None, info's finalDefault is set to empty\r
+                               info.finalDefault = (FinalDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));\r
+\r
+                       if(BlockDefault == XmlSchemaDerivationMethod.All)\r
+                               info.blockDefault = XmlSchemaDerivationMethod.All;\r
+                       else // If finalDefault is None, info's blockDefault is set to empty\r
+                               info.blockDefault = (blockDefault & (XmlSchemaDerivationMethod.Extension |\r
+                                                                       XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution));\r
 \r
                        // Compile the content of this schema\r
                        foreach(XmlSchemaObject obj in Includes)\r
@@ -273,7 +281,7 @@ namespace System.Xml.Schema
                        {\r
                                if(obj is XmlSchemaAnnotation)\r
                                {\r
-                                       if(((XmlSchemaAnnotation)obj).Compile(handler,info))\r
+                                       if(((XmlSchemaAnnotation)obj).Compile(handler,info) == 0)\r
                                        {\r
                                                //FIXME: What PSVI set do we add this to?\r
                                        }\r
@@ -281,16 +289,16 @@ namespace System.Xml.Schema
                                else if(obj is XmlSchemaAttribute)\r
                                {\r
                                        XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
-                                       if(attr.Compile(handler,info))\r
+                                       attr.parentIsSchema = true;\r
+                                       if(attr.Compile(handler,info) == 0)\r
                                        {\r
-                                               attr.parentIsSchema = true;\r
                                                Attributes.Add(attr.QualifiedName, attr);\r
                                        }\r
                                }\r
                                else if(obj is XmlSchemaAttributeGroup)\r
                                {\r
                                        XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup) obj;\r
-                                       if(attrgrp.Compile(handler,info))\r
+                                       if(attrgrp.Compile(handler,info) == 0)\r
                                        {\r
                                                AttributeGroups.Add(attrgrp.QualifiedName, attrgrp);\r
                                        }\r
@@ -298,7 +306,8 @@ namespace System.Xml.Schema
                                else if(obj is XmlSchemaComplexType)\r
                                {\r
                                        XmlSchemaComplexType ctype = (XmlSchemaComplexType) obj;\r
-                                       if(ctype.Compile(handler,info))\r
+                                       ctype.istoplevel = true;\r
+                                       if(ctype.Compile(handler,info) == 0)\r
                                        {\r
                                                schemaTypes.Add(ctype.QualifiedName, ctype);\r
                                        }\r
@@ -306,7 +315,8 @@ namespace System.Xml.Schema
                                else if(obj is XmlSchemaSimpleType)\r
                                {\r
                                        XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;\r
-                                       if(stype.Compile(handler,info))\r
+                                       stype.islocal = false; //This simple type is toplevel\r
+                                       if(stype.Compile(handler,info) == 0)\r
                                        {\r
                                                SchemaTypes.Add(stype.QualifiedName, stype);\r
                                        }\r
@@ -314,7 +324,8 @@ namespace System.Xml.Schema
                                else if(obj is XmlSchemaElement)\r
                                {\r
                                        XmlSchemaElement elem = (XmlSchemaElement) obj;\r
-                                       if(elem.Compile(handler,info))\r
+                                       elem.parentIsSchema = true;\r
+                                       if(elem.Compile(handler,info) == 0)\r
                                        {\r
                                                Elements.Add(elem.QualifiedName,elem);\r
                                        }\r
@@ -322,7 +333,7 @@ namespace System.Xml.Schema
                                else if(obj is XmlSchemaGroup)\r
                                {\r
                                        XmlSchemaGroup grp = (XmlSchemaGroup) obj;\r
-                                       if(grp.Compile(handler,info))\r
+                                       if(grp.Compile(handler,info) == 0)\r
                                        {\r
                                                Groups.Add(grp.QualifiedName,grp);\r
                                        }\r
@@ -330,7 +341,7 @@ namespace System.Xml.Schema
                                else if(obj is XmlSchemaNotation)\r
                                {\r
                                        XmlSchemaNotation ntn = (XmlSchemaNotation) obj;\r
-                                       if(ntn.Compile(handler,info))\r
+                                       if(ntn.Compile(handler,info) == 0)\r
                                        {\r
                                                Notations.Add(ntn.QualifiedName, ntn);\r
                                        }\r
index c5b1d1c27901e068e2443a44a178a43d922c7f74..874767df2a5014f8817c877f4c21e873be489cd4 100755 (executable)
@@ -11,6 +11,7 @@ namespace System.Xml.Schema
        public class XmlSchemaAll : XmlSchemaGroupBase\r
        {\r
                private XmlSchemaObjectCollection items;\r
+               private int errorCount=0;\r
                public XmlSchemaAll()\r
                {\r
                        items = new XmlSchemaObjectCollection();\r
@@ -20,5 +21,42 @@ namespace System.Xml.Schema
                {\r
                        get{ return items; }\r
                }\r
+               /// <remarks>\r
+               /// 1. MaxOccurs must be one. (default is also one)\r
+               /// 2. MinOccurs must be zero or one.\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(MaxOccurs != Decimal.One)\r
+                               error(h,"maxOccurs must be 1");\r
+                       if(MinOccurs != Decimal.One && MinOccurs != Decimal.Zero)\r
+                               error(h,"minOccurs must be 0 or 1");\r
+\r
+                       foreach(XmlSchemaObject obj in Items)\r
+                       {\r
+                               if(obj is XmlSchemaElement)\r
+                               {\r
+                                       errorCount += ((XmlSchemaElement)obj).Compile(h,info);\r
+                               }\r
+                               else\r
+                               {\r
+                                       error(h,"XmlSchemaAll can only contain Items of type Element");\r
+                               }\r
+                       }\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 896eeccd0a0d1b26c532de30d917b89c5e90e927..e3129229230ff445c6e2150699ea2ae58a19c2fe 100755 (executable)
@@ -42,15 +42,15 @@ namespace System.Xml.Schema
                }\r
 \r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       return false;\r
+                       return 1;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
                {\r
-                       return false;\r
+                       return 1;\r
                }\r
        }\r
 }\r
index 80ce461990217e9e6f9d5d396f3dffd0f5978b23..95de9949a4135751811938f7f5b6fc05286b2d59 100755 (executable)
@@ -13,10 +13,10 @@ namespace System.Xml.Schema
        {\r
                private string nameSpace;\r
                private XmlSchemaContentProcessing processing;\r
+               private int errorCount = 0;\r
 \r
                public XmlSchemaAny()\r
                {\r
-                       nameSpace = string.Empty;\r
                }\r
 \r
                [System.Xml.Serialization.XmlAttribute("namespace")]\r
@@ -33,5 +33,67 @@ namespace System.Xml.Schema
                        get{ return processing; } \r
                        set{ processing = value; }\r
                }\r
+\r
+               /// <remarks>\r
+               /// 1. id must be of type ID\r
+               /// 2. namespace can have one of the following values:\r
+               ///             a) ##any or ##other\r
+               ///             b) list of anyURI and ##targetNamespace and ##local\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       errorCount = 0;\r
+\r
+                       if(Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                       {\r
+                               error(h, "id attribute must be a valid ID");\r
+                       }\r
+                       //define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16\r
+                       int nscount = 0;\r
+                       string[] nslist = XmlSchemaUtil.SplitList(Namespace);\r
+                       foreach(string ns in nslist)\r
+                       {\r
+                               switch(ns)\r
+                               {\r
+                                       case "##any": \r
+                                               nscount |= 1;\r
+                                               break;\r
+                                       case "##other":\r
+                                               nscount |= 2;\r
+                                               break;\r
+                                       case "##targetNamespace":\r
+                                               nscount |= 4;\r
+                                               break;\r
+                                       case "##local":\r
+                                               nscount |= 8;\r
+                                               break;\r
+                                       default:\r
+                                               if(!XmlSchemaUtil.CheckAnyUri(ns))\r
+                                                       error(h,"the namespace is not a valid anyURI");\r
+                                               else\r
+                                                       nscount |= 16;\r
+                                               break;\r
+                               }\r
+                       }\r
+                       if((nscount&1) == 1 && nscount != 1)\r
+                               error(h,"##any if present must be the only namespace attribute");\r
+                       if((nscount&2) == 2 && nscount != 2)\r
+                               error(h,"##other if present must be the only namespace attribute");\r
+                       \r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 6392c84ebb0be993985619097edddbf6c8b9ef03..df494ec47d6be169a778d89d24b6a3b41f00f259 100755 (executable)
@@ -13,10 +13,10 @@ namespace System.Xml.Schema
        {\r
                private string nameSpace;\r
                private XmlSchemaContentProcessing processing;\r
+               private int errorCount;\r
 \r
                public XmlSchemaAnyAttribute()\r
                {\r
-                       nameSpace = string.Empty;\r
                }\r
 \r
                [System.Xml.Serialization.XmlAttribute("namespace")]\r
@@ -33,5 +33,67 @@ namespace System.Xml.Schema
                        get{ return processing; } \r
                        set{ processing = value; }\r
                }\r
+\r
+               /// <remarks>\r
+               /// 1. id must be of type ID\r
+               /// 2. namespace can have one of the following values:\r
+               ///             a) ##any or ##other\r
+               ///             b) list of anyURI and ##targetNamespace and ##local\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       errorCount = 0;\r
+\r
+                       if(Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                       {\r
+                               error(h, "id attribute must be a valid ID");\r
+                       }\r
+                       //define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16\r
+                       int nscount = 0;\r
+                       string[] nslist = XmlSchemaUtil.SplitList(Namespace);\r
+                       foreach(string ns in nslist)\r
+                       {\r
+                               switch(ns)\r
+                               {\r
+                                       case "##any": \r
+                                               nscount |= 1;\r
+                                               break;\r
+                                       case "##other":\r
+                                               nscount |= 2;\r
+                                               break;\r
+                                       case "##targetNamespace":\r
+                                               nscount |= 4;\r
+                                               break;\r
+                                       case "##local":\r
+                                               nscount |= 8;\r
+                                               break;\r
+                                       default:\r
+                                               if(!XmlSchemaUtil.CheckAnyUri(ns))\r
+                                                       error(h,"the namespace is not a valid anyURI");\r
+                                               else\r
+                                                       nscount |= 16;\r
+                                               break;\r
+                               }\r
+                       }\r
+                       if((nscount&1) == 1 && nscount != 1)\r
+                               error(h,"##any if present must be the only namespace attribute");\r
+                       if((nscount&2) == 2 && nscount != 2)\r
+                               error(h,"##other if present must be the only namespace attribute");\r
+                       \r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+                               \r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       this.errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index ae060eb723849b4fc64c01b902c73de28f9cd6c2..0aa067664a8d5580cec3bdde2e9ae93982254f5a 100755 (executable)
@@ -16,7 +16,6 @@ namespace System.Xml.Schema
 \r
                public XmlSchemaAppInfo()\r
                {\r
-                       source = string.Empty;\r
                }\r
 \r
                [XmlAnyElement]\r
index cc4fdd03a09bc6ea1368fb704d4b1409c4b1c72a..b90c96fa80bbd30da3dfcb60386bda4de4e451b4 100755 (executable)
@@ -24,8 +24,7 @@ namespace System.Xml.Schema
                private XmlSchemaUse use;\r
                //Compilation fields\r
                internal bool parentIsSchema = false;\r
-               internal XmlSchema schema = null;\r
-               internal bool errorOccured = false;\r
+               internal int errorCount;\r
                \r
                public XmlSchemaAttribute()\r
                {\r
@@ -146,13 +145,28 @@ namespace System.Xml.Schema
                ///             14. name must not be xmlns\r
                ///             15. Targetnamespace must not be xsi. This implies the target namespace of schema can't be xsi if toplevel attributes are used.\r
                ///             16. *Exception to rule 15* inbuilt attributes: xsi:nil, xsi:type, xsi:schemaLocation, xsi: noNamespaceSchemaLocation\r
-               ///     b) *TODO*: If the parent is complextype and ref is not set\r
-               ///     c) *TODO*: if the parent is not schema and ref is set\r
+               ///     b) If the parent is complextype and ref is not set\r
+               ///             1. name must be present and of type NCName.\r
+               ///             2. type and <simpleType> must not both be present.\r
+               ///             3. default and fixed must not both be present. \r
+               ///     4. If default and use are both present, use must have the Â·actual value· optional.\r
+               ///             5. name must not be xmlns\r
+               ///             6. Targetnamespace must not be xsi.\r
+               ///             7. *Exception to rule 15* inbuilt attributes: xsi:nil, xsi:type, xsi:schemaLocation, xsi: noNamespaceSchemaLocation\r
+               ///             8. If form has actual value qualified or the schema's formdefault is qualified, targetnamespace\r
+               ///                is same as schema's target namespace, otherwise absent.\r
+               ///     c) if the parent is not schema and ref is set\r
+               ///             1. name must not be present\r
+               ///             2. all of <simpleType>, form and type must be absent. \r
+               ///             3. default and fixed must not both be present. \r
+               ///     4. If default and use are both present, use must have the Â·actual value· optional.\r
                /// </remarks>\r
                [MonoTODO]\r
                //FIXME: Should we set a property to null if an error occurs? Or should we stop the validation?\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
+                       errorCount = 0;\r
+                       \r
                        if(parentIsSchema)//a\r
                        {\r
                                if(this.refName!= null && !this.refName.IsEmpty) // a.1\r
@@ -164,18 +178,45 @@ namespace System.Xml.Schema
                                if(this.use != XmlSchemaUse.None)               // a.3\r
                                        error(h,"use must be absent in the top level <attribute>");\r
 \r
-                               if(this.name == null)   //a.4\r
-                                       error(h,"name must be present if attribute has schema as its parent");\r
-                               else if(!XmlSchemaUtil.CheckNCName(this.name)) // a.4.2\r
+                               // TODO: a.10, a.11, a.12, a.13\r
+                               CompileCommon(h,info, true);\r
+                       }\r
+                       else // local\r
+                       {\r
+                               if(this.refName == null || this.refName.IsEmpty)\r
+                               {\r
+                                       //TODO: b.8\r
+                                       CompileCommon(h,info, true);\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(this.name != null)\r
+                                               error(h,"name must be absent if ref is present");\r
+                                       if(this.form != XmlSchemaForm.None)\r
+                                               error(h,"form must be absent if ref is present");\r
+                                       if(this.schemaType != null)\r
+                                               error(h,"simpletype must be absent if ref is present");\r
+                                       if(this.schemaTypeName != null && !this.schemaTypeName.IsEmpty)\r
+                                               error(h,"type must be absent if ref is present");\r
+                                       CompileCommon(h,info,false);\r
+                               }\r
+                       }\r
+\r
+                       return errorCount;\r
+               }\r
+               \r
+               private void CompileCommon(ValidationEventHandler h, XmlSchemaInfo info, bool refIsNotPresent)\r
+               {\r
+                       if(refIsNotPresent)\r
+                       {\r
+                               if(this.name == null)   //a.4, b.1, \r
+                                       error(h,"Required attribute name must be present");\r
+                               else if(!XmlSchemaUtil.CheckNCName(this.name)) // a.4.2, b1.2\r
                                        error(h,"attribute name must be NCName");\r
-                               else if(this.name == "xmlns") // a.14 \r
+                               else if(this.name == "xmlns") // a.14 , b5\r
                                        error(h,"attribute name can't be xmlns");\r
                                else\r
                                        this.qualifiedName = new XmlQualifiedName(this.name, info.targetNS);    \r
-       \r
-                               // TODO: a.10, a.11, a.12, a.13\r
-                               if(this.defaultValue != null && this.fixedValue != null) // a.6\r
-                                       error(h,"default and fixed must not both be present in an Attribute");\r
 \r
                                if(this.schemaType != null)\r
                                {\r
@@ -183,35 +224,40 @@ namespace System.Xml.Schema
                                                error(h,"attribute can't have both a type and <simpleType> content");\r
                                        else \r
                                        {\r
-                                               this.SchemaType.islocal = true;\r
-                                               this.schemaType.Compile(h,info); \r
+                                               errorCount += this.schemaType.Compile(h,info); \r
                                        }\r
                                }\r
-\r
-                               if(info.targetNS == XmlSchema.InstanceNamespace && this.name != "nil" && this.name != "type" \r
-                                       && this.name != "schemaLocation" && this.name != "noNamespaceSchemaLocation") // a.15, a.16\r
-                                       error(h,"targetNamespace can't be " + XmlSchema.InstanceNamespace);\r
-\r
                        }\r
-//                     TODO: \r
-//                     else\r
-//                     {\r
-//                     }\r
-                       if(!XmlSchemaUtil.CheckID(this.Id))\r
-                               error(h,"id must be a valid ID");\r
+                       else\r
+                       {\r
+                               //      redundant since we call function after check\r
+                               //if(this.refName == null || this.refName.IsEmpty) \r
+                               //      error(h,"refname must be present");\r
+                               this.qualifiedName = this.refName;\r
+                       }\r
+                       if(info.targetNS == XmlSchema.InstanceNamespace && this.name != "nil" && this.name != "type" \r
+                               && this.name != "schemaLocation" && this.name != "noNamespaceSchemaLocation") // a.15, a.16\r
+                               error(h,"targetNamespace can't be " + XmlSchema.InstanceNamespace);\r
+\r
+                       if(this.defaultValue != null && this.fixedValue != null) // a.6, b.3, c.3\r
+                               error(h,"default and fixed must not both be present in an Attribute");\r
 \r
-                       return !errorOccured;\r
+                       if(this.defaultValue != null && this.use != XmlSchemaUse.None && this.use != XmlSchemaUse.Optional)\r
+                               error(h,"if default is present, use must be optional");\r
+                       \r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h,"id attribute must be a valid ID");\r
                }\r
-               \r
+\r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
                {\r
-                       return false;\r
+                       return errorCount;\r
                }\r
                \r
                internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       this.errorOccured = true;\r
+                       this.errorCount++;\r
                        ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
index beb1d82321eeee55cd8f4047bf4742faeb3e25d4..5e18271463a5ca9181db3cd22de3db8208b21908 100755 (executable)
@@ -16,12 +16,11 @@ namespace System.Xml.Schema
                private string name;\r
                private XmlSchemaAttributeGroup redefined;\r
                private XmlQualifiedName qualifiedName;\r
+               private int errorCount;\r
 \r
                public XmlSchemaAttributeGroup()\r
                {\r
                        attributes  = new XmlSchemaObjectCollection();\r
-                       //FIXME:\r
-                       redefined  = this;\r
                }\r
 \r
                [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]\r
@@ -58,16 +57,58 @@ namespace System.Xml.Schema
                        get{ return qualifiedName;}\r
                }\r
 \r
+               /// <remarks>\r
+               /// An Attribute group can only be defined as a child of XmlSchema or in XmlSchemaRedefine.\r
+               /// The other attributeGroup has type XmlSchemaAttributeGroupRef.\r
+               ///  1. Name must be present\r
+               /// </remarks>\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       return false;\r
+                       errorCount = 0;\r
+\r
+                       if(this.Name == null) //1\r
+                               error(h,"Name is required in top level simpletype");\r
+                       else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2\r
+                               error(h,"name attribute of a simpleType must be NCName");\r
+                       else\r
+                               this.qualifiedName = new XmlQualifiedName(this.Name,info.targetNS);\r
+                       \r
+                       if(this.AnyAttribute != null)\r
+                       {\r
+                               errorCount += this.AnyAttribute.Compile(h,info);\r
+                       }\r
+                       \r
+                       foreach(XmlSchemaObject obj in Attributes)\r
+                       {\r
+                               if(obj is XmlSchemaAttribute)\r
+                               {\r
+                                       XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
+                                       errorCount += attr.Compile(h, info);\r
+                               }\r
+                               else if(obj is XmlSchemaAttributeGroupRef)\r
+                               {\r
+                                       XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef) obj;\r
+                                       errorCount += gref.Compile(h, info);\r
+                               }\r
+                               else\r
+                               {\r
+                                       error(h,"invalid type of object in Attributes property");\r
+                               }\r
+                       }\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+                               \r
+               internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       return false;\r
+                       this.errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
 }\r
index 371f30fe0ae27398860696acace17e0889c70205..32a5ead42cba133122c72e04d776069f73383c5d 100755 (executable)
@@ -12,9 +12,12 @@ namespace System.Xml.Schema
        public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated\r
        {\r
                private XmlQualifiedName refName;\r
+               private int errorCount;\r
 \r
                public XmlSchemaAttributeGroupRef()\r
-               {}\r
+               {\r
+                       refName = XmlQualifiedName.Empty;\r
+               }\r
                \r
                [System.Xml.Serialization.XmlAttribute("ref")]\r
                public XmlQualifiedName RefName \r
@@ -22,5 +25,35 @@ namespace System.Xml.Schema
                        get{ return  refName; }\r
                        set{ refName = value; }\r
                }\r
+\r
+               /// <remarks>\r
+               /// 1. ref must be present\r
+               /// 2. The element must be empty. FIXME: does it mean no id attribute too??\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       errorCount = 0;\r
+                       if(this.refName == null || this.refName.IsEmpty)\r
+                               error(h, "ref must be present");\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       if(this.Annotation != null)\r
+                               error(h, "attributegroup with a ref can't have any content");\r
+                       \r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+                               \r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       this.errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 372f6b5ffdfdad421e580553f3d320a3571a8ce4..345dff2cd3c7846b099729b3b41350781e632ab9 100755 (executable)
@@ -11,6 +11,7 @@ namespace System.Xml.Schema
        public class XmlSchemaChoice : XmlSchemaGroupBase\r
        {\r
                private XmlSchemaObjectCollection items;\r
+               private int errorCount=0;\r
                public XmlSchemaChoice()\r
                {\r
                        items = new XmlSchemaObjectCollection();\r
@@ -25,5 +26,46 @@ namespace System.Xml.Schema
                {\r
                        get{ return items; }\r
                }\r
+\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       foreach(XmlSchemaObject obj in Items)\r
+                       {\r
+                               if(obj is XmlSchemaElement)\r
+                               {\r
+                                       errorCount += ((XmlSchemaElement)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaGroupRef)\r
+                               {\r
+                                       errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaChoice)\r
+                               {\r
+                                       errorCount += ((XmlSchemaChoice)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaSequence)\r
+                               {\r
+                                       errorCount += ((XmlSchemaSequence)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaAny)\r
+                               {\r
+                                       errorCount += ((XmlSchemaAny)obj).Compile(h,info);\r
+                               }\r
+                       }\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index e66cde088b20c0532886fc88addba7d6e16f8cef..c397af5686579f02cf11c54d56694c2d42d4b9a5 100755 (executable)
@@ -12,6 +12,7 @@ namespace System.Xml.Schema
        {\r
                private XmlSchemaContent content;\r
                private bool isMixed;\r
+               private int errorCount=0;\r
 \r
                public XmlSchemaComplexContent()\r
                {}\r
@@ -30,5 +31,49 @@ namespace System.Xml.Schema
                        get{ return  isMixed; } \r
                        set{ isMixed = value; }\r
                }\r
+\r
+               /// <remarks>\r
+               /// 1. Content must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(Content == null)\r
+                       {\r
+                               error(h, "Content must be present in a complexContent");\r
+                       }\r
+                       else\r
+                       {\r
+                               if(Content is XmlSchemaComplexContentRestriction)\r
+                               {\r
+                                       XmlSchemaComplexContentRestriction xscr = (XmlSchemaComplexContentRestriction) Content;\r
+                                       errorCount += xscr.Compile(h,info);\r
+                               }\r
+                               else if(Content is XmlSchemaComplexContentExtension)\r
+                               {\r
+                                       XmlSchemaComplexContentExtension xsce = (XmlSchemaComplexContentExtension) Content;\r
+                                       errorCount += xsce.Compile(h,info);\r
+                               }\r
+                               else\r
+                                       error(h,"complexContent can't have any value other than restriction or extention");\r
+                       }\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 95e4d2c50951323d699c08a65fea5762e50a8a83..bb9ad011b1ae1d97ca539bc734d3ca34b58ad306 100755 (executable)
@@ -15,9 +15,12 @@ namespace System.Xml.Schema
                private XmlSchemaObjectCollection attributes;\r
                private XmlQualifiedName baseTypeName;\r
                private XmlSchemaParticle particle;\r
+               private int errorCount = 0;\r
+\r
                public XmlSchemaComplexContentExtension()\r
                {\r
                        attributes = new XmlSchemaObjectCollection();\r
+                       baseTypeName = XmlQualifiedName.Empty;\r
                }\r
                \r
                [System.Xml.Serialization.XmlAttribute("base")]\r
@@ -26,6 +29,7 @@ namespace System.Xml.Schema
                        get{ return  baseTypeName; }\r
                        set{ baseTypeName = value; }\r
                }\r
+\r
                [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]\r
                public XmlSchemaAnyAttribute AnyAttribute \r
                {\r
@@ -49,5 +53,73 @@ namespace System.Xml.Schema
                        get{ return  particle; }\r
                        set{ particle = value; }\r
                }\r
+\r
+               /// <remarks>\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(BaseTypeName == null || BaseTypeName.IsEmpty)\r
+                       {\r
+                               error(h, "base must be present and a QName");\r
+                       }\r
+                       \r
+                       if(this.AnyAttribute != null)\r
+                       {\r
+                               errorCount += AnyAttribute.Compile(h,info);\r
+                       }\r
+\r
+                       foreach(XmlSchemaObject obj in Attributes)\r
+                       {\r
+                               if(obj is XmlSchemaAttribute)\r
+                               {\r
+                                       XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
+                                       errorCount += attr.Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaAttributeGroupRef)\r
+                               {\r
+                                       XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;\r
+                                       errorCount += atgrp.Compile(h,info);\r
+                               }\r
+                               else\r
+                                       error(h,"object is not valid in this place");\r
+                       }\r
+                       \r
+                       if(Particle != null)\r
+                       {\r
+                               if(Particle is XmlSchemaGroupRef)\r
+                               {\r
+                                       errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaAll)\r
+                               {\r
+                                       errorCount += ((XmlSchemaAll)Particle).Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaChoice)\r
+                               {\r
+                                       errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaSequence)\r
+                               {\r
+                                       errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
+                               }\r
+                       }\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       \r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 043704b55f3110bce71756893ed7eb1b1b84da29..292f7a76bf282ad5f33dfd13cd8e81d722786474 100755 (executable)
@@ -15,6 +15,7 @@ namespace System.Xml.Schema
                private XmlSchemaObjectCollection attributes;\r
                private XmlQualifiedName baseTypeName;\r
                private XmlSchemaParticle particle;\r
+               private int errorCount = 0;\r
 \r
                public XmlSchemaComplexContentRestriction()\r
                {\r
@@ -52,5 +53,74 @@ namespace System.Xml.Schema
                        get{ return  particle; }\r
                        set{ particle = value; }\r
                }\r
+\r
+               /// <remarks>\r
+               /// 1. base must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(BaseTypeName == null || BaseTypeName.IsEmpty)\r
+                       {\r
+                               error(h, "base must be present and a QName");\r
+                       }\r
+                       \r
+                       if(this.AnyAttribute != null)\r
+                       {\r
+                               errorCount += AnyAttribute.Compile(h,info);\r
+                       }\r
+\r
+                       foreach(XmlSchemaObject obj in Attributes)\r
+                       {\r
+                               if(obj is XmlSchemaAttribute)\r
+                               {\r
+                                       XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
+                                       errorCount += attr.Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaAttributeGroupRef)\r
+                               {\r
+                                       XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;\r
+                                       errorCount += atgrp.Compile(h,info);\r
+                               }\r
+                               else\r
+                                       error(h,"object is not valid in this place");\r
+                       }\r
+                       \r
+                       if(Particle != null)\r
+                       {\r
+                               if(Particle is XmlSchemaGroupRef)\r
+                               {\r
+                                       errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaAll)\r
+                               {\r
+                                       errorCount += ((XmlSchemaAll)Particle).Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaChoice)\r
+                               {\r
+                                       errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaSequence)\r
+                               {\r
+                                       errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
+                               }\r
+                       }\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       \r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 91f393b12f3b3da4a0bebecb6d368483ae969c11..3526a75d51458d271ec7d694878c4510154d79eb 100755 (executable)
@@ -24,11 +24,15 @@ namespace System.Xml.Schema
                private bool isAbstract;\r
                private bool isMixed;\r
                private XmlSchemaParticle particle;\r
+               \r
+               private int errorCount;\r
+               internal bool istoplevel = false;\r
 \r
                public XmlSchemaComplexType()\r
                {\r
                        attributes = new XmlSchemaObjectCollection();\r
                        block = XmlSchemaDerivationMethod.None;\r
+                       attributeUses = new XmlSchemaObjectTable();\r
                }\r
 \r
                #region Attributes\r
@@ -80,6 +84,8 @@ namespace System.Xml.Schema
                        set{ contentModel = value; }\r
                }\r
 \r
+               //LAMESPEC: The default value for particle in Schema is of Type EmptyParticle (internal?)\r
+               //But since Particle is a PSVI \r
                [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]\r
                [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]\r
                [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]\r
@@ -120,16 +126,163 @@ namespace System.Xml.Schema
                }\r
                #endregion\r
 \r
+               /// <remarks>\r
+               /// 1. If ContentModel is present, neither particle nor Attributes nor AnyAttribute can be present.\r
+               /// 2. If particle is present, \r
+               /// a. For a topLevelComplexType\r
+               ///             1. name must be present and type NCName\r
+               ///             2. if block is #all, blockdefault is #all, else List of (extension | restriction)\r
+               ///             3. if final is #all, finaldefault is #all, else List of (extension | restriction)\r
+               ///     b. For a local Complex type \r
+               ///             1. abstract must be false\r
+               ///             2. Name must be absent\r
+               ///             3. final must be absent\r
+               ///             4. block must be absent\r
+               ///             \r
+               /// </remarks>\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       return false;\r
+                       if(istoplevel)\r
+                       {\r
+                               if(this.Name == null || this.Name == string.Empty)\r
+                                       error(h,"name must be present in a top level complex type");\r
+                               else\r
+                               {\r
+                                       if(!XmlSchemaUtil.CheckNCName(Name))\r
+                                               error(h,"name must be a NCName");\r
+                                       else\r
+                                               this.qName = new XmlQualifiedName(info.targetNS, Name);\r
+                               }\r
+                               if(Block != XmlSchemaDerivationMethod.None)\r
+                               {\r
+                                       if(Block == XmlSchemaDerivationMethod.All)\r
+                                       {\r
+                                               blockResolved = XmlSchemaDerivationMethod.All;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               //TODO: Check what all is not allowed\r
+                                               blockResolved = Block & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(info.blockDefault == XmlSchemaDerivationMethod.All)\r
+                                       {\r
+                                               blockResolved = XmlSchemaDerivationMethod.All;\r
+                                       }\r
+                                       else\r
+                                               blockResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+                               }\r
+                               if(Final != XmlSchemaDerivationMethod.None)\r
+                               {\r
+                                       if(Final == XmlSchemaDerivationMethod.All)\r
+                                       {\r
+                                               finalResolved = XmlSchemaDerivationMethod.All;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               //TODO: Check what all is not allowed\r
+                                               finalResolved = Final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(info.finalDefault == XmlSchemaDerivationMethod.All)\r
+                                       {\r
+                                               finalResolved = XmlSchemaDerivationMethod.All;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               finalResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+                                       }\r
+                               }\r
+                       }\r
+                       else // Not Top Level\r
+                       {\r
+                               if(isAbstract)\r
+                                       error(h,"abstract must be false in a local complex type");\r
+                               if(Name != null)\r
+                                       error(h,"name must be absent in a local complex type");\r
+                               if(Final != XmlSchemaDerivationMethod.None)\r
+                                       error(h,"final must be absent in a local complex type");\r
+                               if(block != XmlSchemaDerivationMethod.None)\r
+                                       error(h,"block must be absent in a local complex type");\r
+                       }\r
+\r
+                       if(ContentModel != null)\r
+                       {\r
+                               if(anyAttribute != null || Attributes.Count != 0 || Particle != null)\r
+                                       error(h,"attributes, particles or anyattribute is not allowed if ContentModel is present");\r
+\r
+                               if(ContentModel is XmlSchemaSimpleContent)\r
+                               {\r
+                                       XmlSchemaSimpleContent smodel = (XmlSchemaSimpleContent)ContentModel;\r
+                                       errorCount += smodel.Compile(h,info);\r
+                               }\r
+                               else if(ContentModel is XmlSchemaComplexContent)\r
+                               {\r
+                                       XmlSchemaComplexContent cmodel = (XmlSchemaComplexContent)ContentModel;\r
+                                       errorCount += cmodel.Compile(h,info);\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               if(Particle is XmlSchemaGroupRef)\r
+                               {\r
+                                       XmlSchemaGroupRef xsgr = (XmlSchemaGroupRef)Particle;\r
+                                       errorCount += xsgr.Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaAll)\r
+                               {\r
+                                       XmlSchemaAll xsa = (XmlSchemaAll)Particle;\r
+                                       errorCount += xsa.Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaChoice)\r
+                               {\r
+                                       XmlSchemaChoice xsc = (XmlSchemaChoice)Particle;\r
+                                       errorCount += xsc.Compile(h,info);\r
+                               }\r
+                               else if(Particle is XmlSchemaSequence)\r
+                               {\r
+                                       XmlSchemaSequence xss = (XmlSchemaSequence)Particle;\r
+                                       errorCount += xss.Compile(h,info);\r
+                               }\r
+\r
+                               if(this.anyAttribute != null)\r
+                               {\r
+                                       AnyAttribute.Compile(h,info);\r
+                               }\r
+                               foreach(XmlSchemaObject obj in Attributes)\r
+                               {\r
+                                       if(obj is XmlSchemaAttribute)\r
+                                       {\r
+                                               XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
+                                               attr.Compile(h,info);\r
+                                       }\r
+                                       else if(obj is XmlSchemaAttributeGroup)\r
+                                       {\r
+                                               XmlSchemaAttributeGroup atgrp = (XmlSchemaAttributeGroup) obj;\r
+                                               atgrp.Compile(h,info);\r
+                                       }\r
+                                       else\r
+                                               error(h,"object is not valid in this place");\r
+                               }\r
+                       \r
+                       }\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       return false;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
 }\r
index ac7d267deb72f4bc40d4e0f7871ce59a683b6952..bd9e4801a7cb6836698f335eb4520d7111b7ee29 100755 (executable)
@@ -29,6 +29,9 @@ namespace System.Xml.Schema
                private XmlSchemaType schemaType;\r
                private XmlQualifiedName schemaTypeName;\r
                private XmlQualifiedName substitutionGroup;\r
+               internal bool parentIsSchema = false;\r
+               private int errorCount;\r
+               private string targetNamespace;\r
 \r
                public XmlSchemaElement()\r
                {\r
@@ -36,6 +39,10 @@ namespace System.Xml.Schema
                        final = XmlSchemaDerivationMethod.None;\r
                        constraints = new XmlSchemaObjectCollection();\r
                        qName = XmlQualifiedName.Empty;\r
+                       refName = XmlQualifiedName.Empty;\r
+                       schemaTypeName = XmlQualifiedName.Empty;\r
+                       substitutionGroup = XmlQualifiedName.Empty;\r
+\r
                        substitutionGroup = XmlQualifiedName.Empty;\r
                }\r
 \r
@@ -175,16 +182,207 @@ namespace System.Xml.Schema
 \r
                #endregion\r
 \r
+               /// <remarks>\r
+               /// a) If Element has parent as schema:\r
+               ///             1. name must be present and of type NCName.\r
+               ///             2. ref must be absent\r
+               ///             3. form must be absent\r
+               ///             4. minOccurs must be absent\r
+               ///             5. maxOccurs must be absent\r
+               ///     b) If Element has parent is not schema and ref is absent\r
+               ///             1. name must be present and of type NCName.\r
+               ///             2. if form equals qualified or form is absent and schema's formdefault is qualifed,\r
+               ///                targetNamespace is schema's targetnamespace else empty.\r
+               ///             3. type and either <simpleType> or <complexType> are mutually exclusive\r
+               ///             4. default and fixed must not both be present.\r
+               ///             5. substitutiongroup must be absent\r
+               ///             6. final must be absent\r
+               ///             7. abstract must be absent\r
+               ///     c) if the parent is not schema and ref is set\r
+               ///             1. name must not be present\r
+               ///             2. all of <simpleType>,<complexType>,  <key>, <keyref>, <unique>, nillable, \r
+               ///                default, fixed, form, block and type,  must be absent.\r
+               ///         3. substitutiongroup is prohibited\r
+               ///             4. final is prohibited\r
+               ///             5. abstract is prohibited\r
+               ///             6. default and fixed must not both be present.(Actually both are absent)\r
+               /// </remarks>  \r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       return false;\r
+                       \r
+                       if(this.defaultValue != null && this.fixedValue != null)\r
+                               error(h,"both default and fixed can't be present");\r
+\r
+                       if(parentIsSchema)\r
+                       {\r
+                               if(this.refName != null && !RefName.IsEmpty)\r
+                                       error(h,"ref must be absent");\r
+                               \r
+                               if(this.name == null)   //b1\r
+                                       error(h,"Required attribute name must be present");\r
+                               else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2\r
+                                       error(h,"attribute name must be NCName");\r
+                               else\r
+                                       this.qName = new XmlQualifiedName(this.name, info.targetNS);\r
+                               \r
+                               if(form != XmlSchemaForm.None)\r
+                                       error(h,"form must be absent");\r
+                               if(MinOccursString != null)\r
+                                       error(h,"minOccurs must be absent");\r
+                               if(MaxOccursString != null)\r
+                                       error(h,"maxOccurs must be absent");\r
+\r
+                               \r
+                               if(final == XmlSchemaDerivationMethod.All)\r
+                                       finalResolved = XmlSchemaDerivationMethod.All;\r
+                               else if(final == XmlSchemaDerivationMethod.None)\r
+                                       finalResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+                               else \r
+                                       finalResolved = final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+\r
+                               if(block == XmlSchemaDerivationMethod.All)\r
+                                       blockResolved = XmlSchemaDerivationMethod.All;\r
+                               else if(block == XmlSchemaDerivationMethod.None)\r
+                                       blockResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | \r
+                                               XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
+                               else \r
+                                       blockResolved = block & (XmlSchemaDerivationMethod.Extension | \r
+                                               XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
+\r
+                               if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)\r
+                               {\r
+                                       error(h,"both schemaType and content can't be present");\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(schemaType != null)\r
+                                       {\r
+                                               if(schemaType is XmlSchemaSimpleType)\r
+                                                       errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);\r
+                                               else if(schemaType is XmlSchemaComplexType)\r
+                                                       errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);\r
+                                               else\r
+                                                       error(h,"only simpletype or complextype is allowed");\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               if(schemaTypeName == null || schemaTypeName.IsEmpty)\r
+                                                       error(h,"one of schemaType or schemaTypeName must be present");\r
+                                       }\r
+                               }\r
+\r
+                               foreach(XmlSchemaObject obj in constraints)\r
+                               {\r
+                                       if(obj is XmlSchemaUnique)\r
+                                               ((XmlSchemaUnique)obj).Compile(h,info);\r
+                                       else if(obj is XmlSchemaKey)\r
+                                               ((XmlSchemaKey)obj).Compile(h,info);\r
+                                       else if(obj is XmlSchemaKeyref)\r
+                                               ((XmlSchemaKeyref)obj).Compile(h,info);\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               if(substitutionGroup != null && !substitutionGroup.IsEmpty)\r
+                                       error(h,"substitutionGroup must be absent");\r
+                               if(final != XmlSchemaDerivationMethod.None)\r
+                                       error(h,"final must be absent");\r
+                               if(isAbstract)\r
+                                       error(h,"abstract must be absent");\r
+\r
+                               if(refName == null || RefName.IsEmpty)\r
+                               {\r
+                                       if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && info.formDefault == XmlSchemaForm.Qualified))\r
+                                               this.targetNamespace = info.targetNS;\r
+                                       else\r
+                                               this.targetNamespace = string.Empty;\r
+\r
+                                       if(this.name == null)   //b1\r
+                                               error(h,"Required attribute name must be present");\r
+                                       else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2\r
+                                               error(h,"attribute name must be NCName");\r
+                                       else\r
+                                               this.qName = new XmlQualifiedName(this.name, this.targetNamespace);\r
+                               \r
+                                       if(block == XmlSchemaDerivationMethod.All)\r
+                                               blockResolved = XmlSchemaDerivationMethod.All;\r
+                                       else if(block == XmlSchemaDerivationMethod.None)\r
+                                               blockResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | \r
+                                                       XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
+                                       else \r
+                                               blockResolved = block & (XmlSchemaDerivationMethod.Extension | \r
+                                                       XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
+\r
+                                       if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)\r
+                                       {\r
+                                               error(h,"both schemaType and content can't be present");\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               if(schemaType != null)\r
+                                               {\r
+                                                       if(schemaType is XmlSchemaSimpleType)\r
+                                                               errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);\r
+                                                       else if(schemaType is XmlSchemaComplexType)\r
+                                                               errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);\r
+                                                       else\r
+                                                               error(h,"only simpletype or complextype is allowed");\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       if(schemaTypeName == null || schemaTypeName.IsEmpty)\r
+                                                               error(h,"one of schemaType or schemaTypeName must be present");\r
+                                               }\r
+                                       }\r
+\r
+                                       foreach(XmlSchemaObject obj in constraints)\r
+                                       {\r
+                                               if(obj is XmlSchemaUnique)\r
+                                                       ((XmlSchemaUnique)obj).Compile(h,info);\r
+                                               else if(obj is XmlSchemaKey)\r
+                                                       ((XmlSchemaKey)obj).Compile(h,info);\r
+                                               else if(obj is XmlSchemaKeyref)\r
+                                                       ((XmlSchemaKeyref)obj).Compile(h,info);\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(name != null)\r
+                                               error(h,"name must not be present when ref is present");\r
+                                       if(Constraints.Count != 0)\r
+                                               error(h,"key, keyref and unique must be absent");\r
+                                       if(isNillable)\r
+                                               error(h,"nillable must be absent");\r
+                                       if(defaultValue != null)\r
+                                               error(h,"default must be absent");\r
+                                       if(fixedValue != null)\r
+                                               error(h,"fixed must be null");\r
+                                       if(form != XmlSchemaForm.None)\r
+                                               error(h,"form must be absent");\r
+                                       if(block != XmlSchemaDerivationMethod.None)\r
+                                               error(h,"block must be absent");\r
+                                       if(schemaTypeName != null && !schemaTypeName.IsEmpty)\r
+                                               error(h,"type must be absent");\r
+                                       if(SchemaType != null)\r
+                                               error(h,"simpleType or complexType must be absent");\r
+                               }\r
+                       }\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       return false;\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
 }\r
index ed684395714faaac085e4a3dafdbd12ac8d320fa..9758edc4f53200478f9a99a66083f5e87bcd2a09 100755 (executable)
@@ -17,8 +17,8 @@ namespace System.Xml.Schema
 \r
                protected XmlSchemaFacet()\r
                {\r
-                       val = string.Empty;\r
                }\r
+\r
                [DefaultValue(false)]\r
                [System.Xml.Serialization.XmlAttribute("fixed")]\r
                public virtual bool IsFixed \r
@@ -26,6 +26,7 @@ namespace System.Xml.Schema
                        get{ return  isFixed; }\r
                        set{ isFixed = value; }\r
                }\r
+               \r
                [System.Xml.Serialization.XmlAttribute("value")]\r
                public string Value\r
                {\r
index 627241afd2a225f5d9c1bb4fea43e9212be2fff2..4399f67c00fbef312c24c0251659808e9347396a 100755 (executable)
@@ -14,6 +14,7 @@ namespace System.Xml.Schema
                private string name;\r
                private XmlSchemaGroupBase particle;\r
                private XmlQualifiedName qualifiedName;\r
+               private int errorCount;\r
 \r
                public XmlSchemaGroup()\r
                {\r
@@ -41,16 +42,54 @@ namespace System.Xml.Schema
                        get{ return qualifiedName;}\r
                }\r
 \r
+               // 1. name must be present\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       return false;\r
+                       if(Name == null)\r
+                               error(h,"Required attribute name must be present");\r
+                       else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
+                               error(h,"attribute name must be NCName");\r
+                       else\r
+                               qualifiedName = new XmlQualifiedName(Name,info.targetNS);\r
+                       \r
+                       if(Particle == null)\r
+                       {\r
+                               error(h,"Particle is required");\r
+                       }\r
+                       else if(Particle is XmlSchemaChoice)\r
+                       {\r
+                               errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);\r
+                       }\r
+                       else if(Particle is XmlSchemaSequence)\r
+                       {\r
+                               errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
+                       }\r
+                       else if(Particle is XmlSchemaAll)\r
+                       {\r
+                               errorCount += ((XmlSchemaAll)Particle).Compile(h,info);\r
+                       }\r
+                       else\r
+                       {\r
+                               error(h,"only all,choice or sequence are allowed");\r
+                       }\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+               \r
+               internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       return false;\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
 }\r
index f8b73c6f34a098eec06c85709ee8f7a699b79171..bcbf82ddcb2db8ea6eadeca23c6ae794ea7b1fe2 100755 (executable)
@@ -13,8 +13,10 @@ namespace System.Xml.Schema
        {\r
                private XmlSchemaGroupBase particle;\r
                private XmlQualifiedName refName;\r
+               private int errorCount=0;\r
                public XmlSchemaGroupRef()\r
                {\r
+                       refName = XmlQualifiedName.Empty;\r
                }\r
                [XmlIgnore]\r
                public XmlSchemaGroupBase Particle \r
@@ -27,5 +29,32 @@ namespace System.Xml.Schema
                        get{ return  refName; } \r
                        set{ refName = value; }\r
                }\r
+               /// <remarks>\r
+               /// 1. RefName must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(refName == null || refName.IsEmpty)\r
+                       {\r
+                               error(h,"ref must be present");\r
+                       }\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       \r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index f7e20a7c1843f91a7b542964409481e74c1e1c60..e1911f485c0ce447d2c8c1f1bc82f2a65e2304e8 100755 (executable)
@@ -15,6 +15,7 @@ namespace System.Xml.Schema
                private string name;\r
                private XmlQualifiedName qName;\r
                private XmlSchemaXPath selector;\r
+               private int errorCount = 0;\r
 \r
                public XmlSchemaIdentityConstraint()\r
                {\r
@@ -47,5 +48,37 @@ namespace System.Xml.Schema
                {\r
                        get{ return  qName; }\r
                }\r
+               /// <remarks>\r
+               /// 1. name must be present\r
+               /// 2. selector and field must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(Name == null)\r
+                               error(h,"Required attribute name must be present");\r
+                       else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
+                               error(h,"attribute name must be NCName");\r
+                       else\r
+                               this.qName = new XmlQualifiedName(Name,info.targetNS);\r
+\r
+                       //TODO: Compile Xpath. \r
+                       if(Selector == null)\r
+                               error(h,"selector must be present");\r
+               \r
+                       if(Fields.Count == 0)\r
+                               error(h,"atleast one field value must be present");\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle, string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle, this, message);\r
+               }\r
        }\r
 }\r
index 2c5efb3a1cd0192137ef043952a59bf46b24c453..d52bf1d9f8d97ce0cd34749439b1a3fd37e70524 100755 (executable)
@@ -15,5 +15,6 @@ namespace System.Xml.Schema
                internal string targetNS;\r
                internal XmlSchemaDerivationMethod finalDefault;\r
                internal XmlSchemaDerivationMethod blockDefault;\r
+               internal XmlSchemaForm formDefault;\r
        }\r
 }\r
index f89c00594fc6b86363a5680c0e41a088942f3bf9..c05942b684a505d1146a729fef04d102064dc895 100755 (executable)
@@ -9,8 +9,31 @@ namespace System.Xml.Schema
        /// </summary>\r
        public class XmlSchemaKey : XmlSchemaIdentityConstraint\r
        {\r
+               private int errorCount;\r
+\r
                public XmlSchemaKey()\r
                {\r
                }\r
+               /// <remarks>\r
+               /// 1. name must be present\r
+               /// 2. selector and field must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       return base.Compile(h,info);\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal new void error(ValidationEventHandler handle, string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle, this, message);\r
+               }\r
        }\r
 }\r
index cc3a06792ed97c81a5a6e8304adc39288344caf0..fdf88199334991563d3315efd23d6b5e1093fc10 100755 (executable)
@@ -12,9 +12,11 @@ namespace System.Xml.Schema
        public class XmlSchemaKeyref : XmlSchemaIdentityConstraint\r
        {\r
                private XmlQualifiedName refer;\r
+               private int errorCount;\r
 \r
                public XmlSchemaKeyref()\r
                {\r
+                       refer = XmlQualifiedName.Empty;\r
                }\r
 \r
                [System.Xml.Serialization.XmlAttribute("refer")]\r
@@ -23,5 +25,30 @@ namespace System.Xml.Schema
                        get{ return  refer; } \r
                        set{ refer = value; }\r
                }\r
+               /// <remarks>\r
+               /// 1. name must be present\r
+               /// 2. selector and field must be present\r
+               /// 3. refer must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       errorCount = base.Compile(h,info);\r
+                       if(refer == null || refer.IsEmpty)\r
+                               error(h,"refer must be present");\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal new void error(ValidationEventHandler handle, string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle, this, message);\r
+               }\r
        }\r
 }\r
index a955168bb9d8009a030ab5a4303b4bc357a4814c..bdc9b2f5a45bdcb89fb62e69ef52594c09c39170 100755 (executable)
@@ -15,6 +15,7 @@ namespace System.Xml.Schema
                private string pub;\r
                private string system;\r
                private XmlQualifiedName qualifiedName;\r
+               private int errorCount;\r
 \r
                public XmlSchemaNotation()\r
                {\r
@@ -44,16 +45,42 @@ namespace System.Xml.Schema
                        get{ return qualifiedName;}\r
                }\r
 \r
+               // 1. name and public must be present\r
+               // public and system must be anyURI\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       return false;\r
+                       if(Name == null)\r
+                               error(h,"Required attribute name must be present");\r
+                       else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
+                               error(h,"attribute name must be NCName");\r
+                       else\r
+                               qualifiedName = new XmlQualifiedName(Name,info.targetNS);\r
+\r
+                       if(Public==null||Public == "")\r
+                               error(h,"public must be present");\r
+                       else if(!XmlSchemaUtil.CheckAnyUri(Public))\r
+                               error(h,"public must be anyURI");\r
+\r
+                       if(system != null && XmlSchemaUtil.CheckAnyUri(system))\r
+                               error(h,"system must be anyURI");\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+                               \r
+               internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       return false;\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
 }\r
index c9fdf5ce95518000c3214dcdd3de99a25546e00a..a87353025aa7d3504117d7d6e2c85a987f941c62 100755 (executable)
@@ -15,7 +15,7 @@ namespace System.Xml.Schema
                private int linePosition;\r
                private string sourceUri;\r
                private XmlSerializerNamespaces namespaces;\r
-               \r
+\r
                protected XmlSchemaObject()\r
                {\r
                        namespaces = new XmlSerializerNamespaces();\r
index 29c358207a0ad68d15005d90daa51e40f728d81f..637be368baf4cb929778de389ad0d4be8235c046 100755 (executable)
@@ -17,6 +17,10 @@ namespace System.Xml.Schema
 \r
                public XmlSchemaRedefine()\r
                {\r
+                       attributeGroups = new XmlSchemaObjectTable();\r
+                       groups = new XmlSchemaObjectTable();\r
+                       items = new XmlSchemaObjectCollection(this);\r
+                       schemaTypes = new XmlSchemaObjectTable();\r
                }\r
                [XmlIgnore]\r
                public XmlSchemaObjectTable AttributeGroups \r
index 66295e2d2b1a2fdfcd22548e13dca23909bb5a02..013e63c3187ef6daa5de2153798a5dc5fab84c3a 100755 (executable)
@@ -11,6 +11,7 @@ namespace System.Xml.Schema
        public class XmlSchemaSequence : XmlSchemaGroupBase\r
        {\r
                private XmlSchemaObjectCollection items;\r
+               private int errorCount=0;\r
                public XmlSchemaSequence()\r
                {\r
                        items = new XmlSchemaObjectCollection();\r
@@ -25,5 +26,44 @@ namespace System.Xml.Schema
                {\r
                        get{ return items; }\r
                }\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       foreach(XmlSchemaObject obj in Items)\r
+                       {\r
+                               if(obj is XmlSchemaElement)\r
+                               {\r
+                                       errorCount += ((XmlSchemaElement)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaGroupRef)\r
+                               {\r
+                                       errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaChoice)\r
+                               {\r
+                                       errorCount += ((XmlSchemaChoice)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaSequence)\r
+                               {\r
+                                       errorCount += ((XmlSchemaSequence)obj).Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaAny)\r
+                               {\r
+                                       errorCount += ((XmlSchemaAny)obj).Compile(h,info);\r
+                               }\r
+                       }\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 827a37075c34e468eae3853f3c406ed4b303463c..c1eaabbf60b95fe73c7aad1f3682599180f538af 100755 (executable)
@@ -11,6 +11,7 @@ namespace System.Xml.Schema
        public class XmlSchemaSimpleContent : XmlSchemaContentModel\r
        {\r
                private XmlSchemaContent content;\r
+               private int errorCount;\r
 \r
                public XmlSchemaSimpleContent()\r
                {\r
@@ -23,5 +24,46 @@ namespace System.Xml.Schema
                        get{ return  content; } \r
                        set{ content = value; }\r
                }\r
+\r
+               ///<remarks>\r
+               /// 1. Content must be present and one of restriction or extention\r
+               ///</remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(Content == null)\r
+                       {\r
+                               error(h, "Content must be present in a simpleContent");\r
+                       }\r
+                       else\r
+                       {\r
+                               if(Content is XmlSchemaSimpleContentRestriction)\r
+                               {\r
+                                       XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction) Content;\r
+                                       errorCount += xscr.Compile(h,info);\r
+                               }\r
+                               else if(Content is XmlSchemaSimpleContentExtension)\r
+                               {\r
+                                       XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension) Content;\r
+                                       errorCount += xsce.Compile(h,info);\r
+                               }\r
+                               else\r
+                                       error(h,"simpleContent can't have any value other than restriction or extention");\r
+                       }\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index eacb8c5bf166f786c19aa959945e59c0e7f62a7b..e3cdcf7d7d065a500b33c5139e0f667e288560cf 100755 (executable)
@@ -15,6 +15,7 @@ namespace System.Xml.Schema
                private XmlSchemaAnyAttribute any;\r
                private XmlSchemaObjectCollection attributes;\r
                private XmlQualifiedName baseTypeName;\r
+               private int errorCount=0;\r
 \r
                public XmlSchemaSimpleContentExtension()\r
                {\r
@@ -42,5 +43,52 @@ namespace System.Xml.Schema
                        get{ return  baseTypeName; }\r
                        set{ baseTypeName = value; }\r
                }\r
+               ///<remarks>\r
+               /// 1. Base must be present and a QName\r
+               ///</remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(BaseTypeName == null || BaseTypeName.IsEmpty)\r
+                       {\r
+                               error(h, "base must be present and a QName");\r
+                       }\r
+                       \r
+                       if(this.AnyAttribute != null)\r
+                       {\r
+                               AnyAttribute.Compile(h,info);\r
+                       }\r
+\r
+                       foreach(XmlSchemaObject obj in Attributes)\r
+                       {\r
+                               if(obj is XmlSchemaAttribute)\r
+                               {\r
+                                       XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
+                                       attr.Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaAttributeGroup)\r
+                               {\r
+                                       XmlSchemaAttributeGroup atgrp = (XmlSchemaAttributeGroup) obj;\r
+                                       atgrp.Compile(h,info);\r
+                               }\r
+                               else\r
+                                       error(h,"object is not valid in this place");\r
+                       }\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index 98e6bb7afd1a74971a18c3a511089f06651eba21..4e628a7ba5c0a815a0f9930cc7aa6076be4ae9ab 100755 (executable)
@@ -17,6 +17,7 @@ namespace System.Xml.Schema
                private XmlSchemaSimpleType baseType;\r
                private XmlQualifiedName baseTypeName;\r
                private XmlSchemaObjectCollection facets;\r
+               private int errorCount=0;\r
 \r
                public XmlSchemaSimpleContentRestriction()\r
                {\r
@@ -70,5 +71,60 @@ namespace System.Xml.Schema
                { \r
                        get{ return facets; } \r
                }\r
+               ///<remarks>\r
+               /// 1. Base must be present and a QName\r
+               ///</remarks>\r
+               [MonoTODO]\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       if(BaseTypeName == null || BaseTypeName.IsEmpty)\r
+                       {\r
+                               error(h, "base must be present and a QName");\r
+                       }\r
+\r
+                       if(BaseType != null)\r
+                       {\r
+                               errorCount += BaseType.Compile(h,info);\r
+                       }\r
+\r
+                       if(this.AnyAttribute != null)\r
+                       {\r
+                               errorCount += AnyAttribute.Compile(h,info);\r
+                       }\r
+\r
+                       foreach(XmlSchemaObject obj in Attributes)\r
+                       {\r
+                               if(obj is XmlSchemaAttribute)\r
+                               {\r
+                                       XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
+                                       errorCount += attr.Compile(h,info);\r
+                               }\r
+                               else if(obj is XmlSchemaAttributeGroupRef)\r
+                               {\r
+                                       XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;\r
+                                       errorCount += atgrp.Compile(h,info);\r
+                               }\r
+                               else\r
+                                       error(h,"object is not valid in this place");\r
+                       }\r
+                       \r
+                       //TODO: Compile Facets: Looks like they are a part of datatypes. So we'll do them with the datatypes\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
+                               error(h, "id must be a valid ID");\r
+                       return errorCount;\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal void error(ValidationEventHandler handle,string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle,this,message);\r
+               }\r
        }\r
 }\r
index ad26db8bf770a057f2f438d94f9388b5ca3c3d64..7be3e46b3b2448971bf32889fddc235195feb9e9 100755 (executable)
@@ -13,8 +13,8 @@ namespace System.Xml.Schema
        {\r
                private XmlSchemaSimpleTypeContent content;\r
                //compilation vars\r
-               internal bool islocal = false;\r
-               private  bool errorOccured = false;\r
+               internal bool islocal = true; // Assuming local means we have to specify islocal=false only in XmlSchema\r
+               private int errorCount;\r
 \r
                public XmlSchemaSimpleType()\r
                {\r
@@ -49,8 +49,10 @@ namespace System.Xml.Schema
                ///                             4.2 otherwise simple ur-type\r
                /// </remarks>\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
+                       errorCount = 0;\r
+\r
                        if(this.islocal) // a\r
                        {\r
                                if(this.Name != null) // a.1\r
@@ -67,75 +69,79 @@ namespace System.Xml.Schema
                                else\r
                                        this.qName = new XmlQualifiedName(this.Name,info.targetNS);\r
                                \r
-                               XmlSchemaDerivationMethod finaltmp;\r
-\r
-                               // The possible values of finalDefault on schema are #all | List of (extension | restriction)\r
-                               // Of these, the only possible values for us are #all | restriction.\r
-                               if(this.Final != XmlSchemaDerivationMethod.None)\r
-                                       finaltmp = this.Final;\r
-                               else\r
-                                       finaltmp = info.finalDefault;// & XmlSchemaDerivationMethod.Restriction;\r
-                               \r
-                               switch(finaltmp) //b.3, b.4, b.5\r
+                               //NOTE: Although the FinalResolved can be Empty, it is not a valid value for Final\r
+                               //DEVIATION: If an error occurs, the finaldefault is always consulted. This deviates\r
+                               //                       from the way MS implementation works.\r
+                               switch(this.Final) //b.3, b.4\r
                                {\r
+                                               // Invalid values: Throw error and use "prohibited substitutions"\r
                                        case XmlSchemaDerivationMethod.Substitution:\r
                                                error(h,"substition is not a valid value for final in a simpletype");\r
-                                               break;\r
+                                               goto case XmlSchemaDerivationMethod.None;\r
                                        case XmlSchemaDerivationMethod.Extension:\r
                                                error(h,"extension is not a valid value for final in a simpletype");\r
-                                               break;\r
-                                       case XmlSchemaDerivationMethod.Union:\r
-                                               error(h,"union is not a valid value for final in simpletype");\r
-                                               break;\r
+                                               goto case XmlSchemaDerivationMethod.None;\r
                                        case XmlSchemaDerivationMethod.Empty:\r
-                                               this.finalResolved = XmlSchemaDerivationMethod.Empty;\r
+                                               error(h,"empty is not a valid value for final in simpletype");\r
+                                               goto case XmlSchemaDerivationMethod.None;\r
+                                               //valid cases:\r
+                                       case XmlSchemaDerivationMethod.All:\r
+                                               this.finalResolved = XmlSchemaDerivationMethod.All;\r
                                                break;\r
                                        case XmlSchemaDerivationMethod.List:\r
                                                this.finalResolved = XmlSchemaDerivationMethod.List;\r
                                                break;\r
+                                       case XmlSchemaDerivationMethod.Union:\r
+                                               this.finalResolved = XmlSchemaDerivationMethod.Union;\r
+                                               break;\r
                                        case XmlSchemaDerivationMethod.Restriction:\r
                                                this.finalResolved = XmlSchemaDerivationMethod.Restriction;\r
                                                break;\r
-                                       case XmlSchemaDerivationMethod.All:\r
-                                               this.finalResolved = XmlSchemaDerivationMethod.All;\r
-                                               break;\r
-                                       case XmlSchemaDerivationMethod.None: // Default is empty\r
-                                               this.finalResolved = XmlSchemaDerivationMethod.Empty;\r
-                                               break;\r
+                                               // If mutliple values are specified\r
                                        default:\r
                                                error(h,"simpletype can't have more than one value for final");\r
+                                               goto case XmlSchemaDerivationMethod.None;\r
+                                               // use assignment from finaldefault on schema.\r
+                                               // The possible values of finalDefault on schema are #all | List of (extension | restriction)\r
+                                               // Of these, the only possible values for us are #all | restriction.\r
+                                       case XmlSchemaDerivationMethod.None: // b.5\r
+                                               if(info.finalDefault == XmlSchemaDerivationMethod.All)\r
+                                                       finalResolved = XmlSchemaDerivationMethod.All;\r
+                                               else // Either Restriction or Empty\r
+                                                       finalResolved = info.finalDefault & XmlSchemaDerivationMethod.Restriction;\r
                                                break;\r
                                }\r
                        }\r
-                       if(!XmlSchemaUtil.CheckID(this.Id))\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
                                error(h,"id must be a valid ID");\r
 \r
                        if(this.Content == null) //a.3,b.2\r
                                error(h,"Content is required in a simpletype");\r
                        else if(Content is XmlSchemaSimpleTypeRestriction)\r
                        {\r
-                               ((XmlSchemaSimpleTypeRestriction)Content).Compile(h,info);\r
+                               errorCount += ((XmlSchemaSimpleTypeRestriction)Content).Compile(h,info);\r
                        }\r
                        else if(Content is XmlSchemaSimpleTypeList)\r
                        {\r
-                               ((XmlSchemaSimpleTypeList)Content).Compile(h,info);\r
+                               errorCount += ((XmlSchemaSimpleTypeList)Content).Compile(h,info);\r
                        }\r
                        else if(Content is XmlSchemaSimpleTypeUnion)\r
                        {\r
-                               ((XmlSchemaSimpleTypeUnion)Content).Compile(h,info);\r
+                               errorCount += ((XmlSchemaSimpleTypeUnion)Content).Compile(h,info);\r
                        }\r
-                       return !errorOccured;\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
                {\r
-                       return false;\r
+                       return errorCount;\r
                }\r
                \r
                internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       this.errorOccured = true;\r
+                       this.errorCount++;\r
                        ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
index db31ac0f66c750bfdda5bd3582768cc71df928c9..df36902d517759a76a349c8d779d876d2112d619 100755 (executable)
@@ -14,10 +14,12 @@ namespace System.Xml.Schema
        {\r
                private XmlSchemaSimpleType itemType;\r
                private XmlQualifiedName itemTypeName;\r
-               private bool errorOccured;\r
+               private int errorCount;\r
 \r
                public XmlSchemaSimpleTypeList()\r
-               {}\r
+               {\r
+                       this.ItemTypeName = XmlQualifiedName.Empty;\r
+               }\r
 \r
                [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]\r
                public XmlSchemaSimpleType ItemType \r
@@ -26,7 +28,6 @@ namespace System.Xml.Schema
                        set\r
                        {\r
                                itemType = value;\r
-                               itemTypeName = null;\r
                        }\r
                }\r
 \r
@@ -37,7 +38,6 @@ namespace System.Xml.Schema
                        set\r
                        {\r
                                itemTypeName = value;\r
-                               itemType = null;\r
                        }\r
                }\r
                /// <remarks>\r
@@ -45,33 +45,34 @@ namespace System.Xml.Schema
                /// 2. id must be of type ID\r
                /// </remarks>\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
+                       errorCount = 0;\r
+\r
                        if(this.itemType != null && !this.ItemTypeName.IsEmpty)\r
                                error(h, "both itemType and simpletype can't be present");\r
                        if(this.itemType == null && this.ItemTypeName.IsEmpty)\r
                                error(h, "one of itemType or simpletype must be present");\r
                        if(this.itemType != null)\r
                        {\r
-                               this.itemType.islocal = true;\r
-                               this.itemType.Compile(h,info);\r
+                               errorCount += this.itemType.Compile(h,info);\r
                        }\r
 \r
-                       if(!XmlSchemaUtil.CheckID(this.Id))\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
                                error(h,"id must be a valid ID");\r
 \r
-                       return !errorOccured;\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
                {\r
-                       return false;\r
+                       return errorCount;\r
                }\r
                \r
                internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       this.errorOccured = true;\r
+                       this.errorCount++;\r
                        ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
index dde82b70d9d56a4f334354a21e7d26ca02e87d4c..4f2c871e5330ef96b0f9e5bba77456cab5cfe668 100755 (executable)
@@ -15,7 +15,7 @@ namespace System.Xml.Schema
                private XmlSchemaSimpleType baseType;\r
                private XmlQualifiedName baseTypeName;\r
                private XmlSchemaObjectCollection facets;\r
-               bool errorOccured;\r
+               private int errorCount;\r
 \r
                public XmlSchemaSimpleTypeRestriction()\r
                {\r
@@ -60,33 +60,34 @@ namespace System.Xml.Schema
                /// 3. base must be a valid QName *NO CHECK REQUIRED*\r
                /// </remarks>\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
+                       errorCount = 0;\r
+\r
                        if(this.baseType != null && !this.BaseTypeName.IsEmpty)\r
                                error(h, "both base and simpletype can't be set");\r
                        if(this.baseType == null && this.BaseTypeName.IsEmpty)\r
                                error(h, "one of basetype or simpletype must be present");\r
                        if(this.baseType != null)\r
                        {\r
-                               this.baseType.islocal = true;\r
-                               this.baseType.Compile(h,info);\r
+                               errorCount += this.baseType.Compile(h,info);\r
                        }\r
 \r
-                       if(!XmlSchemaUtil.CheckID(this.Id))\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
                                error(h,"id must be a valid ID");\r
 \r
-                       return !errorOccured;\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
                {\r
-                       return false;\r
+                       return errorCount;\r
                }\r
 \r
                internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       this.errorOccured = true;\r
+                       this.errorCount++;\r
                        ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
        }\r
index 70443469515fdaaa77d62cec131374afa0f57496..899431e9569f157cb469636961ceb8fcef461cc9 100755 (executable)
@@ -13,7 +13,7 @@ namespace System.Xml.Schema
        {\r
                private XmlSchemaObjectCollection baseTypes;\r
                private XmlQualifiedName[] memberTypes;\r
-               private bool errorOccured;\r
+               private int errorCount;\r
 \r
                public XmlSchemaSimpleTypeUnion()\r
                {\r
@@ -37,9 +37,15 @@ namespace System.Xml.Schema
                /// 2. id must be a valid ID\r
                /// </remarks>\r
                [MonoTODO]\r
-               internal bool Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
                {\r
-                       if(BaseTypes.Count + MemberTypes.Length == 0)\r
+                       errorCount = 0;\r
+\r
+                       int count = BaseTypes.Count;\r
+                       if(MemberTypes != null)\r
+                               count += MemberTypes.Length;\r
+\r
+                       if(count == 0)\r
                                error(h, "Atleast one simpletype or membertype must be present");\r
 \r
                        foreach(XmlSchemaObject obj in baseTypes)\r
@@ -47,42 +53,47 @@ namespace System.Xml.Schema
                                if(obj != null && obj is XmlSchemaSimpleType)\r
                                {\r
                                        XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;\r
-                                       stype.Compile(h,info);\r
+                                       errorCount += stype.Compile(h,info);\r
                                }\r
                                else\r
                                {\r
                                        error(h, "baseTypes can't have objects other than a simpletype");\r
                                }\r
                        }\r
-                       for(int i=0; i< memberTypes.Length; i++)\r
+                       \r
+                       if(memberTypes!=null)\r
                        {\r
-                               if(memberTypes[i] == null)\r
+                               for(int i=0; i< memberTypes.Length; i++)\r
                                {\r
-                                       warn(h,"memberTypes should not have a null value");\r
-                                       memberTypes[i] = XmlQualifiedName.Empty;\r
+                                       if(memberTypes[i] == null)\r
+                                       {\r
+                                               warn(h,"memberTypes should not have a null value");\r
+                                               memberTypes[i] = XmlQualifiedName.Empty;\r
+                                       }\r
                                }\r
                        }\r
-                       if(!XmlSchemaUtil.CheckID(this.Id))\r
+\r
+                       if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
                                error(h,"id must be a valid ID");\r
 \r
-                       return !errorOccured;\r
+                       return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal bool Validate(ValidationEventHandler h)\r
+               internal int Validate(ValidationEventHandler h)\r
                {\r
-                       return false;\r
+                       return errorCount;\r
                }\r
                \r
                internal void error(ValidationEventHandler handle,string message)\r
                {\r
-                       this.errorOccured = true;\r
+                       this.errorCount++;\r
                        ValidationHandler.RaiseValidationError(handle,this,message);\r
                }\r
 \r
                internal void warn(ValidationEventHandler handle,string message)\r
                {\r
-                       this.errorOccured = true;\r
+                       this.errorCount++;\r
                        ValidationHandler.RaiseValidationWarning(handle,this,message);\r
                }\r
        }\r
index 4996b7e81dda15d8d1ec5023b42d4baa3fed6946..f497cb840ce32ae5632c08a8345528c46ac3d66d 100755 (executable)
@@ -24,6 +24,7 @@ namespace System.Xml.Schema
                public XmlSchemaType()\r
                {\r
                        final = XmlSchemaDerivationMethod.None;\r
+                       qName = XmlQualifiedName.Empty;\r
                }\r
 \r
                #region Attributes\r
index 82465500e590a18d6a9c069c5afe852cf327cb92..d5264239ba14cff7e72ff4ce9f47e912e07b7433 100755 (executable)
@@ -1,6 +1,7 @@
 // Author: Dwivedi, Ajay kumar\r
 //            Adwiv@Yahoo.com\r
 using System;\r
+using System.Xml;\r
 \r
 namespace System.Xml.Schema\r
 {\r
@@ -9,8 +10,31 @@ namespace System.Xml.Schema
        /// </summary>\r
        public class XmlSchemaUnique : XmlSchemaIdentityConstraint\r
        {\r
+               private int errorCount;\r
+\r
                public XmlSchemaUnique()\r
                {\r
                }\r
+               /// <remarks>\r
+               /// 1. name must be present\r
+               /// 2. selector and field must be present\r
+               /// </remarks>\r
+               [MonoTODO]\r
+               internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               {\r
+                       return base.Compile(h,info);\r
+               }\r
+               \r
+               [MonoTODO]\r
+               internal int Validate(ValidationEventHandler h)\r
+               {\r
+                       return errorCount;\r
+               }\r
+\r
+               internal new void error(ValidationEventHandler handle, string message)\r
+               {\r
+                       errorCount++;\r
+                       ValidationHandler.RaiseValidationError(handle, this, message);\r
+               }\r
        }\r
 }\r
index ef1db7614d57d6a85766230d92c18db97ef94dc9..337e15ea6862efdce7bfd324755ce14fd775326a 100755 (executable)
@@ -1,4 +1,5 @@
 using System;\r
+using System.Xml;\r
 \r
 namespace System.Xml.Schema\r
 {\r
@@ -14,6 +15,12 @@ namespace System.Xml.Schema
                public static bool CheckID(string id)\r
                {\r
                        //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID\r
+                       // 1. ID must be a NCName\r
+                       // 2. ID must be unique in the schema\r
+                       if(!CheckNCName(id)) \r
+                               return false;\r
+                       //If !unique\r
+\r
                        return true;\r
                }\r
                [MonoTODO]\r
@@ -35,7 +42,25 @@ namespace System.Xml.Schema
                public static bool CheckNCName(string name)\r
                {\r
                        //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#NCName\r
-                       return true;\r
+                       try\r
+                       {\r
+                               XmlConvert.VerifyNCName(name);\r
+                               return true;\r
+                       }\r
+                       catch(Exception ex)\r
+                       {\r
+                               return false;\r
+                       }\r
+               }\r
+               public static string[] SplitList(string ns)\r
+               {\r
+                       return ns.Split(new char[]{' '});\r
+               }\r
+\r
+               // To Be Removed\r
+               public static XmlQualifiedName GetRandomQName()\r
+               {\r
+                       return new XmlQualifiedName(new Random().Next(int.MaxValue).ToString());\r
                }\r
        }\r
 }\r