2004-01-08 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 7 Jan 2004 17:58:48 +0000 (17:58 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 7 Jan 2004 17:58:48 +0000 (17:58 -0000)
* XmlSchemaElement.cs : Fixed incorrect unique particle attribution
  check on ##other and target namespace element.

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

mcs/class/System.XML/System.Xml.Schema/ChangeLog
mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs

index 1b11591d19b73c398a3c035d6873a0f0bc53523c..a16f47f83129a7fa1446487632c92c3877fff248 100755 (executable)
@@ -1,3 +1,8 @@
+2004-01-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaElement.cs : Fixed incorrect unique particle attribution
+         check on ##other and target namespace element.
+
 2004-01-08  Nick Drochak <ndrochak@ieee.org>
 
        * XmlSchemaSimpleType.cs: Needed a 'new' on the property
index 71ff9360b58b59edc09c72a9d81bef971ff42c57..25d82000e857010c48ecc2269ad3a899595d3bfd 100755 (executable)
@@ -36,7 +36,6 @@ namespace System.Xml.Schema
                private XmlQualifiedName schemaTypeName;\r
                private XmlQualifiedName substitutionGroup;\r
                internal bool parentIsSchema = false;\r
-               private string targetNamespace;\r
                private string validatedDefaultValue;\r
                private string validatedFixedValue;\r
                internal bool actualIsAbstract;\r
@@ -281,7 +280,6 @@ namespace System.Xml.Schema
                ///             5. abstract is prohibited\r
                ///             6. default and fixed must not both be present.(Actually both are absent)\r
                /// </remarks>  \r
-               [MonoTODO]\r
                internal override int Compile(ValidationEventHandler h, XmlSchema schema)\r
                {\r
                        // If this is already compiled this time, simply skip.\r
@@ -370,42 +368,23 @@ namespace System.Xml.Schema
                                        error(h,"substitutionGroup must be absent");\r
                                if(final != XmlSchemaDerivationMethod.None)\r
                                        error(h,"final must be absent");\r
-                               // This is not W3C REC 3.3.3 requirement\r
-//                             if(isAbstract)\r
-//                                     error(h,"abstract must be absent");\r
 \r
                                CompileOccurence (h, schema);\r
 \r
                                if(refName == null || RefName.IsEmpty)\r
                                {\r
+                                       string targetNamespace = String.Empty;\r
+\r
                                        if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && schema.ElementFormDefault == XmlSchemaForm.Qualified))\r
-                                               this.targetNamespace = schema.TargetNamespace;\r
-                                       else\r
-                                               this.targetNamespace = "";\r
+                                               targetNamespace = schema.TargetNamespace;\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
+                                               this.qName = new XmlQualifiedName(this.name, targetNamespace);\r
                                \r
-                                       /*\r
-                                       XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension | \r
-                                               XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;\r
-\r
-                                       if(block == XmlSchemaDerivationMethod.All)\r
-                                               blockResolved = allblock;\r
-//                                     else if(block == XmlSchemaDerivationMethod.None)\r
-//                                             blockResolved = allblock;\r
-                                       else\r
-                                       {\r
-                                               if((block & ~allblock) != 0)\r
-                                                       warn(h,"Some of the values for block are invalid in this context");\r
-                                               blockResolved = block & allblock;\r
-                                       }\r
-                                       */\r
-\r
                                        if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)\r
                                        {\r
                                                error(h,"both schemaType and content can't be present");\r
@@ -501,7 +480,6 @@ namespace System.Xml.Schema
                        return errorCount;\r
                }\r
 \r
-               [MonoTODO]\r
                internal override int Validate(ValidationEventHandler h, XmlSchema schema)\r
                {\r
                        if (IsValidated (schema.CompilationId))\r
@@ -756,11 +734,11 @@ namespace System.Xml.Schema
                                                continue;\r
                                        if (any.HasValueAny ||\r
                                                any.HasValueLocal && this.QualifiedName.Namespace == "" ||\r
-                                               any.HasValueOther && this.QualifiedName.Namespace != this.targetNamespace ||\r
-                                               any.HasValueTargetNamespace && this.QualifiedName.Namespace == this.targetNamespace) {\r
+                                               any.HasValueOther && this.QualifiedName.Namespace != this.QualifiedName.Namespace ||\r
+                                               any.HasValueTargetNamespace && this.QualifiedName.Namespace == this.QualifiedName.Namespace) {\r
                                                error (h, "Ambiguous element label which is contained by -any- particle was detected: " + this.QualifiedName);\r
                                                break;\r
-                                       } else {\r
+                                       } else if (!any.HasValueOther) {\r
                                                bool bad = false;\r
                                                foreach (string ns in any.ResolvedNamespaces) {\r
                                                        if (ns == this.QualifiedName.Namespace) {\r
@@ -772,6 +750,10 @@ namespace System.Xml.Schema
                                                        error (h, "Ambiguous element label which is contained by -any- particle was detected: " + this.QualifiedName);\r
                                                        break;\r
                                                }\r
+                                       } else {\r
+                                               if (any.TargetNamespace.Length == 0 ||\r
+                                                       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
                                qnames.Add (this.QualifiedName, this);\r