2004-01-22 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 22 Jan 2004 16:31:31 +0000 (16:31 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 22 Jan 2004 16:31:31 +0000 (16:31 -0000)
* BuiltInDatatype.cs : On parsing QName, we don't have to spend costs
  on Add()ing parsed name to name table.
* XmlSchemaUtil.cs : Added IsBuiltInDatatypeName().
* XmlSchemaAttribute.cs, XmlSchemaComplexType.cs,
  XmlSchemaElement.cs, XmlSchemaSimpleContentExtension.cs,
  XmlSchemaSimpleContentRestriction.cs, XmlSchemaSimpleTypeList.cs :
  Use the method above instead of Namespace string comparison.
  (it will be required to validate schema for schemas.)
* XmlSchemaComplexType.cs : Type Derivation OK (3.4.6) should also
  treat null base type as anyType.  Derivation Valid Restriction
  (3.4.6) should allow base type wildcard absense in case of anyType.

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

mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
mcs/class/System.XML/System.Xml.Schema/ChangeLog
mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.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/XmlSchemaSimpleContentExtension.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs

index 3542ce8edc651d6e94654b425d82e248724073e8..b9f1f98100edddfdbd59ad25b71a78c095279f36 100644 (file)
@@ -1229,8 +1229,8 @@ namespace Mono.Xml.Schema
                        if (nsmgr == null)\r
                                throw new ArgumentNullException ("namespace manager");\r
                        int colonAt = s.IndexOf (':');\r
-                       string localName = \r
-                               nameTable.Add (colonAt < 0 ? s : s.Substring (colonAt + 1));\r
+                       string localName = colonAt < 0 ? s : s.Substring (colonAt + 1);\r
+//                     string localName = nameTable.Add (colonAt < 0 ? s : s.Substring (colonAt + 1));\r
                        return new XmlQualifiedName (localName, nsmgr.LookupNamespace (\r
                                colonAt < 0 ? "" : s.Substring (0, colonAt - 1)));\r
                }\r
index 17b38a10c94d8e710d691fc622801deea5d1dc08..32d76d1f648cafb085db17fc927b62998d09abf4 100755 (executable)
@@ -1,3 +1,17 @@
+2004-01-22  Atsushi Enomoto <atsushi@ximian.com>
+
+       * BuiltInDatatype.cs : On parsing QName, we don't have to spend costs
+         on Add()ing parsed name to name table.
+       * XmlSchemaUtil.cs : Added IsBuiltInDatatypeName().
+       * XmlSchemaAttribute.cs, XmlSchemaComplexType.cs, 
+         XmlSchemaElement.cs, XmlSchemaSimpleContentExtension.cs,
+         XmlSchemaSimpleContentRestriction.cs, XmlSchemaSimpleTypeList.cs :
+         Use the method above instead of Namespace string comparison.
+         (it will be required to validate schema for schemas.)
+       * XmlSchemaComplexType.cs : Type Derivation OK (3.4.6) should also
+         treat null base type as anyType.  Derivation Valid Restriction 
+         (3.4.6) should allow base type wildcard absense in case of anyType.
+
 2004-01-22  Atsushi Enomoto <atsushi@ximian.com>
 
        * XmlSchema.cs : When we have schema A which includes schema B which
index d6f30f5f7888d0f3da2389a130f4eca90d39e291..4307bd5d70e6ee01f34a8ee30d514ca0dacb6b72 100755 (executable)
@@ -334,7 +334,7 @@ namespace System.Xml.Schema
                                }\r
                                else if (SchemaTypeName == XmlSchemaComplexType.AnyTypeName)\r
                                        attributeType = XmlSchemaComplexType.AnyType;
-                               else if (SchemaTypeName.Namespace == XmlSchema.Namespace) {\r
+                               else if (XmlSchemaUtil.IsBuiltInDatatypeName (SchemaTypeName)) {\r
                                        attributeType = XmlSchemaDatatype.FromName (SchemaTypeName);\r
                                        if (attributeType == null)\r
                                                error (h, "Invalid xml schema namespace datatype was specified.");\r
index 2d1a2ebdbc9b22ddca3f6a20d440f56cce591c25..a7f4110578692f51398b31d21ca274304f46d5f3 100755 (executable)
@@ -662,7 +662,7 @@ namespace System.Xml.Schema
                                this.DatatypeInternal = baseType.Datatype;\r
                        } else if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)\r
                                DatatypeInternal = XmlSchemaSimpleType.AnySimpleType;
