Quantcast

XML integration with ADO+

Get the WebProNews Newsletter:
[ Business]

One of the most important design goals for ADO+ was powerful XML support. Microsoft designed ADO+ hand in hand with the .NET XML framework. Both are components of a single architecture. The unification of ADO+ with the XML framework happens in the dataset.

For beginners datasets has methods that can read and write XML. For reading XML, the XML framework parser is used, either explicitly or implicitly. For writing XML out, the XML framework XmlWriter is utilized.

In spite of where the data originated, the dataset can save out its contents, both schema and data as XML. The schema is encoded as an internal W3C schema section, generally known as XSD, and the data is encoded as XML that be conventional to that schema. Because the dataset’s native serialization format is XML, it is an tremendous medium for moving data between tiers in a disconnected fashion just like the disconnected recordset.

Indeed, .NET Web services make intense use of datasets to transport data in the context of a schema between tiers of an application. Just like populating the dataset via its object model or through managed providers, loading the dataset with XML is a two stage process.

1) The schema is created, and then the data is loaded. If the XML document comes with a schema, that schema is used to create the relational structure of the dataset. If not, the dataset can infer schema from the containment relationships within the document. In general speaking, elements that are not scalar valued are mapped to tables, whereas attributes and scalar valued elements are mapped to columns.

2) The process of inferring schema is useful when constructing an application that has to consume XML that comes with no schema. But for production applications, it is highly desirable to take the inferred schema, modify it as appropriate, and load that schema in before the actual data is loaded. That way, the process of loading the document is deterministic, so you don’t have to worry about what a slight change in the incoming document will do to the inference heuristics.

Whatever the means for setting the dataset’s schema, when it comes time to load XML into the dataset the following rules are used:

1) Elements with a certain name are mapped into the dataset of the same table name.

2) Attributes and scalar-valued sub-elements are mapped into columns of that table.

3) The schema of the table is expanded as appropriate if the columns are not already in the dataset or if the dataset does not already contain a table by the same name.

When loading an XML schema into the dataset, a table is created for each complex type in the schema, and containment is expressed using primary/foreign key relationships. The key columns are automatically inserted into the schema, and a Data relation is added for each pair of related tables.

Therefore, when loading data that resides in multiple tables from SQL server or any other database that supports XML, it is in some ways more expedient to use the XML loading facilities rather than the DataSet command. The former enables loading all the data in one step, whereas the latter requires a dataset command per table, and also involves setting up the relationships between the tables manually.

Pawan Bangar, Technical Director, Birbals, #1047,Sector 42-b, Chandigarh. www.ebirbals.com, www.birbals.com

XML integration with ADO+
Comments Off
Top Rated White Papers and Resources

Comments are closed.