[Mono-list] Datasets passed between methods loses data

anthony whalley tont@o2.ie
Mon, 07 Mar 2005 11:00:37 +0000 (GMT)


Hi Atsushi

I should of been more explicit in my example.
If I call 
 ds.GetXml(); 
in the GetLogFile method before passing it over
then it returns the full XML document and
I can also access the full structure using 
the usual methods. e.g. ds.Tables[0]

It is only when I pass it to a new method that 
the issue arises. 

Thanks for the hint on the loading of 
mal formed XML but the file i am loading
is the Xml formatted log from log4net not
a tab deliniated. 

TTFN 

tont


----- Original Message -----
From: Atsushi Eno <atsushi@ximian.com>
Date: Monday, March 7, 2005 10:07 am
Subject: Re: [Mono-list] Datasets passed between methods loses data

> Hello,
> 
> Actually it depends on the content of "server.log" since the XML
> structure is not determined only with that code. If that log file
> contains only simple text (BTW that code is really not recommended
> because it will raise an XmlException if there is broken XML
> fragment), it won't return any XML content, since that simple text
> content is not mapped to any DataTable, nor the "root" element is
> not regarded as a DataTable.
> 
> DataSet is not such universal XML store. It just holds such contents
> that is mappable to table set structure and ReadXml() ignores
> other content. Just FYI, MS.NET also ignores the text content.
> 
> Atsushi Eno
> 
> anthony whalley wrote:
> > Hi All 
> > 
> > I am writing an application that marshells a log4net 
> > file into a dataset and then passes the dataset
> > over to another method. I am using v 1.1.4 from the 
> > RPMs on Suse 9.2 and below is the code.
> > However when I test the dataset returned it 
> > has only a root node even though before
> > it is passed it has all the data inside it. 
> > I have solved the prolem for now by passing over
> > the data as a string type and marhalling the 
> > data there but wondered if I should
> > report it as a bug?? 
> > 
> > public class obj{
> >         	public DataSet GetLogFile()
> >         	{
> >                 	DataSet ds = new DataSet() ;
> >                 	try 
> >                 	{
> >                         	string _logLocation = 
> Environment.CurrentDirectory + Path.DirectorySeparatorChar + 
> "server.log" ;
> >                         	Stream stm = File.Open(_logLocation, 
> FileMode.Open, FileAccess.Read, FileShare.ReadWrite) ;
> >                         	
> >                         	StreamReader str = new 
> StreamReader(stm) ;
> >                         	ds.ReadXml(new StringReader("<root 
> xmlns:log4net='" target="l">http://logging.apache.org/log4net/LogSchema'>" + 
> >                                 	str.ReadToEnd() + 
> >                                 	"</root>")) ;
> >                         	str.Close();
> >                         	stm.Close();
> >                         	
> >                 	}
> >                 	catch(Exception e)
> >                 	{
> >                         	log.Error("Get log file error", e) ; 
> >                 	}
> >                 	return ds ;
> >         	}
> > }
> > 
> > public class otherObj
> > {
> > 
> >   obj o = new obj() ;
> >   DataSet ds = new DataSet() ;
> >   public void testxml(){
> >   ds = o.GetLogFile() ;
> >   Console.WriteLine(ds.GetXml()); //returns <root />
> > }
> > }
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Mono-list maillist  -  Mono-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> > 
> 
>