2003-09-30 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaComplexContent.cs
index 20633c7f00f149e899fc3006c2f98cb3f5b1991a..b45c74435386ddddfd41ba968a5bdf26d43c351e 100755 (executable)
@@ -1,5 +1,10 @@
-// Author: Dwivedi, Ajay kumar\r
-//            Adwiv@Yahoo.com\r
+//\r
+// System.Xml.Schema.XmlSchemaComplexContent.cs\r
+//\r
+// Author:\r
+//     Dwivedi, Ajay kumar  Adwiv@Yahoo.com\r
+//     Atsushi Enomoto  ginga@kit.hi-ho.ne.jp\r
+//\r
 using System;\r
 using System.Xml.Serialization;\r
 using System.Xml;\r
@@ -18,14 +23,6 @@ namespace System.Xml.Schema
                public XmlSchemaComplexContent()\r
                {}\r
 \r
-               [XmlElement("restriction",typeof(XmlSchemaComplexContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]\r
-               [XmlElement("extension",typeof(XmlSchemaComplexContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]\r
-               public override XmlSchemaContent Content \r
-               {\r
-                       get{ return  content; } \r
-                       set{ content = value; }\r
-               }\r
-\r
                [System.Xml.Serialization.XmlAttribute("mixed")]\r
                public bool IsMixed \r
                {\r
@@ -33,12 +30,31 @@ namespace System.Xml.Schema
                        set{ isMixed = value; }\r
                }\r
 \r
+               [XmlElement("restriction",typeof(XmlSchemaComplexContentRestriction),Namespace=XmlSchema.Namespace)]\r
+               [XmlElement("extension",typeof(XmlSchemaComplexContentExtension),Namespace=XmlSchema.Namespace)]\r
+               public override XmlSchemaContent Content \r
+               {\r
+                       get{ return  content; } \r
+                       set{ content = value; }\r
+               }\r
+\r
                /// <remarks>\r
                /// 1. Content must be present\r
                /// </remarks>\r
                [MonoTODO]\r
-               internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+               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
+                               return 0;\r
+\r
+                       if (isRedefinedComponent) {\r
+                               if (Annotation != null)\r
+                                       Annotation.isRedefinedComponent = true;\r
+                               if (Content != null)\r
+                                       Content.isRedefinedComponent = true;\r
+                       }\r
+\r
                        if(Content == null)\r
                        {\r
                                error(h, "Content must be present in a complexContent");\r
@@ -48,26 +64,32 @@ namespace System.Xml.Schema
                                if(Content is XmlSchemaComplexContentRestriction)\r
                                {\r
                                        XmlSchemaComplexContentRestriction xscr = (XmlSchemaComplexContentRestriction) Content;\r
-                                       errorCount += xscr.Compile(h,info);\r
+                                       errorCount += xscr.Compile(h, schema);\r
                                }\r
                                else if(Content is XmlSchemaComplexContentExtension)\r
                                {\r
                                        XmlSchemaComplexContentExtension xsce = (XmlSchemaComplexContentExtension) Content;\r
-                                       errorCount += xsce.Compile(h,info);\r
+                                       errorCount += xsce.Compile(h, schema);\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
+                       XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);\r
 \r
+                       this.CompilationId = schema.CompilationId;\r
                        return errorCount;\r
                }\r
                \r
                [MonoTODO]\r
-               internal int Validate(ValidationEventHandler h)\r
+               internal override int Validate(ValidationEventHandler h, XmlSchema schema)\r
                {\r
+                       if (IsValidated (schema.ValidationId))\r
+                               return errorCount;\r
+\r
+                       errorCount += Content.Validate (h, schema);\r
+\r
+                       ValidationId = schema.ValidationId;\r
                        return errorCount;\r
                }\r
                //<complexContent\r
@@ -105,13 +127,13 @@ namespace System.Xml.Schema
                                        if(innerex != null)\r
                                                error(h,reader.Value + " is an invalid value for mixed",innerex);\r
                                }\r
-                               else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)\r
+                               else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)\r
                                {\r
                                        error(h,reader.Name + " is not a valid attribute for complexContent",null);\r
                                }\r
                                else\r
                                {\r
-                                       //TODO: Add to Unhandled attributes\r
+                                       XmlSchemaUtil.ReadUnhandledAttribute(reader,complex);\r
                                }\r
                        }\r
                        \r