dataset and xsd

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rickbear

    dataset and xsd

    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:
    'InformationDat a' 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"
    elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
    <xs:element name="Informati onSet">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="Informati onData">
    <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="unbo unded">
    <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="unbo unded">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="Identifye r" 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.ReadX mlSchema(schema File); //schemaFile is the above schema
    /* Some connection to the first table in the db here */
    myAdapter.Missi ngSchemaAction = MissingSchemaAc tion.Error;
    myAdapter.Fill( myDataset, "InformationDat a");
    /* Some connection to another table in the db here */
    myAdapter.Missi ngSchemaAction = MissingSchemaAc tion.Error;
    myAdapter.Fill( myDataset, "Content");
    /* Some connection to third table in the db here */
    myAdapter.Missi ngSchemaAction = MissingSchemaAc tion.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 >
    <InformationDat a>
    <IdNumber>Tes t</IdNumber>
    <Name>Pony</Name>
    <Content>
    <Name>SomeNam e</Name>
    <Value>SomeValu e</Value>
    </Content>
    <Setup>
    <Identifyer>Som eIdentifyer</Identifyer>
    <Value>SomeValu e</Value>
    </Setup>
    </InformationData >
    </InformationSet>

    But this is not the case! Instead I am getting this:

    extracted.xml:
    <?xml version="1.0" standalone="yes "?>
    <InformationSet >
    <InformationDat a>
    <IdNumber>Tes t</IdNumber>
    <Name>Pony</Name>
    </InformationData >
    <Content>
    <Name>SomeNam e</Name>
    <Value>SomeValu e</Value>
    </Content>
    <Setup>
    <Identifyer>Som eIdentifyer</Identifyer>
    <Value>SomeValu e</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 -
Working...