home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / XML / DataSetMapXMLData.aspx next >
Encoding:
Text File  |  2000-06-10  |  3.1 KB  |  96 lines

  1. <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
  2.  
  3. <!-- #include virtual="/quickstart/howto/doc/xml/header.inc" -->
  4.  
  5. <h4>How Do I...Infer DataSet mappings from XML?</h4>
  6.  
  7. <div class="indent" style="width:660">
  8. This sample illustrates how to create DataSet mappings from XML Data. Here we use the concept of inference whereby the structure of the XML data is used to 
  9. build a relational schema. This is then used to create a relational structure of tables and columns to store data in a DataSet that conforms to the infered
  10. schema.</div>
  11.  
  12. <h4>Infer DataSet mappings from XML</h4> 
  13. <Acme:SourceRef
  14. ViewSource="/quickstart/howto/samples/Xml/DataSetMapXMLData/DataSetMapXMLData.src"
  15. RunSample="/quickstart/howto/samples/Xml/DataSetMapXMLData/DataSetMapXMLData.aspx" 
  16. Icon = "/quickstart/images/genicon.gif"
  17. Caption="DataSetMapXMLData.aspx"
  18. runat="server" />
  19.  
  20. <br clear="left"><br>
  21. <div class="indent" style="width:660">
  22. To achieve inference on the XML the <b>InferSchema</b> method is called with the XML file.
  23. </div>
  24.  
  25. <div class="code"><xmp>
  26. // Infer the DataSet schema from the XML data
  27. dataset.InferSchema(new StreamReader("books.xml"));
  28. </xmp></div>
  29.  
  30. <div class="indent" style="width:660">
  31. As in the previous topic we use the DisplayTables() method to display the structure and contents of the DataSet.
  32. See <a href="/quickstart/howto/doc/Xml/LoadDataSetXMLData.aspx">How Do I...Load a DataSet with XML?</a></br>
  33. </div>
  34.  
  35. <br clear="left"><div class="indent" style="width:660">
  36. The output from the DisplayTables() method for the schema inferred from the
  37. <a target="_blank" href="/quickstart/util/srcctrlwin.aspx?path=/quickstart/howto/samples/Xml/DataSetMapXMLData/&file=books.xml">books.xml</a> file
  38. is illustrated below showing the table and column names and the row contents.
  39. </div>
  40.  
  41. <div class="code"><xmp>
  42. Creating an XmlDataDocument ...
  43. Content of Tables ...
  44.  
  45. TableName = book
  46. ---------
  47. Columns ...
  48.  
  49. genre                 publicationdate       ISBN                  title                 book_Id               price
  50.  
  51. Number of rows = 3
  52. Rows ...
  53.  
  54. autobiography         1981                  1-861003-11-0         The Autobiography of Benjamin Franklin 0    8.99
  55. novel                 1967                  0-201-63361-2         The Confidence Man    1                     11.99
  56. philosophy            1991                  1-861001-57-6         The Gorgias           2                     9.99
  57.  
  58. TableName = author
  59. ---------
  60. Columns ...
  61.  
  62. first-name            last-name             book_Id
  63.  
  64. Number of rows = 3
  65. Rows ...
  66.  
  67. Benjamin              Franklin              0
  68. Herman                Melville              1
  69. Sidas                 Plato                 2
  70. </xmp></div>
  71.         
  72. <H4>Summary</H4>
  73. <OL>
  74. <LI>Inference is the mechanism whereby the structure of the XML data is used to build a relational schema.
  75. <LI>The DataSet InferSchema method builds relational mapping using the supplied XML file in a StreamReader.
  76. </LI></OL>
  77.  
  78. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.