Java Reference
In-Depth Information
< LastName > Turner < /LastName >
< /Name >
< AgeInYears > 49 < /AgeInYears >
< Sex > Male < /Sex >
< Smoker > No < /Smoker >
</LifeExpectancyParameters>
Even without understanding the XML syntax, the meaning of each value is man-
ifest. The fact that each value is associated with a “tag” that identifies the data
value's meaning is what is meant by the phrase “self-describing data.”
The XML tags are reminiscent of HTML tags, but, unlike HTML, the tag
names may be anything you want! The < Smoker > tag, for instance, could be
changed to < Nonsmoker > , with a corresponding change of the value to Yes ,
and the meaning would still be clear. The fact that programmers are free to make
up their own tag names is the “extensible” part of XML.
Let us now return to the “self-describing” aspect of XML data. As demon-
strated above, the XML syntax permits, and even strongly encourages, data to be
associated with human-readable tags that identify the meaning of the data values.
This tagging is done for the benefit of humans, not computers. Computers are
just as happy to receive a string of ASCII or even binary data as long as they are
programmed to know the order and meaning of each parameter. There is nothing,
for example, in XML that prevents us creating a document like this:
<LifeExpectancyParams>Jackson Turner 49 Male
No</LifeExpectancyParams>
The server can receive and decode this document and perform exactly the same
calculation as with the previous document. The disadvantage of this second XML
example is that it is not as meaningful to humans , not that it is less meaningful to
a computer or more difficult to process. In fact, parsing this second document is
probably much easier for a computer than the previous document. And the second
document is certainly much shorter, requiring considerably less bandwidth than
the first XML document. Shorter still, and even easier for a computer to “parse”
is the binary format that would be used by RMI or CORBA. The self-describing
aspect of XML documents is for humans, not computers.
However, just seeing the XML document shown above - the good one, with
meaningful tags - does little to define what is to be done with the data. In that
sense, the data may be somewhat self-describing, but the XML data alone provides
no description of how it will be used. There still needs to be some documentation
that describes how a server uses the data for there to be true understanding of the
meaning of the data itself. Just as important, both client and server must agree
on the XML tags to be used. It would not be successful for a client to use the
< Nonsmoker > tag while the server is expecting a < Smoker > tag. So there still
must be close cooperation among clients and servers.
Search WWH ::




Custom Search