The Power of XML

IOTA^_^    

ASP.NET Developer's JumpStart
By Paul D. Sheriff, Ken Getz
Table of Contents
Chapter 27.  Introduction to XML


You might wonder why XML is suddenly so popular. To understand the popularity, you must consider the alternatives. Humans and computers need some standardized way of moving data from one application to another or from one computer to another. The transport mechanism needs to have the following qualities:

  • Self-describing. It must require no external support to "understand" the data.

  • Able to maintain full data integrity. It must transport all the information about the data, including types, relations, and so on.

  • Able to move through firewalls and across the Internet.

  • Extensible. You must be able to extend the standard without breaking existing uses.

  • Universally understood and subscribes to an open standard.

Think of some common mechanisms for transporting data:

  • Comma-delimited text files

  • ActiveX Data Objects (ADO) recordsets

  • Hypertext Markup Language (HTML)

  • Electronic Data Interchange (EDI)

Each of these is popular and in wide use. However, each fails the requirements in at least one way. Comma-delimited text files can't really include full information about data and relations they simply maintain a set of rows and columns. Recordsets can provide full data integrity, but because they're binary objects (and limited to Windows and COM), they aren't universally understood nor can they pass through firewalls easily. HTML is great for displaying content, but it can't be extended and is just a bit too flexible for data management. EDI is totally proprietary, and many different, incompatible "flavors" are currently in use.

XML solves all these problems by providing text-based data in a standard, yet totally extensible package. In this chapter, you'll begin to see how XML makes it possible to describe just about any type of data, and it can be used to transport that data over the Internet (and within applications, as well).

NOTE

Although you won't often need to investigate the inner workings of XML for most of your applications, most applications use XML "under the covers" in one way or another. The .NET Framework uses XML to transmit data between tiers of a multitiered application, and .NET handles this data transfer for you. If you want to step in and modify the XML being sent from one place to another, you can. When you return a DataSet from a component, or when you return data from a Web Service (coming up in the next chapters), you're sending XML from one component to another.


What About HTML?

You might be confused as to the differences and similarities between HTML and XML. Perhaps you thought that XML was a "superset" of HTML, but that's not true. HTML is a markup language devised for including layout and style information it provides little or no information about its actual content. For example, the following HTML indicates how the text should be displayed but conveys no information about what the information actually is:

 <b>May 16 1956</b> 

The <b> and </b> tags indicate that the text within should be displayed in boldface, but nothing more than that.

XML, however, can convey information about the content; using XML "helpers" such as XSL (a set of elements created in XML specifically geared toward formatting XML data), you can include formatting information as well. For example, this XML indicates the usage of its content:

 <birthdate>May 16, 1956</birthdate> 

This fragment doesn't contain any formatting information (you'll learn a little about XSL later in the chapter), but it does at least indicate the significance of its contents.

XML's Helpers

XML itself is quite simple it's just a combination of elements, attributes, and text, for the most part. On its own, it doesn't seem all that powerful. The most powerful part about XML, however, is that it's not just a language: It's a language for defining other languages. For example, developers have already created the following list of grammars of XML (languages created in XML), and this is a tiny subset of a growing list of specific tools created in XML:

  • XML Schema. Defines a custom markup language created in XML. Just as a database schema defines the columns of a database table, XML Schema defines what content can appear within an XML file. Without a schema, XML data is really nothing more than structured text. With a schema, XML data is a representation of structured data.

  • XSLT (Extensible Stylesheet Language Transformation). Defines a language that allows you to format and transform XML data into any other format. Using XSLT, you can shape and format the data any way you require. You'll see an example later that uses XSLT to transform XML data into an HTML table.

  • XPath. Defines a language that allows you to search within a set of XML data for elements meeting specified criteria. Much as you use SQL to query relational data, you use XPath to query XML data.

TIP

For more information on XML and the growing set of grammars created using XML, visit the World Wide Web Consortium site at http://www.w3.org. You'll find white papers, specifications, training, up-to-the-minute documentation, and more.



    IOTA^_^    
    Top


    ASP. NET Developer's JumpStart
    ASP.NET Developers JumpStart
    ISBN: 0672323575
    EAN: 2147483647
    Year: 2002
    Pages: 234

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net