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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>XML</strong>DOM model (memory footpr<strong>in</strong>t and bandwidth required to process largedocuments) are structural and stem directly from design choices.SAX parsers work by lett<strong>in</strong>g client applications pass liv<strong>in</strong>g <strong>in</strong>stances of plat<strong>for</strong>m-specificobjects to handle parser events. The parser controls the whole process and pushesdata to the application, which is <strong>in</strong> turn free to accept or simply ignore the data. TheSAX model is extremely lean and features a limited complexity <strong>in</strong> space.The .<strong>NET</strong> Framework provides full support <strong>for</strong> the <strong>XML</strong>DOM pars<strong>in</strong>g model but not <strong>for</strong>the SAX model. The set of .<strong>NET</strong> Framework <strong>XML</strong> core classes supports two parsermodels: <strong>XML</strong>DOM and a new model called an <strong>XML</strong> reader. The lack of support <strong>for</strong> SAXparsers does not mean that you have to renounce the functionality that a SAX parsercan br<strong>in</strong>g, however. All the functions of a SAX parser can be easily and even moreeffectively implemented us<strong>in</strong>g an <strong>XML</strong> reader. Unlike a SAX parser, a .<strong>NET</strong> Framework<strong>XML</strong> reader works under the total control of the client application, enabl<strong>in</strong>g theapplication to pull out only the data it really needs and skip over the rema<strong>in</strong>der of the<strong>XML</strong> stream.Readers are based on .<strong>NET</strong> Framework streams and work <strong>in</strong> much the same way as adatabase cursor. Interest<strong>in</strong>gly, the classes that implement this cursor-like pars<strong>in</strong>g modelalso provide the substrate <strong>for</strong> the .<strong>NET</strong> Framework implementation of the <strong>XML</strong>DOMparser. Two abstract classes—XmlReader and XmlWriter—are at the very foundation ofall .<strong>NET</strong> Framework <strong>XML</strong> classes, <strong>in</strong>clud<strong>in</strong>g <strong>XML</strong>DOM classes, ADO.<strong>NET</strong>-relatedclasses, and configuration classes. So <strong>in</strong> the .<strong>NET</strong> Framework you have two possibleapproaches when it comes to process<strong>in</strong>g <strong>XML</strong> data. You can use either any classesdirectly built onto XmlReader and XmlWriter or classes that expose <strong>in</strong><strong>for</strong>mation throughthe well-known <strong>XML</strong>DOM.The set of <strong>XML</strong> core classes also <strong>in</strong>cludes tailor-made class hierarchies to supportother related <strong>XML</strong> technologies such as XSLT, XPath expressions, and the SchemaObject Model (SOM).We'll look at <strong>XML</strong> core classes and related standards <strong>in</strong> the follow<strong>in</strong>g chapters. Inparticular, Chapter 2, Chapter 3, Chapter 4, and Chapter 5 describe the core classesand pars<strong>in</strong>g models. Chapter 6 and Chapter 7 exam<strong>in</strong>e the related standards, such asXPath and XSL.<strong>XML</strong> and ADO.<strong>NET</strong>The <strong>in</strong>teraction between ADO.<strong>NET</strong> classes and <strong>XML</strong> documents takes one of two<strong>for</strong>ms:• Serialization of ADO.<strong>NET</strong> objects (<strong>in</strong> particular, the DataSet object) to<strong>XML</strong> documents and correspond<strong>in</strong>g deserialization. Data can be saved to<strong>XML</strong> <strong>in</strong> a variety of <strong>for</strong>mats, with or without schema <strong>in</strong><strong>for</strong>mation, as a fullsnapshot of the <strong>in</strong>-memory data <strong>in</strong>clud<strong>in</strong>g pend<strong>in</strong>g changes and errors, orwith just the current <strong>in</strong>stance of the data.• A dual-access model that lets you access and update the same piece ofdata either through a hierarchical programm<strong>in</strong>g <strong>in</strong>terface or us<strong>in</strong>g theADO.<strong>NET</strong> relational API. Basically, you can trans<strong>for</strong>m a DataSet object<strong>in</strong>to an <strong>XML</strong>DOM object and view the <strong>XML</strong>DOM's subtrees as tablesmerged with the DataSet object's tables.The ADO.<strong>NET</strong> DataSet class represents the only .<strong>NET</strong> Framework object that can benatively saved to <strong>XML</strong>. The <strong>XML</strong> representation of a DataSet object can have twodifferent layouts: the ADO.<strong>NET</strong> normal <strong>for</strong>m and the DiffGram <strong>for</strong>mat. In particular, theDiffGram <strong>for</strong>mat describes the history of the data and all recent changes. Eachchanged row <strong>in</strong> each table is represented by two nodes: the first node conta<strong>in</strong>s the9

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

Saved successfully!

Ooh no, something went wrong!