-                       else if (BaseSchemaTypeName.Namespace == XmlSchema.Namespace) {\r
+                       else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName)) {\r
                                DatatypeInternal = XmlSchemaDatatype.FromName (BaseSchemaTypeName);\r
                        }\r
 \r
@@ -684,7 +684,7 @@ namespace System.Xml.Schema
                                // base\r
                                if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)\r
                                        baseComplexType = XmlSchemaComplexType.AnyType;\r
-                               else if (BaseSchemaTypeName.Namespace == XmlSchema.Namespace)\r
+                               else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName))\r
                                        error (h, "Referenced base schema type is XML Schema datatype.");\r
                                else if (baseComplexType == null && !schema.IsNamespaceAbsent (BaseSchemaTypeName.Namespace))\r
                                        error (h, "Referenced base schema type " + BaseSchemaTypeName + " was not complex type or not found in the corresponding schema.");\r
@@ -703,9 +703,7 @@ namespace System.Xml.Schema
                                        error (h, "Base schema complex type of a simple content must be simple content type. Base type is " + BaseSchemaTypeName);\r
                                } else if (sce == null && (baseSimpleType != null && BaseSchemaTypeName.Namespace != XmlSchema.Namespace)) {\r
                                        error (h, "If a simple content is not an extension, base schema type must be complex type. Base type is " + BaseSchemaTypeName);\r
-                               } else if (BaseSchemaTypeName.Namespace == XmlSchema.Namespace) {\r
-                                       if (XmlSchemaDatatype.FromName (BaseSchemaTypeName) == null)\r
-                                               error (h, "Invalid schema data type was specified: " + BaseSchemaTypeName);\r
+                               } else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName)) {\r
                                        // do nothing for particle.\r
                                }\r
                                // otherwise, it might be missing sub components.\r
@@ -855,7 +853,7 @@ namespace System.Xml.Schema
                                error (h, "Derivation type " + resolvedDerivedBy + " is prohibited by the base type.");\r
                        if (BaseXmlSchemaType == b) // 2.2\r
                                return;\r
-                       if (BaseXmlSchemaType == XmlSchemaComplexType.AnyType) { // 2.3.1\r
+                       if (BaseXmlSchemaType == null || BaseXmlSchemaType == XmlSchemaComplexType.AnyType) { // 2.3.1\r
                                error (h, "Derived type's base schema type is anyType.");\r
                                return;\r
                        }\r
@@ -987,7 +985,7 @@ namespace System.Xml.Schema
                        }\r
                        // I think 3. is considered in 2.\r
                        // 4.\r
-                       if (this.AttributeWildcard != null) {\r
+                       if (this.AttributeWildcard != null && baseType != XmlSchemaComplexType.AnyType) {\r
                                if (baseType.AttributeWildcard == null)\r
                                        error (h, "Invalid attribute derivation by restriction because of attribute wildcard.");\r
                                else\r
index 6cd705008d9eeb0316666153cde6711933f72182..1066ff7bad6f1ac1f40fae7589a8d82a1b17764f 100755 (executable)
@@ -58,7 +58,6 @@ namespace System.Xml.Schema
                        refName = XmlQualifiedName.Empty;\r
                        schemaTypeName = XmlQualifiedName.Empty;\r
                        substitutionGroup = XmlQualifiedName.Empty;\r
-                       substitutionGroup = XmlQualifiedName.Empty;\r
                }\r
 \r
                #region Attributes\r
@@ -599,7 +598,7 @@ namespace System.Xml.Schema
                                }\r
                                else if (SchemaTypeName == XmlSchemaComplexType.AnyTypeName)\r
                                        elementType = XmlSchemaComplexType.AnyType;
-                               else if (SchemaTypeName.Namespace == XmlSchema.Namespace) {\r
+                               else if (XmlSchemaUtil.IsBuiltInDatatypeName (SchemaTypeName)) {\r
                                        datatype = XmlSchemaDatatype.FromName (SchemaTypeName);\r
                                        if (datatype == null)\r
                                                error (h, "Invalid schema datatype was specified.");\r
index 959b5f6ab00875be661ecb487c6154b2a14ec048..89f935189acb401f9423b81676b250a2fd347687 100755 (executable)
@@ -130,7 +130,7 @@ namespace System.Xml.Schema
                                actualBaseSchemaType = st;\r
                        } else if (baseTypeName == XmlSchemaComplexType.AnyTypeName) {\r
                                actualBaseSchemaType = XmlSchemaComplexType.AnyType;
-                       } else if (baseTypeName.Namespace == XmlSchema.Namespace) {\r
+                       } else if (XmlSchemaUtil.IsBuiltInDatatypeName (baseTypeName)) {\r
                                actualBaseSchemaType = XmlSchemaDatatype.FromName (baseTypeName);\r
                                if (actualBaseSchemaType == null)\r
                                        error (h, "Invalid schema datatype name is specified.");\r
index d9168fdfc98363a17aaedd0291d2640fde8a3bc9..eda9827908c165181419e973591935dbe9dc3c04 100755 (executable)
@@ -161,7 +161,7 @@ namespace System.Xml.Schema
                                        actualBaseSchemaType = st;\r
                                } else if (baseTypeName == XmlSchemaComplexType.AnyTypeName) {\r
                                        actualBaseSchemaType = XmlSchemaComplexType.AnyType;
-                               } else if (baseTypeName.Namespace == XmlSchema.Namespace) {\r
+                               } else if (XmlSchemaUtil.IsBuiltInDatatypeName (baseTypeName)) {\r
                                        actualBaseSchemaType = XmlSchemaDatatype.FromName (baseTypeName);\r
                                        if (actualBaseSchemaType == null)\r
                                                error (h, "Invalid schema datatype name is specified.");\r
index 7f18e367ad4e61555dc4f05ec8aa67f2d8d4ac09..8c0c9d0bcf4ea7fcd1c3dd7cea47b46980d7f357 100755 (executable)
@@ -92,7 +92,7 @@ namespace System.Xml.Schema
                                validatedListItemType = type;\r
                        } else if (itemTypeName == XmlSchemaComplexType.AnyTypeName) {\r
                                validatedListItemType = XmlSchemaSimpleType.AnySimpleType;
-                       } else if (itemTypeName.Namespace == XmlSchema.Namespace) {\r
+                       } else if (XmlSchemaUtil.IsBuiltInDatatypeName (itemTypeName)) {\r
                                validatedListItemType = XmlSchemaDatatype.FromName (itemTypeName);\r
                                if (validatedListItemType == null)\r
                                        error (h, "Invalid schema type name was specified: " + itemTypeName);\r
index 17c2669413a46d69fd9238e5f3878fde9a8276c8..b667450529cf8a5c57d60319bba61bd10de70de6 100755 (executable)
@@ -13,7 +13,7 @@ namespace System.Xml.Schema
        /// </summary>\r
        internal class XmlSchemaUtil\r
        {\r
-               static XmlSchemaUtil()\r
+               static XmlSchemaUtil ()\r
                {\r
                        FinalAllowed = XmlSchemaDerivationMethod.Restriction | \r
                                XmlSchemaDerivationMethod.Extension;\r
@@ -82,11 +82,6 @@ namespace System.Xml.Schema
                        return true;\r
                }\r
 \r
-//             public static bool CheckLanguage(string lang)\r
-//             {\r
-                       //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#language\r
-//                     return true;\r
-//             }\r
                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
@@ -117,6 +112,38 @@ namespace System.Xml.Schema
                        throw new NotSupportedException ("XmlParserContext cannot be acquired from this XmlReader.");\r
                }\r
 \r
+               public static bool IsBuiltInDatatypeName (XmlQualifiedName qname)\r
+               {\r
+                       if (qname.Namespace != XmlSchema.Namespace)\r
+                               return false;\r
+                       switch (qname.Name) {\r
+                       case "anySimpleType":\r
+                       case "duration": case "dateTime": case "time":\r
+                       case "date": case "gYearMonth": case "gYear":\r
+                       case "gMonthDay": case "gDay": case "gMonth":\r
+                       case "boolean":\r
+                       case "base64Binary": case "hexBinary":\r
+                       case "float": case "double":\r
+                       case "anyURI":\r
+                       case "QName":\r
+                       case "NOTATION":\r
+                       case "string": case "normalizedString": case "token":\r
+                       case "language": case "Name": case "NCName":\r
+                       case "ID": case "IDREF": case "IDREFS":\r
+                       case "ENTITY": case "ENTITIES":\r
+                       case "NMTOKEN": case "NMTOKENS":\r
+                       case "decimal": case "integer":\r
+                       case "nonPositiveInteger": case "negativeInteger":\r
+                       case "nonNegativeInteger":\r
+                       case "unsignedLong": case "unsignedInt":\r
+                       case "unsignedShort": case "unsignedByte":\r
+                       case "positiveInteger":\r
+                       case "long": case "int": case "short": case "byte":\r
+                               return true;\r
+                       }\r
+                       return false;\r
+               }\r
+\r
                public static bool IsSchemaDatatypeEquals (XsdAnySimpleType st1, object v1,
                        XsdAnySimpleType st2, object v2)
                {