Good afternoon,
I have an XML and a corresponding XSD file generated from MS Access with a list of iso4217 currency codes and descriptions and a primary key.
My software reads the XML file (using DataSet.XmlRead()), and then generates a DataTable object of the table contained within the dataset (the table is called "iso4217").
My problem is: if I try to run the DataTable.Rows.Find() method, the debugger returns an error stating that there is no primary key. I have checked my XSD file and the primary key is there.
I have managed to get around the issue by setting the primary key of the generated DataTable programatically, however the rest of my solution relies very heavily on relational tables within XML files.
If there is something that I am missing, I want to get my head around now before I run into larger issues down the line.
For additional information, I have attached to two datafiles. Note: the XSD files was modified within Visual Studio:
XML:
="1.0"="UTF-8"
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="iso4217.xsd" generated="2010-07-30T15:26:56">
<iso4217>
<iso4217_id>152</iso4217_id>
<code>AED</code>
<description>UAE dirham</description>
</iso4217></dataroot>
XSD:
="1.0"="utf-8"
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections />
<Tables />
<Sources />
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="iso4217" msprop:Generator_UserTableName="iso4217" msprop:Generator_RowDeletedName="iso4217RowDeleted" msprop:Generator_TableClassName="iso4217DataTable" msprop:Generator_RowChangedName="iso4217RowChanged" msprop:Generator_RowClassName="iso4217Row" msprop:Generator_RowChangingName="iso4217RowChanging" msprop:Generator_RowEvArgName="iso4217RowChangeEvent" msprop:Generator_RowEvHandlerName="iso4217RowChangeEventHandler" msprop:Generator_TablePropName="iso4217" msprop:Generator_TableVarName="tableiso4217" msprop:Generator_RowDeletingName="iso4217RowDeleting">
<xs:complexType>
<xs:sequence>
<xs:element name="iso4217_id" msdata:AutoIncrementSeed="1" msprop:Generator_UserColumnName="iso4217_id" msprop:Generator_ColumnPropNameInRow="iso4217_id" msprop:Generator_ColumnVarNameInTable="columniso4217_id" msprop:Generator_ColumnPropNameInTable="iso4217_idColumn" type="xs:int" />
<xs:element name="code" msprop:Generator_UserColumnName="code" msprop:Generator_ColumnPropNameInRow="code" msprop:Generator_ColumnVarNameInTable="columncode" msprop:Generator_ColumnPropNameInTable="codeColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="description" msprop:Generator_UserColumnName="description" msprop:Generator_ColumnPropNameInRow="description" msprop:Generator_ColumnVarNameInTable="columndescription" msprop:Generator_ColumnPropNameInTable="descriptionColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="NewDataSet" msprop:Generator_DataSetName="NewDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="iso4217" />
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//iso4217" />
<xs:field xpath="iso4217_id" />
</xs:unique>
</xs:element>
</xs:schema>