Java Reference
In-Depth Information
Having said that, we don't have complete freedom of where we can put whitespace within a tag, as we
have already seen. The tag name must immediately follow the opening < or </ in a tag and there can
be no space within an opening </ delimiter, or a closing /> delimiter in the case of an empty element.
You must also separate an attribute from the tag name or from another attribute with at least one space.
Beyond that you can put additional spaces within a tag wherever you like.
Data Structure in XML
The ability to nest elements is fundamental to defining the structure of the data in a document. We can
easily represent the structure of the data in our XML fragment defining an address, as shown below.
address
housenumber
street
city
state
zip
Chicago
29
South Lasalle Street
Illinois
60603
The structure follows directly from the nesting of the elements. The <address> element contains all of
the others directly, so the nested elements are drawn as subsidiary or child elements of the <address>
element. The items that appear within the tree structure - the elements and the data items - are referred
to as nodes .
The diagram below shows the structure of the first circle definition in XML that we created in the
previous section. Even though there's an extra level of elements in this diagram, there are strong
similarities to the structure above.
circle
position
radius
15
y-coordination
x-coordination
30
50
We can see that both structures have a single root element, <address> in the first example and
<circle> in the second. We can also see that each element contains either other elements or some
data that is a segment of the document content. In both diagrams all the document content lies at the
bottom. Nodes at the extremities of a tree are referred to as leaf nodes .
Search WWH ::




Custom Search