<scene> | | o---------------------o--------------------------o | | | | | | <object> <object> . . . <object> ... | ... | o----------------------o---------------------o | | . . . | | | | <subobj> <subobj> <subobj> ... | ... |-<shape> | |-<size> | |-<color>This serves as a standard template for all 3D graphics representations on the WWW. Now suppose that I wish to create a particular 3D scene with, say, a house and a tree. Then I would create a structure like this:
<scene> | | o------------------------o | | | | <object=House/> <object=Tree/> | | | | o----------------o---------------o | | | | | | | | | <subobj=wndw/> <subobj=door/> <subobj=door/> | | | | | | | | | |-<shape=rect/> |-<shape=rect/> |-<shape=rect/> | | | | | |-<size=2x3/> |-<size=8x3/> |-<size=8x3/> | | | | | |-<color=trans/> |-<color=blue/> |-<color=gray/> | | | o--------------------o | | | | <subobj=trunk/> <subobj=canopy/> | | |-<shape=cylind/> |-<shape=ball/> | | |-<size=3x40/> |-<size=80/> | | |-<color=brown/> |-<color=green/>My house and tree can be considered an instance of the generic 3D graphic structure designed by the expert 3D committee. I can test my instance by validating it against the syntax and semantics of the generic 3D structure, and if it validates successfully, I know that my scene can be displayed by the standard rendering engines created by the same committee.
Now the final scene can be displayed on the WWW using either HTML or XML, but there is a very major difference. In HTML, you merely get the final rendered scene, but with XML you get not only the final scene, but the entire hierarchical structure that created it. As a result, you can operate on this structure and modify, add, or delete branches. Thus you can change the color of the canopy of the tree (the tree in the picture and not the XML tree) from green to gold, can change the size of the window, add more windows, etc.
In more abstract terms we can say that XML allows individuals (or more usually, large user communities) to develop an information structure that is appropriate for their particular discipline. This structure is in the strict form of a hierarchical tree, and the user community determines the syntax of the tree and its semantics (what type of values are allowed, what range or number of values, etc).
Individuals who use this structure create instances of it that are populated with the specific nodes and values appropriate to their needs. The XML processor assures that any instance conforms both to the syntactical and semantic rules designed by the user community. Thus all members of this community posses a universal means of expressing and processing the information that is germane to their field.
Furthermore. although each discipline would develop a different information structure, that is, a different DTD, all such structures would have important properties in common, so that many concepts, and even some specific script programs, would apply to any field, be it physics, economics, entertainment, medicine, shopping, etc.
We can translate the above into XML parlance as follows:
And the specific XML data structure along with its DTD looks like this:
<?xml version="1.0" ?> <!-- Simple picture of house and tree --> <!DOCTYPE scene [ <!ELEMENT scene (object+)> <!ATTLIST object Id (House | Tree) "House"> <!ELEMENT object (subobj+)> <!ATTLIST subobj id (wndw|door|trunk|canopy) "door"> <!ELEMENT subobj (shape, size, color)> <!ELEMENT shape (#PCDATA)> <!ELEMENT size (#PCDATA)> <!ELEMENT color (#PCDATA)> ]> <scene> <object Id="House"> <subobj id="wndw"> <shape>rect</shape> <size>2x3</size> <color>trans</color> </subobj> <subobj id="door"> <shape>rect</shape> <size>8x3</size> <color>blue</color> </subobj> <subobj id="door"> <shape>rect</shape> <size>8x3</size> <color>gray</color> </subobj> </object> <object Id="Tree"> <subobj id="trunk"> <shape>cylind</shape> <size>3x40</size> <color>brown</color> </subobj> <subobj id="canopy"> <shape>ball</shape> <size>80</size> <color>green</color> </subobj> </object> </scene>
By the way, the illustration of 3D graphics by way of a tree structure
is not just an academic example:
real 3D graphic systems have long been defined in terms of
tree structures, even before XML was conceived. Here is an actual
example of a 3D graphic being designed in a VRML program:
In the pages that follow we will show how tree structures, such as the one above are defined in terms of a DTD or XML Schema.