Use XML
Abstract
XML technology can be used to represent structured information. This pattern helps determine when XML is an appropriate solution.
Problem
When data in a system needs to be imported or exported, it needs some type of representation. There are many possible representations for example: Comma Separated Values, Java Object Serialization, Proprietary Binary Formats, HTML, CORBA IIOP Streams, RDBMS tables, and of course XML. Choosing the proper representation for the data can be difficult.
Context
XML can be an appropriate choice when one or more of the following is needed:
- Content needs to be separate from its formatting.
- Data is shared between computers, applications or organizations.
- Human readable representation is needed.
- Readily available tools and resources.
There are some situations where XML may not be a good choice, among them is systems where:
- Terseness is important.
- In a homogeneous environment.
Forces
There are many forces to take into account when considering a data representation. Among the ones that XML can provide are simplicity, openness, extensibility, interoperability, and a technology with proven use.
Solution
Use XML for data representations.
Examples
Discussion
It is impossible to have a complete discussion of the factors involved in make the decision of a data representation in the space of a single pattern, but it can try to provide some pointers.
Related Patterns
All other patterns in this language depend on first using this pattern, because they assume that XML is being used.
Known Uses
There are many places where XML is being used successfully. Here is a small sampling of them.
- Data syndication. XML has been popular in this area, and several XML languages have been developed for this purpose.
-
The Information and Content Exchange (ICE) Protocol (http://www.icestandard.org)
-
moreover.com (http://w.moreover.com/) provides news feeds in several different XML flavors.
- News can be syndicated to browsers via
Rich Site Summary (http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html)
- Data exchange protocols for transport of messages from one system to another across a network.
-
SOAP (Simple Object Access Protocol) (http://www.w3.org/TR/SOAP/)
- Configuration files
J2EE uses Deployment Descriptors (http://java.sun.com/xml/ns/j2ee/) to configure various components
- Test Scripting
The XML Test Suite (http://xmltestsuite.sourceforge.net/)
- Log files
The LOGML(http://www.cs.rpi.edu/~puninj/LOGML/) specification is designed to describe log reports of web servers
- Web content management
- See
Ronald Bourret's Content Management Systems page (http://www.rpbourret.com/xml/ProdsCMS.htm)
-
Wireless Application Data (WAP) (http://www.openmobilealliance.org/)
References
For more information:
Simon St. Laurent's Essay -
Why XML? (http://www.simonstl.com/articles/whyxml.htm) .
A whitepaper by Bob Schloss at the IBM developerWorks site
Ten best bets for XML applications (http://www.digitalearth.net.cn/GISRelatedITIssues/XML/IBM-Ten%20best%20bets%20for%20XML%20applications.pdf)