[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Why deos a Datasets WriteXML method srite an xml that can not be validated

Asked by liversen in C# Programming Language, Visual Studio

Tags: xml, dataset

Hi

In C# 2008 I have made a typed dataset called ParametersDataSet.xsd
It has a table called Parameters the table has two fields: Temperatures and Voltages

When it writes the XML it looks like this:

<?xml version="1.0" standalone="yes"?>
<DocumentElement>
  <ParametersTable>
    <Temperatures>12,30</Temperatures>
    <Voltages>3,5</Voltages>
  </ParametersTable>
</DocumentElement>


The xsd that VS has generated looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="parametersDataset" targetNamespace="http://tempuri.org/parametersDataset.xsd" xmlns:mstns="http://tempuri.org/parametersDataset.xsd" xmlns="http://tempuri.org/parametersDataset.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <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="parametersDataset" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_DataSetName="parametersDataset" msprop:Generator_UserDSName="parametersDataset" msprop:EnableTableAdapterManager="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="ParametersTable" msprop:Generator_UserTableName="ParametersTable" msprop:Generator_RowDeletedName="ParametersTableRowDeleted" msprop:Generator_TableClassName="ParametersTableDataTable" msprop:Generator_RowChangedName="ParametersTableRowChanged" msprop:Generator_RowClassName="ParametersTableRow" msprop:Generator_RowChangingName="ParametersTableRowChanging" msprop:Generator_RowEvArgName="ParametersTableRowChangeEvent" msprop:Generator_RowEvHandlerName="ParametersTableRowChangeEventHandler" msprop:Generator_TablePropName="ParametersTable" msprop:Generator_TableVarName="tableParametersTable" msprop:Generator_RowDeletingName="ParametersTableRowDeleting">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Temperatures" msprop:Generator_UserColumnName="Temperatures" msprop:Generator_ColumnPropNameInRow="Temperatures" msprop:Generator_ColumnVarNameInTable="columnTemperatures" msprop:Generator_ColumnPropNameInTable="TemperaturesColumn" type="xs:string" minOccurs="0" />
              <xs:element name="Voltages" msprop:Generator_UserColumnName="Voltages" msprop:Generator_ColumnPropNameInRow="Voltages" msprop:Generator_ColumnVarNameInTable="columnVoltages" msprop:Generator_ColumnPropNameInTable="VoltagesColumn" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

The problem is that the xml has an elemnt called DocumentElement and the XSD requires it to be called parametersDataset

So the question is what is microsoft thinking about? I mean I have made the dataset in the ide so the xsd text is autogenerated. I have saved the xml file using the DataSet that is based on the xsd and they end up not matching and thus I can't validate the xml from other programs like xmlspy !!!  grrrr

As I need to be able to edit the xml in xmlspy I need the xml to be validatable. It is not.
I have tried to change the DocumentElement  field in the xml to parametersDataset
Then I can't use the method: myTable.ReadXml("C:\\myXml.xml"); It fails
I have also tried to edit the xsd and change from parametersDataset to DocumentElement  
That also gives me an error when I try to read in the xml again

Is there a work around? Have I misunderstood something?

Thanks in advance
Lars Iversen
1:
2:
3:
var myTable = new parametersDataset.ParametersTableDataTable();
  myTable.AddParametersTableRow("12,30", "3,5");
  myTable.WriteXml("C:\\myXml.xml");
[+][-]10/29/09 09:21 AM, ID: 25695309Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/29/09 10:04 AM, ID: 25695785Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/30/09 02:29 AM, ID: 25701276Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/30/09 03:40 AM, ID: 25701625Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/30/09 05:13 AM, ID: 25702124Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 01:09 AM, ID: 25727135Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625