diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-12-08 09:56:12 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-12-08 09:56:12 +0300 |
commit | 99c907944c8403aa060be61e4ae65f44c3806e0c (patch) | |
tree | 64c6094b5a06e2a0a6e35513c54ad49525cc8d73 /mcs/class/System.XML | |
parent | c2029b413fb6d6a690a34331cdc7b07a5a3015a8 (diff) |
2005-12-08 Atsushi Enomoto <atsushi@ximian.com>
* System.Xml.dll.sources : added XmlSchemaCompilationSettings.cs
* XmlReaderSettings.cs : thanks to idiotic MS design,
AllowXmlAttributes is turned on by default.
* XmlSchemaCompilationSettings.cs : new file.
* XmlSchemaSet.cs : added CompilationSettings property.
* XmlSchemaComplexType.cs : support for EnableUpaCheck.
* XmlReaderSettingsTests.cs : (DefaultValue)
Added assertion label everywhere.
* XmlWriterTests.cs : WriteNodeError is broken under MS.NET 2.0 (it
should cause an error).
* XmlSchemaSetTests.cs : added CompilationSettings tests.
svn path=/trunk/mcs/; revision=54094
Diffstat (limited to 'mcs/class/System.XML')
14 files changed, 144 insertions, 21 deletions
diff --git a/mcs/class/System.XML/ChangeLog b/mcs/class/System.XML/ChangeLog index a51bd00c911..8d18fe7bdb4 100644 --- a/mcs/class/System.XML/ChangeLog +++ b/mcs/class/System.XML/ChangeLog @@ -1,3 +1,7 @@ +2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + + * System.Xml.dll.sources : added XmlSchemaCompilationSettings.cs + 2055-12-01 Konstantin Triger <kostat@mainsoft.com> * Makefile: java profile reference change. diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog index 8dce9a6e518..bf263dec181 100644 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,5 +1,11 @@ 2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlSchemaCompilationSettings.cs : new file. + * XmlSchemaSet.cs : added CompilationSettings property. + * XmlSchemaComplexType.cs : support for EnableUpaCheck. + +2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlSchemaValidationException.cs : added SetSourceObject() which is just for API compat (it does nothing on MS.NET). Removed #if NET_2_0 inside #if NET_2_0. diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCompilationSettings.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCompilationSettings.cs new file mode 100644 index 00000000000..debd6655404 --- /dev/null +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCompilationSettings.cs @@ -0,0 +1,54 @@ +// +// XmlSchemaCompilationSettings.cs +// +// Author: +// Atsushi Enomoto <atsushi@ximian.com> +// +// Copyright (C) 2005 Novell, Inc. http://www.novell.com +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +#if NET_2_0 + +using System; +using System.Collections; +using System.Xml; +using System.Xml.Serialization; + +namespace System.Xml.Schema +{ + public sealed class XmlSchemaCompilationSettings + { + public XmlSchemaCompilationSettings () + { + } + + bool enable_upa_check = true; + + public bool EnableUpaCheck { + get { return enable_upa_check; } + set { enable_upa_check = value; } + } + } +} + +#endif diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs index 60d62ef7620..0807a8c37d0 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs @@ -599,6 +599,10 @@ namespace System.Xml.Schema error (h, "Particle whose term is -all- and consists of complex type content particle must have maxOccurs = 1.");
}
+#if NET_2_0
+ if (schema.Schemas.CompilationSettings.EnableUpaCheck)
+#endif
+ // This check is optional only after 2.0
contentTypeParticle.ValidateUniqueParticleAttribution (new XmlSchemaObjectTable (),
new ArrayList (), h, schema);
contentTypeParticle.ValidateUniqueTypeAttribution (
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs index 7202c50c673..99b808d9b8f 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs @@ -54,7 +54,10 @@ namespace System.Xml.Schema XmlSchemaObjectTable types; // XmlSchemaObjectTable attributeGroups; // XmlSchemaObjectTable groups; - + + XmlSchemaCompilationSettings settings = + new XmlSchemaCompilationSettings (); + XmlSchemaCollection col; ValidationEventHandler handler; @@ -116,6 +119,10 @@ namespace System.Xml.Schema get { return nameTable; } } + public XmlSchemaCompilationSettings CompilationSettings { + get { return settings; } + } + // This is mainly used for event delegating internal XmlSchemaCollection SchemaCollection { get { diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidationFlags.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidationFlags.cs index 5053499c935..144cfffa07d 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidationFlags.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidationFlags.cs @@ -38,9 +38,7 @@ namespace System.Xml.Schema ProcessSchemaLocation = 2, ReportValidationWarnings = 4,
ProcessIdentityConstraints = 8, - // LAMESPEC: It is really idiotic idea to include such - // validation option that breaks W3C XML Schema specification - // compliance and interoperability. + [Obsolete ("It is really idiotic idea to include such validation option that breaks W3C XML Schema specification compliance and interoperability.")] AllowXmlAttributes = 16, }
}
diff --git a/mcs/class/System.XML/System.Xml.dll.sources b/mcs/class/System.XML/System.Xml.dll.sources index e6afc9aa1db..26aa4233ef4 100644 --- a/mcs/class/System.XML/System.Xml.dll.sources +++ b/mcs/class/System.XML/System.Xml.dll.sources @@ -202,6 +202,7 @@ System.Xml.Schema/XmlSchemaAttributeGroupRef.cs System.Xml.Schema/XmlSchemaChoice.cs System.Xml.Schema/XmlSchemaCollection.cs System.Xml.Schema/XmlSchemaCollectionEnumerator.cs +System.Xml.Schema/XmlSchemaCompilationSettings.cs System.Xml.Schema/XmlSchemaComplexContent.cs System.Xml.Schema/XmlSchemaComplexContentExtension.cs System.Xml.Schema/XmlSchemaComplexContentRestriction.cs diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index ddd585fe542..343b1779c03 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,5 +1,10 @@ 2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlReaderSettings.cs : thanks to idiotic MS design, + AllowXmlAttributes is turned on by default. + +2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlReaderSettings.cs : set_Schemas() is fixed in 2.0 RTM (it just works). * XmlResolver.cs : throw ArgumentNullException instead of diff --git a/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs b/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs index cbf5691d2ad..08cbe9eba22 100644 --- a/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs +++ b/mcs/class/System.XML/System.Xml/XmlReaderSettings.cs @@ -100,7 +100,8 @@ namespace System.Xml prohibitDtd = true; schemas = new XmlSchemaSet (); validationFlags = - XsValidationFlags.ProcessIdentityConstraints; + XsValidationFlags.ProcessIdentityConstraints | + XsValidationFlags.AllowXmlAttributes; validationType = ValidationType.None; xmlResolver = new XmlUrlResolver (); } diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index a3ec769020c..3bcb2a82eca 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog @@ -1,3 +1,7 @@ +2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + + * XmlSchemaSetTests.cs : added CompilationSettings tests. + 2005-12-01 Atsushi Enomoto <atsushi@ximian.com> * XmlSchemaTests.cs : diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs index 3085e180a97..19342db345e 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs @@ -66,6 +66,34 @@ namespace MonoTests.System.Xml ss.Add ("ab", new XmlNodeReader (doc)); ss.Add ("ab", new XmlNodeReader (doc)); } + + [Test] + public void CompilationSettings () + { + Assert.IsNotNull (new XmlSchemaSet ().CompilationSettings); + } + + [Test] + public void DisableUpaCheck () + { + string schema = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'> + <xs:complexType name='Foo'> + <xs:sequence> + <xs:choice minOccurs='0'> + <xs:element name='el'/> + </xs:choice> + <xs:element name='el' /> + </xs:sequence> + </xs:complexType> +</xs:schema>"; + XmlSchema xs = XmlSchema.Read (new XmlTextReader ( + schema, XmlNodeType.Document, null), null); + XmlSchemaSet xss = new XmlSchemaSet (); + xss.Add (xs); + xss.CompilationSettings.EnableUpaCheck = false; + + xss.Compile (); + } } } #endif diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog index f89b48d0d68..1d4e8ea7e22 100644 --- a/mcs/class/System.XML/Test/System.Xml/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog @@ -1,5 +1,12 @@ 2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlReaderSettingsTests.cs : (DefaultValue) + Added assertion label everywhere. + * XmlWriterTests.cs : WriteNodeError is broken under MS.NET 2.0 (it + should cause an error). + +2005-12-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlReaderSettingsTests.cs : SetSchemas() should not cause an error. Added SetSchemasNull() as well. * XmlUrlResolverTests.cs : (ResolveUriWithNullArgs) diff --git a/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs index dace6789e22..0d5bda4ee3d 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlReaderSettingsTests.cs @@ -31,28 +31,29 @@ namespace MonoTests.System.Xml public void DefaultValue () { XmlReaderSettings s = new XmlReaderSettings (); - AssertEquals (true, s.CheckCharacters); - AssertEquals (ConformanceLevel.Document, + AssertEquals ("CheckCharacters", true, s.CheckCharacters); + AssertEquals ("ConformanceLevel", ConformanceLevel.Document, s.ConformanceLevel); - Assert (s.ValidationType != ValidationType.DTD); - AssertEquals (false, s.IgnoreComments); - Assert (0 == (s.ValidationFlags & + AssertEquals ("ValidationType", ValidationType.None, s.ValidationType); + AssertEquals ("IgnoreComments", false, s.IgnoreComments); + Assert ("ProcessInlineSchema", 0 == (s.ValidationFlags & ValidationFlags.ProcessInlineSchema)); - AssertEquals (false, s.IgnoreProcessingInstructions); - Assert (0 == (s.ValidationFlags & + AssertEquals ("IgnorePI", false, s.IgnoreProcessingInstructions); + Assert ("ProcessSchemaLocation", 0 == (s.ValidationFlags & ValidationFlags.ProcessSchemaLocation)); - Assert (0 == (s.ValidationFlags & + Assert ("ReportValidationWarnings", 0 == (s.ValidationFlags & ValidationFlags.ReportValidationWarnings)); - Assert (0 != (s.ValidationFlags & + Assert ("ProcessIdentityConstraints", 0 != (s.ValidationFlags & ValidationFlags.ProcessIdentityConstraints)); - Assert (0 == (s.ValidationFlags & + // No one should use this flag BTW if someone wants + // code to be conformant to W3C XML Schema standard. + Assert ("AllowXmlAttributes", 0 != (s.ValidationFlags & ValidationFlags.AllowXmlAttributes)); - AssertEquals (false, s.IgnoreWhitespace); - AssertEquals (0, s.LineNumberOffset); - AssertEquals (0, s.LinePositionOffset); - AssertNull (s.NameTable); - AssertEquals (0, s.Schemas.Count); - Assert (s.ValidationType != ValidationType.Schema); + AssertEquals ("IgnoreWhitespace", false, s.IgnoreWhitespace); + AssertEquals ("LineNumberOffset", 0, s.LineNumberOffset); + AssertEquals ("LinePositionOffset", 0, s.LinePositionOffset); + AssertNull ("NameTable", s.NameTable); + AssertEquals ("Schemas.Count", 0, s.Schemas.Count); } [Test] diff --git a/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs index 929d63c6e23..ef4dc43bac2 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs @@ -117,6 +117,9 @@ namespace MonoTests.System.Xml }
[Test]
+#if NET_2_0
+ [Category ("NotDotNet")] // enbugged in 2.0
+#endif
[ExpectedException (typeof (XmlException))]
public void WriteNodeError ()
{
|