[Mono-bugs] [Bug 54505][Nor] New - XmlDataDocument can't add rows with DateTime values

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 17 Feb 2004 22:51:08 -0500 (EST)


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 krisolav@hotmail.com.

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

--- shadow/54505	2004-02-17 22:51:08.000000000 -0500
+++ shadow/54505.tmp.19691	2004-02-17 22:51:08.000000000 -0500
@@ -0,0 +1,157 @@
+Bug#: 54505
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Debian Woody
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: krisolav@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlDataDocument can't add rows with DateTime values
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+XmlDataDocument throws an exception when trying to add a row that contains 
+a DateTime value (where the XSD specified @type of xs:dateTime).
+
+Steps to reproduce the problem:
+1. Create the following test class:
+	public class XmlData 
+	{
+
+		public string XmlFileName
+		{
+			get { return "test.xml"; }
+		}
+
+		public string SchemaFileName
+		{
+			get { return "test.xsd"; }
+		}
+
+		public XmlData()
+		{
+			XmlDataDocument doc = new XmlDataDocument();
+			doc.DataSet.ReadXmlSchema(SchemaFileName);
+			doc.Load(new XmlTextReader(XmlFileName));
+			System.Console.Out.WriteLine("tables: " + 
+doc.DataSet.Tables.Count);
+			foreach (DataTable table in doc.DataSet.Tables)
+			{
+				System.Console.Out.WriteLine("table = " + 
+table.TableName);
+			}
+			DataTable foo = doc.DataSet.Tables["foo"];
+			
+			foreach (DataRow row in foo.Rows) 
+			{
+				System.Console.Out.WriteLine(
+					"s = " + row["s"] 
+					+ ", d = " + row["d"].GetType
+().ToString());
+			}
+			DataRow newRow = foo.NewRow();
+			newRow["s"] = "new";
+			newRow["d"] = DateTime.Now;
+			foo.Rows.Add(newRow);
+				
+			doc.Save("foo.xml");
+		}
+
+		public static void Main(string[] args)
+		{
+			try 
+			{
+				XmlData data = new XmlData();
+			}
+			catch (Exception e)
+			{
+				System.Console.Out.WriteLine(e.Message);
+				System.Console.Out.WriteLine(e.StackTrace);
+			}
+		}
+	}
+
+2. The XML file (test.xml) is:
+<?xml version="1.0" encoding="utf-8"?>
+<top xmlns="urn:test">
+  <foo>
+    <s>first</s>
+    <d>2004-02-14T10:37:03</d>
+  </foo>
+  <foo>
+    <s>second</s>
+    <d>2004-02-17T12:41:49</d>
+  </foo>
+</top>
+
+3. The XSD file (test.xsd) is: 
+<?xml version="1.0"?>
+<xs:schema id="webstore" targetNamespace="urn:test" 
+xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:element name="top">
+    <xs:complexType>
+      <xs:sequence maxOccurs="unbounded">
+        <xs:element name="foo">
+          <xs:complexType>
+		      <xs:sequence maxOccurs="unbounded">
+	              <xs:element name="s" type="xs:string"/>
+		      <xs:element name="d" type="xs:dateTime"/>
+		      </xs:sequence>
+          </xs:complexType>
+        </xs:element>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>
+
+Actual Results:
+Cannot cast from source type to destination type
+in <0x00245> System.Xml.XmlDataDocument:OnDataTableRowAdded 
+(System.Data.DataRowChangeEventArgs)
+in <0x00067> System.Xml.XmlDataDocument:OnDataTableRowChanged 
+(object,System.Data.DataRowChangeEventArgs)
+in <0x0005a> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void_object_DataRowChangeEventArgs 
+(object,System.Data.DataRowChangeEventArgs)
+in <0x00034> System.Data.DataTable:OnRowChanged 
+(System.Data.DataRowChangeEventArgs)
+in <0x00046> System.Data.DataTable:ChangedDataRow 
+(System.Data.DataRow,System.Data.DataRowAction)
+in <0x00169> System.Data.DataRowCollection:Add (System.Data.DataRow)
+in <0x005b2> Test.XmlData:.ctor ()
+in <0x0002c> Test.XmlData:Main (string[])
+
+
+Expected Results:
+Successfully saves the file foo.xml.  Verified this code works with 
+MS .NET.  It produced the following contents:
+<?xml version="1.0" encoding="utf-8"?>
+<top xmlns="urn:test">
+  <foo>
+    <s>first</s>
+    <d>2004-02-14T10:37:03</d>
+  </foo>
+  <foo>
+    <s>second</s>
+    <d>2004-02-17T12:41:49</d>
+  </foo>
+  <foo xmlns="">
+    <s>new</s>
+    <d>2004-02-17T19:24:42.0319856-08:00</d>
+  </foo>
+</top>
+
+
+How often does this happen? 
+Every time
+
+Additional Information: