[Mono-bugs] [Bug 77585][Wis] New - XML Schema importer generates non-validating XML for xsd:list type

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Feb 17 18:42:19 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 t7 at pobox.com.

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

--- shadow/77585	2006-02-17 18:42:19.000000000 -0500
+++ shadow/77585.tmp.10372	2006-02-17 18:42:19.000000000 -0500
@@ -0,0 +1,157 @@
+Bug#: 77585
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: Fedora core 4
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: t7 at pobox.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XML Schema importer generates non-validating XML for xsd:list type
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+The is tricky to explain as I don't know which specific class is at fault.
+The Mono xsd tool has a feature for generating source code from XSD files
+(/classes option).  It's implementation uses some classes from
+System.Xml.Schema and System.Xml.Serialization to import an XSD, generate a
+type mapping and output source code.
+When used on a simple XSD schema that uses the xs:list type, the generated
+type mapping is a managed array.  However, the generated source (at least
+for C#) doesn't include appropriate attributes so that XmlSerializer can
+serialize objects to XML so that they validate against the original XSD.
+
+Steps to reproduce the problem: (on both 1.1.13 release & svn @2006-02-17)
+1. xsd test2.xsd /classes /element:Elt 
+2. mcs testDriver.cs test2.cs
+3. mono testDriver.exe
+
+Actual Results:
+testDriver outputs:
+<?xml version="1.0" encoding="utf-16"?>
+<Elt xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <l>
+    <float>1</float>
+    <float>2</float>
+    <float>3</float>
+  </l>
+</Elt>
+
+
+Expected Results:
+Should output XML that validates against test2.xsd, namely:
+<?xml version="1.0" encoding="utf-16"?>
+<Elt xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <l>1 2 3</l>
+</Elt>
+
+
+How often does this happen? 
+Every time
+
+Additional Information:
+Not sure if the problem is with the XSD importer, the type mapping or the
+source generation.  It probably isn't XmlSerializer, since the information
+about serializing the array as a xs:list doesn't seem to be preserved
+(though that could be because no appropriate attribute exists/is implemented)
+
+Here are the relevate files
+
+test2.xsd:
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:simpleType name="FList">
+    <xs:restriction>
+      <xs:simpleType>
+        <xs:list itemType="xs:float"/>
+      </xs:simpleType>
+    </xs:restriction>
+  </xs:simpleType>
+
+  <xs:element name="Elt">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="l" type="FList"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+</xs:schema>
+
+
+testDriver2.cs:
+using System;
+using System.IO;
+using System.Text;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+
+namespace Schemas 
+{
+
+
+public class test2Driver
+{
+
+  public static void Main(string[] args)
+  {
+    Elt e = new Elt();
+    e.l = new float[3];
+    e.l[0] = 1.0f;
+    e.l[1] = 2.0f;
+    e.l[2] = 3.0f;
+
+    XmlSerializer s = new XmlSerializer(typeof(Elt));
+
+    TextWriter writer = new StringWriter();
+    s.Serialize(writer, e);
+    writer.Close();
+    string xml = writer.ToString();
+    System.Console.WriteLine(xml);
+  }
+
+}
+
+
+and, for comparison, the generated output of the xsd tool on test2.xsd:
+(note that the XmlArray attribute isn't present (if that's appropriate?))
+
+//
+------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      Mono Runtime Version: 1.1.4322.2032
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+//
+------------------------------------------------------------------------------
+
+// 
+//This source code was auto-generated by MonoXSD
+//
+namespace Schemas {
+    
+    /// <remarks/>
+    public class Elt {
+        
+        /// <remarks/>
+        [System.Xml.Serialization.XmlArrayItem(IsNullable=false)]
+        public System.Single[] l;
+    }
+    
+}


More information about the mono-bugs mailing list