Create XSD Dataset with child table in two nested relations.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It's a commonly known problem that XSD.exe cannot parse the following XML into either an xsd file or class
<Data><One><File><Name>Test1</Name></File></One><Two><File><Name>Test2</Name></File></Two></Data

Because it can't cope with the fact that the <File> element appears in two places (the Custom tool error: Unable to convert input xml file content to a DataSet. The same table (*TableName*) cannot be the child table in two nested relations. error). The MS provided tool "Infer.exe" WILL create an .xsd schema for this XML, but doesn't provide a way to generate a strongly-typed DataSet for it. Can anyone point me to a good workaround? There must be some way (other than me creating the typed DataSet completely manually) that I can get a repeated element into a DataSet using the XSD tool combined with some custom code. Any ideas would be appreciated

Richard
 
One way to get a schema when you cannot do it directly with the command is
to programmatically load the inforrmation (DataTables) into a DataSet and
use GetXMLSchema and write to a file. You can then place the resulting XSD
and have your strongly typed DataSet. The only time I know that this fails
is if you try to do something that is illegal in a DataSet. Of course, it
takes a bit more work to set this up, but it is worth it if you want
strongly typed DataSets.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
Richard A. Lowe said:
It's a commonly known problem that XSD.exe cannot parse the following XML
into either an xsd file or class:
</File></Two></Data>

Because it can't cope with the fact that the <File> element appears in two
places (the Custom tool error: Unable to convert input xml file content to a
DataSet. The same table (*TableName*) cannot be the child table in two
nested relations. error). The MS provided tool "Infer.exe" WILL create an
..xsd schema for this XML, but doesn't provide a way to generate a
strongly-typed DataSet for it. Can anyone point me to a good workaround?
There must be some way (other than me creating the typed DataSet completely
manually) that I can get a repeated element into a DataSet using the XSD
tool combined with some custom code. Any ideas would be appreciated.
 
Back
Top