Hi group...
I am having big difficulties with dataset and xsd schemas.
First I dedicate a specific schema to a dataset. Then I use an adapter
to fill each table in the dataset.
But the problem is, when I use the write or getxml on the dataset, the
result is NOT like the schema I provided the dataset which I think
should not be possible.
I hope to get some idea how to correct my problem.
Here is more detailed information:
I have a databse with 3 tables:
'InformationData' which holds IdNumber, Name.
'Content' which holds Name, Value
'Setup' which holds Identifyer, Value.
My Schema looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="InformationSet">
<xs:complexType>
<xs:sequence>
<xs:element name="InformationData">
<xs:complexType>
<xs:sequence>
<xs:element name="IdNumber" type="xs:string" />
<xs:element name="Name" type="xs:string" />
<xs:element name="Content" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Setup" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Identifyer" type="xs:string" />
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
What i am doing now is:
myDataset.ReadXmlSchema(schemaFile); //schemaFile is the above schema
/* Some connection to the first table in the db here */
myAdapter.MissingSchemaAction = MissingSchemaAction.Error;
myAdapter.Fill(myDataset, "InformationData");
/* Some connection to another table in the db here */
myAdapter.MissingSchemaAction = MissingSchemaAction.Error;
myAdapter.Fill(myDataset, "Content");
/* Some connection to third table in the db here */
myAdapter.MissingSchemaAction = MissingSchemaAction.Error;
myAdapter.Fill(myDataset, "Setup");
What I am expecting from the above xsd, when running a .write()
or .getxml() on the dataset is this:
expected.xml:
<?xml version="1.0" standalone="yes"?>
<InformationSet>
<InformationData>
<IdNumber>Test</IdNumber>
<Name>Pony</Name>
<Content>
<Name>SomeName</Name>
<Value>SomeValue</Value>
</Content>
<Setup>
<Identifyer>SomeIdentifyer</Identifyer>
<Value>SomeValue</Value>
</Setup>
</InformationData>
</InformationSet>
But this is not the case! Instead I am getting this:
extracted.xml:
<?xml version="1.0" standalone="yes"?>
<InformationSet>
<InformationData>
<IdNumber>Test</IdNumber>
<Name>Pony</Name>
</InformationData>
<Content>
<Name>SomeName</Name>
<Value>SomeValue</Value>
</Content>
<Setup>
<Identifyer>SomeIdentifyer</Identifyer>
<Value>SomeValue</Value>
</Setup>
</InformationSet>
As you can see, there is just three ordinary tables in the dataset/xml
(you can see this by the position of the InformationData-tag. Somehow
the xsd is completely ignored.
When I try to load the "wrong" extracted xml from above into a dataset
with the schema provided (by using the .readxml() and .readxmlschema I
get an error. But when doing so with the one I expect I get no errors.
Can someone tell my how to fill the dataset correct? :o)
I need a xml which looks like the expected.xml
Regards
- rick -