London Heathrow
LHR
2
From the above XML samples, we can see how easy it is to extend XML and add new
elements, attributes or entire structures into an XML file. Describing data structures
in XML however, is only half of the problem. How do we know that the XML we
have received is the XML we are expecting? What if we described our airport XML
requirements as:
We need an airport element with fields for
name
IATA code
number of runways
Our XML sample above meets these requirements, but so does the sample below.
Which one is correct?
??? ??? ???
Chapter 7
[ 143 ]
Given the lack of any description of our XML requirements, both XML files are
completely valid, however there is no way that an application would be able to
parse both of these XML files and obtain the same results. XML Schema answers our
problems here by allowing us to describe how the XML should be defined. Using
XML Schema, there are no ambiguities as to whether:
name is an attribute
the IATA code is an element called iata or an attribute called "id"
the numberOfRunways is an element or attribute
numberOfRunways takes an integer or a string.
Pages:
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136