[Mono-bugs] [Bug 77687][Nor] New - Included schema not accessible via XmlSchemaInclude.Schema

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Mar 1 14:36:07 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by matt.ward.bugs at googlemail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77687

--- shadow/77687	2006-03-01 14:36:07.000000000 -0500
+++ shadow/77687.tmp.12863	2006-03-01 14:36:07.000000000 -0500
@@ -0,0 +1,140 @@
+Bug#: 77687
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: matt.ward.bugs at googlemail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Included schema not accessible via XmlSchemaInclude.Schema
+
+Description of Problem:
+
+Given a schema of the form
+
+<xs:schema
+	targetNamespace="http://go-mono.com/tests"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	elementFormDefault="qualified">
+	<xs:include schemaLocation="include.xsd"/>
+</xs:schema>
+
+the XmlSchemaInclude object, returned from XmlSchema.Includes, has a null
+Schema property. 
+
+Steps to reproduce the problem:
+
+The following unit test succeeds under Microsoft's .NET 1.1 framework, but
+fails under Mono on Windows.  
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace XmlSchemaTests
+{
+	/// <summary>
+	/// Checks that a schema included via the schemaLocation attribute will
+	/// be loaded when compiling a schema.
+	/// </summary>
+	[TestFixture]
+	public class IncludedSchemaTestFixture
+	{
+		XmlSchema includedSchema;
+		
+		[SetUp]
+		public void Init()
+		{
+			string schemaFileName = Path.GetFullPath("Schemas/main.xsd");
+			string baseUri = GetUri(schemaFileName);
+			StreamReader sr = new StreamReader(schemaFileName, true);
+			XmlTextReader tr = new XmlTextReader(baseUri, sr);
+			
+			XmlSchema schema = XmlSchema.Read(tr, new
+ValidationEventHandler(SchemaValidation));
+			schema.Compile(new ValidationEventHandler(SchemaValidation));
+			tr.Close();
+
+			XmlSchemaInclude include = schema.Includes[0] as XmlSchemaInclude;
+			includedSchema = include.Schema;
+		}
+		
+		[Test]
+		public void IncludedSchemaIsNotNull()
+		{
+			Assert.IsNotNull(includedSchema);
+		}
+		
+		/// <summary>
+		/// Converts the filename into a valid Uri.
+		/// </summary>
+		static string GetUri(string fileName)
+		{
+			string uri = String.Empty;
+			
+			if (fileName != null) {
+				if (fileName.Length > 0) {
+					uri = String.Concat("file:///", fileName.Replace('\\', '/'));
+				}
+			}
+			return uri;
+		}
+		
+		void SchemaValidation(object source, ValidationEventArgs e)
+		{
+			// Do nothing.
+		}
+	}
+}
+
+
+main.xsd:
+---------
+
+<xs:schema
+	targetNamespace="http://go-mono.com/tests"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	elementFormDefault="qualified">
+	<xs:include schemaLocation="include.xsd"/>
+</xs:schema>
+
+
+include.xsd
+-----------
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+targetNamespace="http://go-mono.com/tests" xmlns="http://go-mono.com/tests"
+elementFormDefault="qualified">
+	<xs:element name="note">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="text" type="text-type"/>
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+	<xs:complexType name="text-type">
+		<xs:attribute name="foo"/>
+	</xs:complexType>
+</xs:schema>
+
+
+Additional notes:
+
+Note that the included schema has been loaded since we can access the note
+element, for example, the following test would succeed.
+
+XmlQualifiedName name = new XmlQualifiedName("note",
+"http://go-mono.com/tests");
+XmlSchemaElement noteElement = FindElement(schema, name);
+Assert.IsNotNull(noteElement);


More information about the mono-bugs mailing list