2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaElement.cs
index 2f040b807181235c485bef2bfb2748bfa38028cd..944a2709d1452f007b757db72e3919b0bd45a7f8 100644 (file)
@@ -151,7 +151,7 @@ namespace System.Xml.Schema
                        set{ form = value; }\r
                }\r
 \r
-               [DefaultValue(null)]\r
+               [DefaultValue("")]\r
                [System.Xml.Serialization.XmlAttribute("name")]\r
                public string Name \r
                {\r
@@ -191,17 +191,17 @@ namespace System.Xml.Schema
 \r
                #region Elements\r
 \r
-               [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]\r
-               [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]\r
+               [XmlElement("simpleType",typeof(XmlSchemaSimpleType))]\r
+               [XmlElement("complexType",typeof(XmlSchemaComplexType))]\r
                public XmlSchemaType SchemaType \r
                {\r
                        get{ return  schemaType; }\r
                        set{ schemaType = value; }\r
                }\r
 \r
-               [XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]\r
-               [XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]\r
-               [XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]\r
+               [XmlElement("unique",typeof(XmlSchemaUnique))]\r
+               [XmlElement("key",typeof(XmlSchemaKey))]\r
+               [XmlElement("keyref",typeof(XmlSchemaKeyref))]\r
                public XmlSchemaObjectCollection Constraints \r
                {\r
                        get{ return constraints; }\r
@@ -350,7 +350,7 @@ namespace System.Xml.Schema
                internal override int Compile(ValidationEventHandler h, XmlSchema schema)\r
                {\r
                        // If this is already compiled this time, simply skip.\r
-                       if (this.IsComplied (schema.CompilationId))\r
+                       if (CompilationId == schema.CompilationId)\r
                                return 0;\r
                        InitPostCompileInformations ();\r
                        this.schema = schema;\r
@@ -653,7 +653,7 @@ namespace System.Xml.Schema
                        if (schemaType != null)\r
                                elementType = schemaType;\r
                        else if (SchemaTypeName != XmlQualifiedName.Empty) {\r
-                               XmlSchemaType type = schema.SchemaTypes [SchemaTypeName] as XmlSchemaType;\r
+                               XmlSchemaType type = schema.FindSchemaType (SchemaTypeName);\r
                                if (type != null) {\r
                                        type.Validate (h, schema);\r
                                        elementType = type;\r
@@ -743,9 +743,13 @@ namespace System.Xml.Schema
                                ident.Validate (h, schema);\r
 \r
 #if NET_2_0\r
-                       elementSchemaType = elementType as XmlSchemaType;\r
-                       if (elementSchemaType == null && elementType != null)\r
-                               elementSchemaType = XmlSchemaType.GetBuiltInType (((XmlSchemaDatatype) elementType).TypeCode);\r
+                       if (elementType != null) {\r
+                               elementSchemaType = elementType as XmlSchemaType;\r
+                               if (elementType == XmlSchemaSimpleType.AnySimpleType)\r
+                                       elementSchemaType = XmlSchemaSimpleType.XsAnySimpleType;\r
+                               if (elementSchemaType == null)\r
+                                       elementSchemaType = XmlSchemaType.GetBuiltInSimpleType (SchemaTypeName);\r
+                       }\r
 #endif\r
 \r
                        ValidationId = schema.ValidationId;\r
@@ -918,8 +922,7 @@ namespace System.Xml.Schema
                                                        break;\r
                                                }\r
                                        } else {\r
-                                               if (any.TargetNamespace.Length == 0 ||\r
-                                                       any.TargetNamespace != this.QualifiedName.Namespace)\r
+                                               if (any.TargetNamespace != this.QualifiedName.Namespace)\r
                                                        error (h, "Ambiguous element label which is contained by -any- particle with ##other value was detected: " + this.QualifiedName);\r
                                        }\r
                                }\r