Bug 22501

Summary: XmlSchema.Read raises InvalidElementError for certain inputs which work fine in MS.NET
Product: [Mono] Class Libraries Reporter: Matej Drolc <pinggo>
Component: System.XMLAssignee: marcos.henrich
Status: RESOLVED FIXED    
Severity: normal CC: kumpera, mono-bugs+mono, pinggo
Priority: ---    
Version: master   
Target Milestone: Untriaged   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Matej Drolc 2014-08-29 09:03:17 UTC
Here is a program example with xml input from a real application that throws an Exception in Mono but works fine in MS.NET.

using System;
using System.Data;
using System.Linq;
using System.Xml;
using System.Xml.Linq;

class Program
{
	static void Main(string[] args)
	{
		string xml = @"<Databag DataBagName="""" GridDataId="""" StartRow=""0"" RowCount=""1"">
		  <xs:schema id=""NewDataSet"" xmlns="""" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"">
			<xs:element name=""NewDataSet"" msdata:IsDataSet=""true"" msdata:MainDataTable=""row"" msdata:Locale="""">
			  <xs:complexType>
				<xs:choice minOccurs=""0"" maxOccurs=""unbounded"">
				  <xs:element name=""row"" msdata:Locale="""">
					<xs:complexType>
					  <xs:sequence>
						<xs:element name=""r_CfgKeyPartForGridLayout"" type=""xs:string"" minOccurs=""0"" />
						<xs:element name=""r_FilterInputData"" type=""xs:string"" minOccurs=""0"" />
					  </xs:sequence>
					</xs:complexType>
				  </xs:element>
				</xs:choice>
			  </xs:complexType>
			</xs:element>
		  </xs:schema>
		  <diffgr:diffgram xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"" xmlns:diffgr=""urn:schemas-microsoft-com:xml-diffgram-v1"">
			<DocumentElement>
			  <row diffgr:id=""row1"" msdata:rowOrder=""0"">
				<r_FilterInputData></r_FilterInputData>
			  </row>
			</DocumentElement>
		  </diffgr:diffgram>
		</Databag>";

		XElement xE = XElement.Parse(xml);		
		DataTable dt = new DataTable();

		using (XmlReader r = xE.CreateReader())
		{
			dt.ReadXmlSchema(r);
		}				
	}
}
Comment 1 marcos.henrich 2014-10-13 16:11:11 UTC
Hi Matej,

Thank you for the detailed bug report.

The pull request for this issue can be found in the link below.
https://github.com/mono/mono/pull/1336
Comment 2 marcos.henrich 2014-12-16 15:19:24 UTC
Fixed in master c0216739390c37ea05a99a4cbc15e2222aac3f11.
https://github.com/mono/mono/commit/c0216739390c37ea05a99a4cbc15e2222aac3f11