Author: atsushi Date: 2008-02-19 10:59:12 -0500 (Tue, 19 Feb 2008) New Revision: 96159
Added: trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-2.xsd trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-3.xsd trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818.xsd Modified: trunk/mcs/class/System.XML/ChangeLog trunk/mcs/class/System.XML/Makefile trunk/mcs/class/System.XML/System.Xml.Schema/ChangeLog trunk/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs trunk/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog trunk/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs trunk/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog Log: 2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> * XmlSchema.cs : Do recursively process xs:include inside included schemas. Fixed bug #361818. * XmlSchemaTests.cs: added test for bug #361818. * 361818.xsd, 361818-2.xsd, 361818-3.xsd : new test files. * Makefile : extra distfiles (361818*.xsd). Modified: trunk/mcs/class/System.XML/ChangeLog =================================================================== --- trunk/mcs/class/System.XML/ChangeLog 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/ChangeLog 2008-02-19 15:59:12 UTC (rev 96159) @@ -1,5 +1,9 @@ 2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> + * Makefile : extra distfiles (361818*.xsd). + +2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> + * System.Xml_test.dll.sources: added XmlSchemasTests.cs. 2008-02-04 Atsushi Enomoto <[EMAIL PROTECTED]> Modified: trunk/mcs/class/System.XML/Makefile =================================================================== --- trunk/mcs/class/System.XML/Makefile 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Makefile 2008-02-19 15:59:12 UTC (rev 96159) @@ -74,6 +74,9 @@ Test/XmlFiles/xsd/datatypesTest.xsd \ Test/XmlFiles/xsd/336625.xsd \ Test/XmlFiles/xsd/358408.xsd \ + Test/XmlFiles/xsd/361818.xsd \ + Test/XmlFiles/xsd/361818-2.xsd \ + Test/XmlFiles/xsd/361818-3.xsd \ Test/XmlFiles/xsd/77687.xsd \ Test/XmlFiles/xsd/77687inc.xsd \ Test/XmlFiles/xsd/78985.xml \ Modified: trunk/mcs/class/System.XML/System.Xml.Schema/ChangeLog =================================================================== --- trunk/mcs/class/System.XML/System.Xml.Schema/ChangeLog 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/System.Xml.Schema/ChangeLog 2008-02-19 15:59:12 UTC (rev 96159) @@ -1,5 +1,10 @@ 2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> + * XmlSchema.cs : Do recursively process xs:include inside included + schemas. Fixed bug #361818. + +2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> + * XmlSchemaAny.cs : block extra compilation in anyTypeContent. 2008-02-04 Atsushi Enomoto <[EMAIL PROTECTED]> Modified: trunk/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs =================================================================== --- trunk/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs 2008-02-19 15:59:12 UTC (rev 96159) @@ -367,94 +367,9 @@ // First, we run into inclusion schemas to collect // compilation target items into compiledItems. - for (int i = 0; i < Includes.Count; i++) { - XmlSchemaExternal ext = Includes [i] as XmlSchemaExternal; - if (ext == null) { - error (handler, String.Format ("Object of Type {0} is not valid in Includes Property of XmlSchema", Includes [i].GetType().Name)); - continue; - } + for (int i = 0; i < Includes.Count; i++) + ProcessExternal (handler, handledUris, resolver, Includes [i] as XmlSchemaExternal); - if (ext.SchemaLocation == null) - continue; - - Stream stream = null; - string url = null; - if (resolver != null) { - url = GetResolvedUri (resolver, ext.SchemaLocation); - if (handledUris.Contains (url)) - // This schema is already handled, so simply skip (otherwise, duplicate definition errrors occur. - continue; - handledUris.Add (url, url); - try { - stream = resolver.GetEntity (new Uri (url), null, typeof (Stream)) as Stream; - } catch (Exception) { - // LAMESPEC: This is not good way to handle errors, but since we cannot know what kind of XmlResolver will come, so there are no mean to avoid this ugly catch. - warn (handler, "Could not resolve schema location URI: " + url); - stream = null; - } - } - - // Process redefinition children in advance. - XmlSchemaRedefine redefine = Includes [i] as XmlSchemaRedefine; - if (redefine != null) { - for (int j = 0; j < redefine.Items.Count; j++) { - XmlSchemaObject redefinedObj = redefine.Items [j]; - redefinedObj.isRedefinedComponent = true; - redefinedObj.isRedefineChild = true; - if (redefinedObj is XmlSchemaType || - redefinedObj is XmlSchemaGroup || - redefinedObj is XmlSchemaAttributeGroup) - compilationItems.Add (redefinedObj); - else - error (handler, "Redefinition is only allowed to simpleType, complexType, group and attributeGroup."); - } - } - - XmlSchema includedSchema = null; - if (stream == null) { - // It is missing schema components. - missedSubComponents = true; - continue; - } else { - XmlTextReader xtr = null; - try { - xtr = new XmlTextReader (url, stream, nameTable); - includedSchema = XmlSchema.Read (xtr, handler); - } finally { - if (xtr != null) - xtr.Close (); - } - includedSchema.schemas = schemas; - } - includedSchema.SetParent (); - ext.Schema = includedSchema; - - // Set - actual - target namespace for the included schema * before compilation*. - XmlSchemaImport import = ext as XmlSchemaImport; - if (import != null) { - if (TargetNamespace == includedSchema.TargetNamespace) { - error (handler, "Target namespace must be different from that of included schema."); - continue; - } else if (includedSchema.TargetNamespace != import.Namespace) { - error (handler, "Attribute namespace and its importing schema's target namespace must be the same."); - continue; - } - } else { - if (TargetNamespace == null && - includedSchema.TargetNamespace != null) { - error (handler, "Target namespace is required to include a schema which has its own target namespace"); - continue; - } - else if (TargetNamespace != null && - includedSchema.TargetNamespace == null) - includedSchema.TargetNamespace = TargetNamespace; - } - - // Do not compile included schema here. - - AddExternalComponentsTo (includedSchema, compilationItems); - } - // Compilation phase. // At least each Compile() must give unique (qualified) name for each component. // It also checks self-resolvable properties correctness. @@ -557,11 +472,102 @@ return abs != null ? abs.ToString () : String.Empty; } - void AddExternalComponentsTo (XmlSchema s, XmlSchemaObjectCollection items) + void ProcessExternal (ValidationEventHandler handler, Hashtable handledUris, XmlResolver resolver, XmlSchemaExternal ext) { + if (ext == null) { + error (handler, String.Format ("Object of Type {0} is not valid in Includes Property of XmlSchema", ext.GetType().Name)); + return; + } + + if (ext.SchemaLocation == null) + return; +// if (ext.Schema != null) // already read +// return; + + Stream stream = null; + string url = null; + if (resolver != null) { + url = GetResolvedUri (resolver, ext.SchemaLocation); + if (handledUris.Contains (url)) + // This schema is already handled, so simply skip (otherwise, duplicate definition errrors occur. + return; + handledUris.Add (url, url); + try { + stream = resolver.GetEntity (new Uri (url), null, typeof (Stream)) as Stream; + } catch (Exception) { + // LAMESPEC: This is not good way to handle errors, but since we cannot know what kind of XmlResolver will come, so there are no mean to avoid this ugly catch. + warn (handler, "Could not resolve schema location URI: " + url); + stream = null; + } + } + + // Process redefinition children in advance. + XmlSchemaRedefine redefine = ext as XmlSchemaRedefine; + if (redefine != null) { + for (int j = 0; j < redefine.Items.Count; j++) { + XmlSchemaObject redefinedObj = redefine.Items [j]; + redefinedObj.isRedefinedComponent = true; + redefinedObj.isRedefineChild = true; + if (redefinedObj is XmlSchemaType || + redefinedObj is XmlSchemaGroup || + redefinedObj is XmlSchemaAttributeGroup) + compilationItems.Add (redefinedObj); + else + error (handler, "Redefinition is only allowed to simpleType, complexType, group and attributeGroup."); + } + } + + XmlSchema includedSchema = null; + if (stream == null) { + // It is missing schema components. + missedSubComponents = true; + return; + } else { + XmlTextReader xtr = null; + try { + xtr = new XmlTextReader (url, stream, nameTable); + includedSchema = XmlSchema.Read (xtr, handler); + } finally { + if (xtr != null) + xtr.Close (); + } + includedSchema.schemas = schemas; + } + includedSchema.SetParent (); + ext.Schema = includedSchema; + + // Set - actual - target namespace for the included schema * before compilation*. + XmlSchemaImport import = ext as XmlSchemaImport; + if (import != null) { + if (TargetNamespace == includedSchema.TargetNamespace) { + error (handler, "Target namespace must be different from that of included schema."); + return; + } else if (includedSchema.TargetNamespace != import.Namespace) { + error (handler, "Attribute namespace and its importing schema's target namespace must be the same."); + return; + } + } else { + if (TargetNamespace == null && + includedSchema.TargetNamespace != null) { + error (handler, "Target namespace is required to include a schema which has its own target namespace"); + return; + } + else if (TargetNamespace != null && + includedSchema.TargetNamespace == null) + includedSchema.TargetNamespace = TargetNamespace; + } + + // Do not compile included schema here. + + AddExternalComponentsTo (includedSchema, compilationItems, handler, handledUris, resolver); + } + + void AddExternalComponentsTo (XmlSchema s, XmlSchemaObjectCollection items, ValidationEventHandler handler, Hashtable handledUris, XmlResolver resolver) + { foreach (XmlSchemaExternal ext in s.Includes) - if (ext.Schema != null) - AddExternalComponentsTo (ext.Schema, items); + ProcessExternal (handler, handledUris, resolver, ext); +// if (ext.Schema != null) +// AddExternalComponentsTo (ext.Schema, items); foreach (XmlSchemaObject obj in s.Items) items.Add (obj); } Modified: trunk/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog =================================================================== --- trunk/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog 2008-02-19 15:59:12 UTC (rev 96159) @@ -1,3 +1,7 @@ +2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> + + * XmlSchemaTests.cs: added test for bug #361818. + 2008-02-04 Atsushi Enomoto <[EMAIL PROTECTED]> * XmlSchemaValidatorTests.cs : new. Test for bug #358408. Modified: trunk/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs =================================================================== --- trunk/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs 2008-02-19 15:59:12 UTC (rev 96159) @@ -406,5 +406,17 @@ while (!vr.EOF) vr.Read (); } + + [Test] + public void ThreeLevelNestedInclusion () + { + XmlTextReader r = new XmlTextReader ("Test/XmlFiles/xsd/361818.xsd"); + try { + XmlSchema xs = XmlSchema.Read (r, null); + xs.Compile (null); + } finally { + r.Close (); + } + } } } Added: trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-2.xsd =================================================================== --- trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-2.xsd 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-2.xsd 2008-02-19 15:59:12 UTC (rev 96159) @@ -0,0 +1,8 @@ +<xs:schema targetNamespace="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2005/08/07/" xmlns="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2005/08/07/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> + <xs:include schemaLocation="361818-3.xsd"/> + <xs:group name="Letters"> + <xs:choice> + <xs:element ref="HospitalReferral"/> + </xs:choice> + </xs:group> +</xs:schema> Added: trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-3.xsd =================================================================== --- trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-3.xsd 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818-3.xsd 2008-02-19 15:59:12 UTC (rev 96159) @@ -0,0 +1,3 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2005/08/07/" targetNamespace="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2005/08/07/" elementFormDefault="qualified" attributeFormDefault="unqualified"> + <xs:element name="HospitalReferral" /> +</xs:schema> Added: trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818.xsd =================================================================== --- trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818.xsd 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Test/XmlFiles/xsd/361818.xsd 2008-02-19 15:59:12 UTC (rev 96159) @@ -0,0 +1,3 @@ +<xs:schema targetNamespace="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2005/08/07/" xmlns="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2005/08/07/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> + <xs:include schemaLocation="361818-2.xsd"/> +</xs:schema> Modified: trunk/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog =================================================================== --- trunk/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog 2008-02-19 15:40:15 UTC (rev 96158) +++ trunk/mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog 2008-02-19 15:59:12 UTC (rev 96159) @@ -1,3 +1,7 @@ +2008-02-19 Atsushi Enomoto <[EMAIL PROTECTED]> + + * 361818.xsd, 361818-2.xsd, 361818-3.xsd : new test files. + 2008-02-04 Atsushi Enomoto <[EMAIL PROTECTED]> * 358408.xsd : new test file. _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches