0% found this document useful (0 votes)
82 views1 page

Pitchers: Part I Introducing XML

This document discusses organizing XML data for baseball statistics. It notes that XML data is organized in a containment model where elements can contain text or other elements. It states that the first question to address is what elements should contain other elements, like whether a season contains leagues or a league contains seasons, as there is no single unique answer and it depends on usage. It also provides some examples of possible element containment relationships like a league containing divisions containing teams containing players.

Uploaded by

Sai Kuamr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views1 page

Pitchers: Part I Introducing XML

This document discusses organizing XML data for baseball statistics. It notes that XML data is organized in a containment model where elements can contain text or other elements. It states that the first question to address is what elements should contain other elements, like whether a season contains leagues or a league contains seasons, as there is no single unique answer and it depends on usage. It also provides some examples of possible element containment relationships like a league containing divisions containing teams containing players.

Uploaded by

Sai Kuamr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

3236-7 ch04.F.

qc

62

6/29/99

1:04 PM

Page 62

Part I Introducing XML

Note

The data in the previous table and the pitcher data in the next section is actually a
somewhat limited list that only begins to specify the data collected on a typical
baseball game. There are a lot more elements including throwing arm, batting
arm, number of times the pitcher balked (rare), fielding percentage, college
attended, and more. However, Ill stick to this basic information to keep the examples manageable.

Pitchers
Pitchers are not expected to be home-run hitters or base stealers. Indeed a pitcher
who can reach first on occasion is a surprise bonus for a team. Instead pitchers are
judged on a whole different set of numbers, shown in Table 4-2. Each column of this
table also defines an element. Some of these elements, such as name and position,
are the same for batters and pitchers. Others like saves and shutouts only apply to
pitchers. And a few like runs and home runs have the same name as a batter
statistic, but have different meanings. For instance, the number of runs for a batter
is the number of runs the batter scored. The number of runs for a pitcher is the
number of runs scored by the opposing teams against this pitcher.

Organization of the XML Data


XML is based on a containment model. Each XML element can contain text or
other XML elements called its children. A few XML elements may contain both
text and child elements, though in general this is bad form and should be avoided
wherever possible.
However, theres often more than one way to organize the data, depending on your
needs. One of the advantages of XML is that it makes it fairly straightforward to
write a program that reorganizes the data in a different form. Well discuss this
when we talk about XSL transformations in Chapter 14.
To get started, the first question youll have to address is what contains what? For
instance, it is fairly obvious that a league contains divisions that contain teams that
contain players. Although teams can change divisions when moving from one city
to another, and players are routinely traded at any given moment in time, each
player belongs to exactly one team and each team belongs to exactly one division.
Similarly, a season contains games, which contain innings, which contain at bats,
which contain pitches or plays.
However, does a season contain leagues or does a league contain a season? The
answer isnt so obvious, and indeed there isnt one unique answer. Whether it
makes more sense to make season elements children of league elements or league
elements children of season elements depends on the use to which the data will be
put. You can even create a new root element that contains both seasons and
leagues, neither of which is a child of the other (though doing so effectively would
require some advanced techniques that wont be discussed for several chapters
yet). You can organize the data as you like.

You might also like