Figuring Out What XML Is Good For

Case studies of XML never fail to mention new and exciting possibilities where XML adds value to existing environments — or solves previously intractable problems. That's probably why XML applications are widely used for everything from displaying chemical formulas to setting up a family tree. So how can you use the power of XML?



Classifying information


One of the more useful functions of XML involves classifying information. To see how this would work, imagine yourself in the business of selling books.



Books can be classified in many ways, but we kind of like the following classification scheme:



  • Title

  • Author

  • Publisher

  • Price

  • Content Type (Fiction, Nonfiction)

  • Format (Paperback, Hardback)

  • ISBN

Using XML, you can create tags to classify this information. The following code shows a possible XML format for one book:



<book>
<title>Night Fall</title>
<author>Demille, Nelson</author>
<publisher>Warner</publisher>
<price>$26.95</price>
<contentType>Fiction</contentType>
<format>Hardback</format>
<isbn>0446576638</isbn>
</book>



Giving your tags meaningful names that actually reflect the content makes it easier to work with the information.



Classifying the information as shown here makes it possible for you to search for — and retrieve — any item with ease. For example, after the information on all the books for your imaginary book business is collected and tucked away in XML format, you can create a list of all the authors — or authors and titles, or titles and ISBNs, whatever information you want to access. (Talk about power at your fingertips!)



Enforcing rules on your data


XML excels at allowing you to create rules for the format of your data. Using either Document Type Definitions (DTDs) or XML Schemas to validate your data gives you two immediate advantages:



  • It helps ensure the accuracy of the information you collect.

  • It helps ensure that the information gathered is in the most usable format for your business needs.tabmark

Outputting information in a variety of ways


Outputting your data means releasing it from its storage locker — presumably somewhere inside the guts of your computer — and getting it to some other place where it can be a bit more useful. The great thing about XML documents is that they're not limited to any particular form of output; they can end up in a variety of different places, in whatever form is appropriate — for example, in a database, a computer monitor, a printer, or a PDA.



XML documents are at home in a wide range of processes. The phrase post-processing was practically tailor-made for XML; it means taking information from a document and using it in some other process or program. For example, suppose you receive a purchase order in the form of an XML document. An application that understands XML purchase orders can use that data to determine which items (and in what quantities) have been ordered — and can even send instructions to another piece of software to generate a pick list so the order can be picked, packed, and shipped from the warehouse.



In many cases, XML documents are used with stylesheets to provide high-quality output on-screen. You can use the same data, however, to send information to a speech-synthesis program that reads the text to a person who is vision impaired. Alternatively, that same data might also create output on a Braille reader. The same document with a layout program and a stylesheet also might be used for high-quality printouts.



The beauty of this concept is that you never need to fuss and fidget with the XML data to create output for different devices. You need only use different pieces of software that can read XML and can provide the output for a particular format or output device.



Using the same data across platforms


The good news looks, at first, like no news: XML documents are not specific to any particular platform or programming language. Okay, why is that something to e-mail home about? Think versatility. Suppose you want to exchange database information across the Web — say, use a Web browser to send information from a user questionnaire back to a Web server. To accomplish this task (and many others), you need a document format that is



  • Extensible: An extensible format is one that can be tailored or customized for specific applications.

  • Open: It's well documented and widely available.

  • Nonproprietary: It's expressed in an accepted or standard form of notation that isn't the exclusive property of some individual, company, or organization.

These characteristics enable the document to adapt to changing conditions, to take best advantage of the work of others, and to avoid incurring extra expense or legal liability.



Guess what? XML meets all three requirements for a document format for exchanging data — it's open, extensible, and nonproprietary. No surprise, then, that XML is the best choice for data exchange; those three magic characteristics make it a handy, consistent way to hand data around among multiple applications and multiple platforms with the most efficiency and least hassle.



dummies

Source:http://www.dummies.com/how-to/content/figuring-out-what-xml-is-good-for.html

No comments:

Post a Comment