Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  Mvp.Xml Project  XInclude.NET  DataSet.ReadXml...
 DataSet.ReadXml behavior
 
beefarino
2 posts
Joined
1/5/2006

DataSet.ReadXml behavior
Posted: 05 Jan 06 1:46 PM (N/A)

Hi all;

I'm encountering a problem using the Mvp.Xml.XInclude.XIncludingReader class to populate a strongly-typed dataset.  When the XML data file contains xinclude elements, those included elements are not read into the dataset if I pass an XIncludingReader instance to DataSet.ReadXml.

I'm using .NET 1.1, VS.NET 2003, and a locally-built version of the 1.3 Mvp.Xml.XInclude codebase. You can use the following files to reproduce the issue:

//Class1.cs

class Class1
{
 static void Main(string[] args)
 {
  Dataset1 data = new Dataset1();
  Mvp.Xml.XInclude.XIncludingReader reader = new Mvp.Xml.XInclude.XIncludingReader( args[ 0 ] );
  data.ReadXml( reader );

  foreach( Dataset1.Table1Row row in data.Table1 )
  {
   Console.WriteLine( "{0} = {1}", row.name, row.value );
  }
 }
}

// Dataset1.xsd

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Dataset1" targetNamespace="http://tempuri.org/Dataset1.xsd" elementFormDefault="qualified"
 attributeFormDefault="qualified" xmlns="http://tempuri.org/Dataset1.xsd" xmlns:mstns="http://tempuri.org/Dataset1.xsd"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
 <xs:element name="Dataset1" msdata:IsDataSet="true">
  <xs:complexType>
   <xs:choice maxOccurs="unbounded">
    <xs:element name="Table1">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="name" type="xs:string" minOccurs="0" />
       <xs:element name="value" type="xs:string" minOccurs="0" />
      </xs:sequence>
     </xs:complexType>
    </xs:element>
   </xs:choice>
  </xs:complexType>
 </xs:element>
</xs:schema>

// data.xml:

<Dataset1 xmlns="http://tempuri.org/Dataset1.xsd">
 
 <include xmlns="http://www.w3.org/2001/XInclude" href="data2.xml" xpointer="xmlns(d=http://tempuri.org/Dataset1.xsd)xpointer(//d:Table1)" parse="xml" />

 <Table1>
  <name>item1</name>
  <value>inline item</value>
 </Table1>
</Dataset1>

// data2.xml

<Dataset1 xmlns="http://tempuri.org/Dataset1.xsd">
 <Table1>
  <name>item2</name>
  <value>included item</value>
 </Table1>
</Dataset1>

If you pass "data.xml" to the executable you will see that only the data rows included in the data.xml file are incorporated into the DataSet; the items in data2.xml are "ignored". 

Pre-loading the XML into an XmlDocument resolves the issue; for example, this code:

class Class1
{
 static void Main(string[] args)
 {
  Dataset1 data = new Dataset1();
  System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

  Mvp.Xml.XInclude.XIncludingReader reader = new Mvp.Xml.XInclude.XIncludingReader( args[ 0 ] );
  doc.Load( reader );

  data.ReadXml( new System.Xml.XmlNodeReader( doc.DocumentElement ) );

  foreach( Dataset1.Table1Row row in data.Table1 )
  {
   Console.WriteLine( "{0} = {1}", row.name, row.value );
  }
 }
}

will process data.xml properly and output all items from data.xml and the included data2xml.  I would rather avoid this overhead if possible.

Any pointers or suggestions?  Any chance I'm using the XIncludingReader incorrectly?

Obliged,

beefarino.

olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: DataSet.ReadXml behavior
Posted: 06 Jan 06 1:18 PM (Israel)
Hmm, that's weird. I'll look at it asap.
Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
rudynz
2 posts
Joined
2/10/2006

Re: DataSet.ReadXml behavior
Posted: 10 Feb 06 1:59 AM (United States)
Hi,

I have the same prolem with VS 2005 .NET 2.0 and the Mvp.Xml-bin-2.0

Rudy


beefarino
2 posts
Joined
1/5/2006

Re: DataSet.ReadXml behavior
Posted: 31 Mar 06 6:54 AM (N/A)
I'm just now revisiting this project; any word on the DataSet.ReadXml issue?
olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: DataSet.ReadXml behavior
Posted: 11 Jul 06 2:08 AM (Israel)
Not fixed yet, sorry.

Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: DataSet.ReadXml behavior
Posted: 10 Jul 07 2:38 AM (Israel)
Fixed in Mvp.Xml library version 2.3. Download from http://www.mvpxml.org.

Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
  Mvp.Xml Project  XInclude.NET  DataSet.ReadXml...
Forum Home  Search