[Mono-bugs] [Bug 74784][Nor] New - unable to import xml schema, code makes no sense

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 1 May 2005 12:34:12 -0400 (EDT)


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 monobugs@joern.heissler.de.

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

--- shadow/74784	2005-05-01 12:34:12.000000000 -0400
+++ shadow/74784.tmp.32194	2005-05-01 12:34:12.000000000 -0400
@@ -0,0 +1,70 @@
+Bug#: 74784
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: monobugs@joern.heissler.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: unable to import xml schema, code makes no sense
+
+file: System.Data/System.Data/XmlSchemaDataImporter.cs
+line: 566
+method: private void ImportColumnGroupBase (XmlSchemaElement parent,
+XmlSchemaGroupBase gb)
+
+how to reproduce:
+fetch http://www.topografix.com/GPX/1/0/gpx.xsd
+then execute this code:
+new DataSet().ReadXmlSchema("gpx.xsd");
+
+program output:
+Unhandled Exception: System.InvalidCastException: Cannot cast from source
+type to destination type.
+in <0x000ef> System.Data.XmlSchemaDataImporter:ImportColumnGroupBase
+(System.Xml.Schema.XmlSchemaElement,System.Xml.Schema.XmlSchemaGroupBase)
+in <0x005bb> System.Data.XmlSchemaDataImporter:ProcessDataTableElement
+(System.Xml.Schema.XmlSchemaElement)
+in <0x00298> System.Data.XmlSchemaDataImporter:ProcessGlobalElement
+(System.Xml.Schema.XmlSchemaElement)
+in <0x0024d> System.Data.XmlSchemaDataImporter:Process ()
+in <0x00031> System.Data.DataSet:ReadXmlSchema (System.Xml.XmlReader)
+in <0x0003f> System.Data.DataSet:ReadXmlSchema (string)
+in <0x00036> Blah.ReadFoo:Main (string[])
+
+what happens in the code:
+1  foreach (XmlSchemaParticle p in gb.Items) {
+2    XmlSchemaElement el = p as XmlSchemaElement;
+3    if (el != null)
+4      ImportColumnElement (parent, el);
+5    else
+6      ImportColumnGroupBase (parent, (XmlSchemaGroupBase) p);
+7  }
+
+in line 1, p is assigned an object of type XmlSchemaAny
+in line 2, it crashes, since both XmlSchemaElement and XmlSchemaAny inherit
+from XmlSchemaParticle
+
+afaics XmlSchemaAny is related to 
+<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
+in gpx.xsd, when removing this (and similar) lines the error won't occur.
+
+this code has some other bugs too:
+line 3: if el == null, p (which is null of course) is casted to
+(XmlSchemaGroupBase) in line 6. 
+
+I don't know XML and I don't know what this method should do, what should
+be in gb.Items, etc. therefore I cannot fix this code myself :)
+
+btw.. MS .net doesn't complain on my code and happily executes it (same binary)
+
+--
+Joern Heissler