Document- Versus Data-Centric XML
Generally speaking, there are two broad application areas of XML
technologies. The first
Document-Centric XML
Because of its SGML origins, in the early days of its existence
XML
The following markup is a perfect example of XML used in a
document-centric manner. The content is directed towards human
consumptionit's part of the FastGlide skateboard
<H1>Skateboard Usage Requirements</H1> <P>In order to use the <B>FastGlide</B> skateboard you have to have:</P> <LIST> <ITEM>A strong pair of legs.</ITEM> <ITEM>A reasonably long stretch of smooth road surface.</ITEM> <ITEM>The impulse to impress others.</ITEM> </LIST> <P>If you have all of the above, you can proceed to <LINK HREF="Chapter2.xml">Getting on the Board</LINK>.</P> Data-Centric XMLBy contrast, data-centric XML is used to mark up highly structured information such as the textual representation of relational data from databases, financial transaction information, and programming language data structures. Data-centric XML is typically generated by machines and is meant for machine consumption. It is XML's natural ability to nest and repeat markup that makes it the perfect choice for representing these types of data. Consider the purchase order example in Listing 2.1. It is a purchase order from the Skateboard Warehouse, retailer of skateboards to SkatesTown. The order is for 5 backpacks, 12 skateboards, and 1,000 SkatesTown promotional stickers (this is what the stock keeping unit [SKU] of 008-PR stands for). Listing 2.1 Purchase Order in XML
<po id="43871" submitted="2001-10-05">
<billTo>
<company>The Skateboard Warehouse</company>
<street>One Warehouse Park</street>
<street>Building 17</street>
<city>Boston</city>
<state>MA</state>
<postalCode>01775</postalCode>
</billTo>
<shipTo>
<company>The Skateboard Warehouse</company>
<street>One Warehouse Park</street>
<street>Building 17</street>
<city>Boston</city>
<state>MA</state>
<postalCode>01775</postalCode>
</shipTo>
<order>
<item sku="318-BP" quantity="5">
<description>Skateboard backpack; five pockets</description>
</item>
<item sku="947-TI" quantity="12">
<description>Street-style titanium skateboard.</description>
</item>
<item sku="008-PR" quantity="1000">
</item>
</order>
</po>
The use of XML is very different from the previous user guide example:
In short, if you can easily imagine the XML as a data structure in your favorite programming language, you are probably looking at a data-centric use of XML. An example Java class that could, with a bit more work, be used to represent the purchase order data is shown here:
class PO
{
int id;
Date submitted;
Address billTo;
Address shipTo;
Item order[];
}
Document Lifetime
Document- and data-centric uses of XML can
Web services are about data-centric uses of XML. Through the rest of this chapter and the rest of this book, we will purposefully ignore discussing document-centric XML. |