0

i have a xml file with following structure,

<TestClass>
  <TestChildClass>
    <TestName Name="sample">
      <Table Name="table1" IdentityColumnName="RollNo" IntColumn="Mark" CharColumn="Name" >
        <Table Name="table2" IdentityColumnName="RollNo" IntColumn="SubjectCode" CharColumn="Subject" ReferenceColumn ="RollNo" >
            <Table Name="table3" IdentityColumnName="RollNo" IntColumn="Average" CharColumn="Subject" ReferenceColumn ="SubjectCode"/>          
         </Table>

        <Table Name="table4" IdentityColumnName="RollNo" IntColumn="Rank" CharColumn="Name" />
      </Table >
    </TestName >    
  </TestChildClass>
  </TestClass>

i have created a class for the above xml using XSD.EXE. But the thing is when i tried to create object for the new class named TestClass.cs then its throwing error like "The same table 'Table' cannot be the child table in two nested relations." How to solve this?

6
  • That's not an XSD file, you can't generate a class from it, because you can't be sure of everything about the definition from one example XML file. If you know all the details, you can manually write the corresponding classes. Commented Oct 9, 2012 at 11:58
  • 2
    But we can create xsd file from xml using xsd.exe right? Commented Oct 9, 2012 at 12:15
  • From the XSD cmd line: <instance>.xml Name of an xml file to infer xsd schema from. Commented Oct 9, 2012 at 12:40
  • ya.. i have created those classes. When i am trying to create instance for that created class it shows error Commented Oct 9, 2012 at 12:51
  • Your XML is not valid... Commented Oct 9, 2012 at 12:57

1 Answer 1

1

Your XML is not valid, you need to remove the lines and make sure to close the node for Table1

<TestClass>
  <TestChildClass>
    <TestName Name="sample">
      <Table Name="table1" IdentityColumnName="RollNo" IntColumn="Mark" CharColumn="Name" >
        <Table Name="table2" IdentityColumnName="RollNo" IntColumn="SubjectCode" CharColumn="Subject" ReferenceColumn ="RollNo" >
            <Table Name="table3" IdentityColumnName="RollNo" IntColumn="Average" CharColumn="Subject" ReferenceColumn ="SubjectCode"/>          
         </Table>
        <Table Name="table4" IdentityColumnName="RollNo" IntColumn="Rank" CharColumn="Name" />
      </Table >
    </TestName >    
  </TestChildClass>
</TestClass>
Sign up to request clarification or add additional context in comments.

7 Comments

But the Table2 is the child table of the table1. And table3 is the child table of table2. Table4 is the again the child table of the table1. for that only i have added the xml like that.
Then you need to remove the /> at the end of table1 and table2, and replace them with >. That should make the XML well formed, but it may still fail the XSD class generation
ya.. that is what i have added in my question. please Checkout
It's still not well formed, you're not closing TestChildClass or TestClass
oh.. sorry i missed "/". but even it is showing the same error
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.