//
// (c)copyright 2003 Ville Palo
//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
using System;
using System.Data;
using System.Xml;
+using System.Xml.Schema;
using System.Xml.XPath;
using System.Collections;
using System.Globalization;
}
reader.MoveToContent ();
- if (reader.IsEmptyElement) return;
+ if (reader.IsEmptyElement) {
+ reader.Skip ();
+ return;
+ }
reader.ReadStartElement ("diffgram", XmlConstants.DiffgrNamespace);
reader.MoveToContent ();
private void LoadCurrent (XmlReader reader)
{
- if (reader.IsEmptyElement) return;
-
+ if (reader.IsEmptyElement) {
+ reader.Skip();
+ return;
+ }
reader.ReadStartElement (); // Dataset root
reader.MoveToContent ();
DataTable t = GetTable (reader.LocalName);
if (t != null)
LoadCurrentTable (t, reader);
+#if true
+ else
+ reader.Skip ();
+#else
else
throw new DataException (Locale.GetText ("Cannot load diffGram. Table '" + reader.LocalName + "' is missing in the destination dataset"));
+#endif
}
else
reader.Skip ();
private void LoadBefore (XmlReader reader)
{
- if (reader.IsEmptyElement) return;
-
+ if (reader.IsEmptyElement) {
+ reader.Skip ();
+ return;
+ }
reader.ReadStartElement ();
reader.MoveToContent ();
private void LoadErrors (XmlReader reader)
{
- if (reader.IsEmptyElement) return;
-
+ if (reader.IsEmptyElement) {
+ reader.Skip ();
+ return;
+ }
reader.ReadStartElement ();
reader.MoveToContent ();
reader.ReadEndElement ();
}
- private void LoadColumns (DataTable Table, DataRow Row, XmlReader reader, DataRowVersion loadType)
+ private void LoadColumns (DataTable Table, DataRow Row,
+ XmlReader reader, DataRowVersion loadType)
{
- if (reader.IsEmptyElement) return;
-
+ // attributes
+ LoadColumnAttributes (Table, Row, reader, loadType);
+ LoadColumnChildren (Table, Row, reader, loadType);
+ }
+
+ private void LoadColumnAttributes (DataTable Table, DataRow Row,
+ XmlReader reader, DataRowVersion loadType)
+ {
+ if (!reader.HasAttributes // this check will be faster
+ || !reader.MoveToFirstAttribute ())
+ return;
+ do {
+ switch (reader.NamespaceURI) {
+ case XmlConstants.XmlnsNS:
+ case XmlConstants.DiffgrNamespace:
+ case XmlConstants.MsdataNamespace:
+ case XmlConstants.MspropNamespace:
+ case XmlSchema.Namespace:
+ continue;
+ }
+ DataColumn c = Table.Columns [reader.LocalName];
+ if (c == null ||
+ c.ColumnMapping != MappingType.Attribute) continue;
+ if (c.Namespace == null && reader.NamespaceURI == String.Empty ||
+ c.Namespace == reader.NamespaceURI) {
+ object data = XmlDataLoader.StringToObject (c.DataType, reader.Value);
+ if (loadType == DataRowVersion.Current)
+ Row [c] = data;
+ else
+ Row.SetOriginalValue (c.ColumnName, data);
+ } // otherwise just ignore as well as unknown elements.
+ } while (reader.MoveToNextAttribute ());
+ reader.MoveToElement ();
+ }
+
+ private void LoadColumnChildren (DataTable Table, DataRow Row,
+ XmlReader reader, DataRowVersion loadType)
+ {
+ // children
+ if (reader.IsEmptyElement) {
+ reader.Skip ();
+ return;
+ }
reader.ReadStartElement ();
reader.MoveToContent ();