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.

The XPath Query Eng<strong>in</strong>eXPath is a language that allows you to navigate with<strong>in</strong> <strong>XML</strong> documents. Th<strong>in</strong>k of XPathas a general-purpose query language <strong>for</strong> address<strong>in</strong>g, sort<strong>in</strong>g, and filter<strong>in</strong>g both theelements and the text of an <strong>XML</strong> document.The XPath notation is basically declarative. Any XPath expression is a path with<strong>in</strong> the<strong>XML</strong> document that identifies the <strong>in</strong><strong>for</strong>mation with the given characteristics. The pathdef<strong>in</strong>es a pattern, and the result<strong>in</strong>g selection <strong>in</strong>cludes all the nodes that match it. Theselection is expressed through a notation that emphasizes the hierarchical relationshipbetween the nodes. It works <strong>in</strong> much the same way files and folders work. For example,the XPath expression "book/publisher" means f<strong>in</strong>d the "publisher" element with<strong>in</strong> the"book" element. The XPath navigation model works <strong>in</strong> the context of a hierarchy ofnodes <strong>in</strong> the <strong>XML</strong> document's tree. XPath makes use of a variation of theXmlDocument class, named XPathDocument.Runn<strong>in</strong>g an XPath query is not actually different from execut<strong>in</strong>g a TransactSQL (T-SQL) query on SQL Server. Instead of gett<strong>in</strong>g back a collection of rows, a valid XPathexpression returns a collection of nodes. To scroll the returned nodes, you just use anXPath-customized version of a reader. We'll look at XPath <strong>in</strong> more detail <strong>in</strong> Chapter 6.ConclusionIn this chapter, we exam<strong>in</strong>ed the build<strong>in</strong>g blocks of <strong>XML</strong> and explored the rationalebeh<strong>in</strong>d <strong>XML</strong> readers and writers—a new and <strong>in</strong>novative way to per<strong>for</strong>m basicoperations on <strong>XML</strong> data sources. In the .<strong>NET</strong> Framework, <strong>XML</strong> readers <strong>in</strong>troduce adatabase-like cursor model to navigate through data. The cursor model fallssomewhere between the well-known <strong>XML</strong>DOM and SAX models. Not as expensive as<strong>XML</strong>DOM and more programmer-friendly than SAX, the .<strong>NET</strong> Framework cursor modelpresents <strong>XML</strong> as just another data <strong>for</strong>mat you can work on us<strong>in</strong>g a familiar approach.As a developer, you are certa<strong>in</strong>ly familiar with I/O operations accomplished on a file ora database. Why should <strong>XML</strong> data sources be totally different? The node becomes justanother atomic element, along with the database row or the byte. Ad hoc methodsmake it possible <strong>for</strong> you to move through nodes <strong>in</strong> a straight<strong>for</strong>ward, effective way.Readers and writers are not the only tools you can use to create <strong>XML</strong>-driven .<strong>NET</strong>applications. Another group of classes work accord<strong>in</strong>g to the specification of the W3CDOM. XSLT and XPath expressions are a pair of <strong>XML</strong>-related technologies that arepopular with developers and effective <strong>for</strong> arrang<strong>in</strong>g applications. In the .<strong>NET</strong>Framework, you f<strong>in</strong>d made-to-measure classes that make <strong>XML</strong>-to-<strong>XML</strong> trans<strong>for</strong>mationand query evaluation fast and easy.All the <strong>XML</strong> technologies <strong>in</strong>troduced <strong>in</strong> this chapter will be covered <strong>in</strong> depth <strong>in</strong> thechapters that follow, beg<strong>in</strong>n<strong>in</strong>g with <strong>XML</strong> readers <strong>in</strong> Chapter 2.Further Read<strong>in</strong>gThe W3C organization is currently work<strong>in</strong>g on a draft of the DOM Level 3 Core to<strong>in</strong>clude support <strong>for</strong> an abstract model<strong>in</strong>g schema and I/O serialization. Check out themost recent draft at http://www.w3.org/TR/2002/WD-DOM-Level3-ASLS-20020409. Theapproved standard—DOM Level 2 Core—is available at http://www.w3.org/TR/DOM-Level-2.Relevant <strong>in</strong><strong>for</strong>mation about <strong>XML</strong> standards is available from the W3C Web site, athttp://www.w3.org. If you want to learn more about the SAX specification, look at thenew Web site <strong>for</strong> the SAX project, at http://www.saxproject.org.19

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

Saved successfully!

Ooh no, something went wrong!