XML Inline Schema

  • Thread starter Thread starter info
  • Start date Start date
I

info

Hi there
I've an XML FIle with an Inline XSD Schema how can I read attributes of
this file?

Below is an sample XML

When I just try to open and read it get the error that the XML Data
can't be parsed.

When i just remove the schema i just get 2 Columns one ist "VFPData"
the other one curpim. But that's not the result i want to get, because
i want the items of curpim.

Can anyone help me with a code sample that works with this XML Data?

Thank you a lot !

Here is an sample of the file:
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<VFPData xml:space="preserve">
<xsd:schema id="VFPData" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="VFPData" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="curpim" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Feld1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"></xsd:maxLength>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Feld2">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"></xsd:maxLength>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
<xsd:anyAttribute namespace="http://www.w3.org/XML/1998/namespace"
processContents="lax"></xsd:anyAttribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<curpim>
<Feld1> 3200013</Feld1>
<Feld2></Feld2>
</curpim>
<curpim>
<Feld1> 4523423</Feld1>
<Feld2>abcdef</Feld2>
</curpim>
<curpim>
<Feld1> A3214</Feld1>
<Feld2>xvcdxfsd</Feld2>
</curpim>
</VFPData>
 
Hi There

I found an solution to retrieve the data from the XML FIle (when it
doesn't have an Inline Schema) via Data set and Data reader.
But now i get the Error "The buffer pool is too small or there are too
many open cursors"

at the moment i work like this
lcXmlPath = program.oDaten.GetAppDir() +
"\\schema\\pim.xml";
DataSet ds = new DataSet();

ds.ReadXml(lcXmlPath);
....
DataTable DT = ds.Tables["table"];
lnItems = DT.Rows.Count;
DataReader = DT.CreateDataReader();

if (DataReader.HasRows == true)
{
// Es wurden daten ausgelesen
while (DataReader.Read())
{
.....
}
....


I also need to use the schema to avoid datatype conflicts etc...



Does somebody know an solution ?

Thanks!
 
Remove xml:space="preserve" and DataSet.ReadXml() would work.
Or remove white spaces from the schema and save on size.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Thank you that worked

ButNow i've to other problems.

When I process an file with about 2 MB I get the errror that there were
not enough space but I've 30 MB Application and 30 MB of Ram Free.

How Can i processs this and even larger files and how can I calculate
how many freespace I need ?

The other problem is that some of my Datevalues were not excepted, is
there a chance to find out in which (data)row this apperead?

Thank you !
 
2 MB XML with DataSet.ReadXml() should not be a problem unless you're using
inference (e.g. don't have schema in XML and DataSet).

If there was a problem loading data, you'll get an exception which should
explain what's wrong.
There's also DataRow.RowError property which would be none-empty for rows
with error.
You can check all rows for errors.

Finally, using DataReader to access data is not needed as DataSet allows
direct access to any row:

DataTable DT = ds.Tables["table"];
object value = DT.Rows[0][0]; // Get value from the first column of the
first row.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Hi
Thanks for this!
Yes I found the error, it was one made of myself and now it works
wirhout problem with bigger files, but gets real slow after 3000
REcords. Till there its really fast.
I think it isn'T the size of the database, because when I stop the
import and restart it its again realfast.

Whats faster and better for bigger (upt to 5- 10 MB) files ? Working
with the Dataset oder the Reader?
 
Our tests indicate loading time for DataSet.ReadXml() with schema is pretty
much directly proportional to the XML size and/or number of records.

If below 3000 records it's "really fast" and above that it's not, you have a
problem.

May be it's quickly failing with exception you're ignoring or not loading
any data because schema and data do not match.



For NETCF V2 Beta 2 (which I believe you're using) ReadXml() with schema
should take around 15 seconds per 1 MB on 400 MHz PXA255 device running PPC
03.

If it's way faster or way slower, you have a problem (like loading no data
if it's faster or using inference if it's way slower).



Now, which Reader you're talking about? If it's the DataTableReader you've
been using, it's just an additional overhead as it would retrieve data from
DataSet anyway.

It's only useful if you have existing application which uses IDataReader and
you want to switch to DataSet without changing it much.



There's another reader, XmlTextReader to be exact. It allows you to read any
XML document element by element.

It has no idea your XML has some records in it; it just provides you with a
stream of elements.

XmlTextReader is used by DataSet.ReadXml() which also doing a lot if work
figuring our what to do with these elements (like converting them to the
right type and putting them to the right column/table).



If your can process these XML elements one by one, you should definitely
switch from DataSet to XmlTextReader.



If your data files are above 2 MB, you should strongly consider abandoning
XML and switching to the real database like SQL CE (which is free).


Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Hi There

thanks for your infos.

I do use the SQL CE Server, but i've to use some kind of file format to
import data to the SQL CE device.
I cant use replication becuase the existing software has its data in
foxpro dbf tables.
 
You should be able to create SQL CE database on the desktop from your legacy
dbf files (or pretty much any other data source).

That can be done using SQL Server 2005 DTS (now called Integration Services,
I believe) or programmatically as SQL Mobile can be used on desktop in some
cases (*).



There also are some 3rd party solutions for using dbf on CF, but I would
advice against using this ages old technology in new projects unless you
absolutely have to.


Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.



* Please see SQL Mobile license for restrictions.



*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Back
Top