13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>in</strong>cludes <strong>in</strong><strong>for</strong>mation about changes as well as pend<strong>in</strong>g errors. Keep <strong>in</strong> m<strong>in</strong>d thatstateless and stateful refer to the data <strong>in</strong> the DataSet object but not to the DataSetobject as a whole.In this chapter, we'll focus on the stateless representation of the DataSet object, withjust a glimpse at the stateful representation—the DiffGram <strong>for</strong>mat. In Chapter 10, we'lldelve <strong>in</strong>to the DiffGram's structure and goals.The <strong>XML</strong> representation of a DataSet object can be written to a file, a stream, anXmlWriter object, or a str<strong>in</strong>g us<strong>in</strong>g the WriteXml method. It can <strong>in</strong>clude, or not <strong>in</strong>clude,XSD schema <strong>in</strong><strong>for</strong>mation. The actual behavior of the WriteXml method can becontrolled by pass<strong>in</strong>g the optional XmlWriteMode parameter. The values <strong>in</strong> theXmlWriteMode enumeration determ<strong>in</strong>e the output's layout. The overloads of the methodare shown <strong>in</strong> the follow<strong>in</strong>g list<strong>in</strong>g:public void WriteXml(Stream, XmlWriteMode);public void WriteXml(str<strong>in</strong>g, XmlWriteMode);public void WriteXml(TextWriter, XmlWriteMode);public void WriteXml(XmlWriter, XmlWriteMode);WriteXml provides four additional overloads with the same structure as this code butwith no explicit XmlWriteMode argument.The stateless representation of the DataSet object takes a snapshot of the currentstatus of the object. In addition to data, the representation <strong>in</strong>cludes tables, relations,and constra<strong>in</strong>ts def<strong>in</strong>itions. The rows <strong>in</strong> the tables are written only <strong>in</strong> their currentversions, unless you use the DiffGram <strong>for</strong>mat—which would make this a statefulrepresentation. The follow<strong>in</strong>g schema shows the ADO.<strong>NET</strong> normal <strong>for</strong>m—that is, the<strong>XML</strong> stateless representation of a DataSet object:...............⋮The root tag is named after the DataSet object. If the DataSet object has no name, thestr<strong>in</strong>g NewDataSet is used. The name of the DataSet object can be set at any timethrough the DataSetName property or via the constructor upon <strong>in</strong>stantiation. Each table<strong>in</strong> the DataSet object is represented as a block of rows. Each row is a subtree rooted <strong>in</strong>a node with the name of the table. You can control the name of a DataTable object viathe TableName property. By default, the first unnamed table added to a DataSet objectis named Table. A trail<strong>in</strong>g <strong>in</strong>dex is appended if a table with that name already exists.The follow<strong>in</strong>g list<strong>in</strong>g shows the <strong>XML</strong> data of a DataSet object named Northw<strong>in</strong>dInfo:327

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!