xsd.exe Typed DataSet generation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Matthew Baskey (matthew.baskey_at_gmail.com)
Date: 09/03/04


Date: 3 Sep 2004 04:25:54 -0700

Hello,

I am loading a DataSet from an xml file and binding it to a
hierarchical datagrid. I am trying to write some keys between the
elements in my xml file into the xsd file. When I write the keys as
elements it works and I get the

public QuestionRow FindByorder(short order) {
 return ((MenuTitlesRow)(this.Rows.Find(new object[] {order})));
}

however when I change these to attributes I loose my this method when
running
xsd.exe test.xsd /d

I need my xml to be structured with attributes, is there anyway I can
do this without have to transform the final output.

There is curiously very little literature available on the web about
this and what is very basic.

Here is my xsd file....

<?xml version="1.0" standalone="yes"?>
<xs:schema id="Test" targetNamespace="http://tempuri.org/test.xsd"
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://tempuri.org/test.xsd"
xmlns:mstns="http://tempuri.org/test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="Test" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Question">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Option" minOccurs="0"
maxOccurs="unbounded">
                <xs:complexType>
                                  <xs:attribute name="parent" type="xs:short" />
                                  <xs:attribute name="suborder" type="xs:short" />
                  <xs:attribute name="Text" type="xs:string" />
                  <xs:attribute name="Selected" type="xs:string" />
                  <xs:attribute name="Tooltip" type="xs:string" />
                  <xs:attribute name="Answer" type="xs:string" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:short" use="required" />
            <xs:attribute name="Text" type="xs:string" use="required"
/>
            <xs:attribute name="Type" type="xs:string" use="required"
/>
            <xs:attribute name="Score" type="xs:string" use="required"
/>
            <xs:attribute name="Mandatory" type="xs:string"
use="required" />
            <xs:attribute name="Tooltip" type="xs:string"
use="required" />
            <xs:attribute name="MultiSelect" type="xs:string"
use="optional" />
            <xs:attribute name="AllowNoSelection" type="xs:string"
use="optional" />
            <xs:attribute name="Multiline" type="xs:string"
use="optional"/>
            <xs:attribute name="MaxLength" type="xs:string"
use="optional" />
            <xs:attribute name="MinLength" type="xs:string"
use="optional" />
            <xs:attribute name="InitialValue" type="xs:string"
use="optional" />
            <xs:attribute name="Validation" type="xs:string"
use="optional" />
            <xs:attribute name="Answer" type="xs:string"
use="optional" />
          </xs:complexType>
                <xs:key name="QuestionKey2" msdata:PrimaryKey="true">
                        <xs:selector xpath=".//mstns:Question" />
                        <xs:field xpath="mstns:id" />
                </xs:key>
        <xs:keyref name="QuestionOption" refer="QuestionKey2"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
            <xs:selector xpath=".//mstns:Option" />
            <xs:field xpath="mstns:parent" />
        </xs:keyref>
        <xs:key name="QuestionKey1" msdata:PrimaryKey="true">
            <xs:selector xpath=".//mstns:Option" />
            <xs:field xpath="mstns:parent" />
            <xs:field xpath="mstns:suborder" />
        </xs:key>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

I am trying to the following in the Update_click method of the
datagrid....

Test dst = (Test)Session("Test");
short order = Convert.ToInt16(HierarGrid1.DataKeys[e.Item.ItemIndex]);
Test.QuestionRow row =
(Test.QuestionRow)dst.Question.FindByorder(order);

also it appears DataKeys are empty...

Thanks for any light shed on this area,
Matt



Relevant Pages

  • Re: Array and Hash able manipulation
    ... given a different source XML file: ... I need to be able to print the names of the keys out without ... server'ness of Perl made me come back. ... The Hash refs and Array ...
    (perl.beginners)
  • DBIx::XML::DataLoader
    ... Is there a package or utility that can read an XML file of the sort I ... credentials to the database, and the database. ... Also obviously not all columns in the database are keys or indeces. ...
    (comp.lang.perl.misc)
  • Re: Adding all user in a domain to a sharepoint site
    ... keys 'analyze' and 'update', former is used to generate the .xml file ... with all the user account information. ... So at one time you can update all the user account regardless of site ...
    (microsoft.public.sharepoint.portalserver.development)
  • What to search for
    ... The unique keys are "negative" as expected. ... After this step I am writing the dataset to an XML file, but it still has "negatives" there. ... How to I get it to write to the xml file with "Positive Keys". ... and using primary keys on an xml file will always be like this - until you take it and write the contents into a real server filesystem? ...
    (microsoft.public.dotnet.languages.vb)
  • xsd.exe Typed DataSet generation
    ... hierarchical datagrid. ... I am trying to write some keys between the ... elements in my xml file into the xsd file. ...
    (microsoft.public.dotnet.framework.adonet)