Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
597
Strongly Typed .NET DataSet
We learned about two different approaches to access XML data: transforming
each element in an XML document into a .NET object with the XmlSerializer or
loading entire XML documents into an ADO.NET DataSet. We can access and
manipulate the data in the DataSet through tables, rows and columns, just as if
we were accessing a database. Chapter 8 also introduced us to typed DataSets
that enforce a specific structure on the XML data they expose.
It is rather complex to create a typed DataSet class by hand. Fortunately
the schema definition tool can create a typed DataSet from an XSD schema that
describes the data structure. We simply need to let the tool know to produce a
DataSet class rather than a class for the XmlSerializer when we specify a file
with a .xsd extension by replacing the /d with the /d option. The following
example creates a DataSet from the schema in listing C.2:
xsd.exe garage.xsd /d
Elements in the schema are modeled as tables; relationships between the
elements are expressed as relationships between these tables as following code
snippet shows:
8 Listing C.8
Types DataSet definition created by the XSD tool.
…(annotation) <#1 The schema id is used for the class name. The class
derives from the DataSet class/ >
(annotation) <#1 Elements in the schema are represented as tables and
relationships.>
The listing for the complete class would go on for the next fifteen or so
pages, but I think you get the point: Creating a typed DataSet and all
supporting classes is very complex. The XSD tool is the only viable option to
create typed DataSet classes.
XSD Switches
We can mix the /l and /n options together with the /d option to select the
programming language and the .NET namespace. The /e and /u option however, have
no effect on the generated DataSet.