<!-- DTD for baseball boxscores
     Clint Wrede
     2000 -->

<!-- The root element -->

<!ELEMENT boxscore             (scoreheader,dateinfo,batting,
                               linescore,pitching,finalmatter)>

<!-- scoreheader contains the simple results of the game, such as -->
<!-- New York 7, Atlanta 5 -->
<!-- along with an optional element, inningsnote, which tells if a game lasted -->
<!-- something other than the "normal" number of innings -->

<!ELEMENT scoreheader          (teamscore+,inningsnote?)>

<!-- teamscore contains a "winning" attribute, so that the winning team may always be -->
<!-- displayed first in scoreheader -->

<!ELEMENT teamscore            (team,teamfinalscore)>
<!ATTLIST teamscore winning    (winning|losing) #REQUIRED>
<!ELEMENT team                 (teamname)>

<!ELEMENT teamname             (teamlocation,teamnickname?)>
<!ELEMENT teamlocation         (#PCDATA)>
<!ELEMENT teamnickname         (#PCDATA)>
<!ELEMENT teamfinalscore       (#PCDATA)>
<!ELEMENT inningsnote          (#PCDATA)>

<!-- dateinfo contains simply the date of the game, along with a note that could indicate -->
<!-- unusual circumstance of the game on that date, such as the first or second game of -->
<!-- a doubleheader, the completion of a suspended game, etc. -->

<!ELEMENT dateinfo             (date,datenote?)>
<!ELEMENT date                 (#PCDATA)>
<!ELEMENT datenote             (#PCDATA)>

<!-- batting is the top "half" of the boxscore, showing the batting (and also baserunning and fielding) -->
<!-- stats for individual batters, one team at a time (which is the teambatting element). Several team-total -->
<!-- stats are also included -->

<!ELEMENT batting              (teambatting+)>
<!ELEMENT teambatting          (teamname,batter+,
                               ab,r,h,rbi,bb,so,lob,
                               footnote*,
                               tlob,dp?,tp?)>

<!-- batter is the element representing each batter and his stats for the game, starting with mandatory stats --> 
<!-- from the table portion of the boxscore, followed by the optional stats in the paragraph presentation -->

<!ELEMENT batter               (footnote-reference?,player,position+,
                               ab,r,h,rbi,bb,so,lob,avg,
                               x2b?,x3b?,hr?,sf?,sac?,gidp?,x2orbi?,
                               rlsp2o?,
                               sb?,cs?,po?,
                               e?,pb?)>

<!ELEMENT footnotereference    (#PCDATA)>

<!-- player is the generic element for both the batter and pitcher elements -->

<!ELEMENT player               (firstname?,lastname)>
<!ELEMENT firstname            (#PCDATA)>
<!ELEMENT lastname             (#PCDATA)>
<!ELEMENT position             (#PCDATA)>
                             
<!-- In the documents used for this project, ab, r, h, rbi, bb, so, lob, and avg -->
<!-- are the mandatory stats given for each batter in the table presentation. The -->
<!-- others are the "optional" paragraph items. -->

<!-- At-bats, the number of times the player came to the plate (with some exceptions) -->
<!ELEMENT ab                   (qty)>
<!-- Runs scored -->
<!ELEMENT r                    (qty)>
<!-- Safe hits made -->
<!ELEMENT h                    (qty)>
<!-- Runs batted in -->
<!ELEMENT rbi                  (qty,runningtotal?)>
<!-- Bases on balls, or walks -->
<!ELEMENT bb                   (qty)>
<!-- Strikeouts -->
<!ELEMENT so                   (qty)>
<!-- Runners left on base when this batter made an out -->
<!ELEMENT lob                  (qty)>
<!-- The batter's season-to-date batting average (h / ab) at the end of the game -->
<!ELEMENT avg                  (qty)>
<!-- Two-base hits, or doubles -->
<!ELEMENT x2b                  (qty,runningtotal,x2b3bi+)>
<!-- Three-base hits, or triples -->
<!ELEMENT x3b                  (qty,runningtotal,x2b3bi+)>
<!-- Home runs, or four-base hits -->
<!ELEMENT hr                   (qty,runningtotal,hri+)>
<!-- Sacrifce flys, flyball outs that allow a runner on third to score -->
<!ELEMENT sf                   (qty)>
<!-- Sacrifice bunts, a bunted out that allows other runners to advance a base -->
<!ELEMENT sac                  (qty)>
<!-- Grounded into double play -->
<!ELEMENT gidp                 (qty)>
<!-- RBIs made with two outs, considered a "clutch" performance -->
<!ELEMENT x2orbi               (qty)>
<!-- Runners left in scoring position with two outs, a negative version of x2orbi -->
<!ELEMENT rlsp2o               (qty)>
<!-- Stolen bases -->
<!ELEMENT sb                   (qty,runningtotal,sbcspoi+)>
<!-- Times caught (out) stealing -->
<!ELEMENT cs                   (qty,runningtotal,sbcspoi+)>
<!-- Times picked off a base -->
<!ELEMENT po                   (qty,sbcspoi+)>
<!-- Outfield assists, a defensive stat remarkable for its relative rarity -->
<!ELEMENT oa                   (qty,oai+)>
<!-- Errors in the field -->
<!ELEMENT e                    (qty,runningtotal,ei+)>
<!-- Passed ball, a special kind of error by the catcher -->
<!ELEMENT pb                   (qty)>

<!-- batter footnotes are used to explain pinch-hitting situations, such as -->
<!-- a-Smith singled for Jones in the seventh. -->
<!-- The "a" appears next to Smith's name in the table, and then the footnote appears -->
<!-- below the table. -->

<!ELEMENT footnote             (footnotereference,footnotecontent)>
<!ELEMENT footnotecontent      (#PCDATA)>
<!-- team left-on-base, not to be confused with the individual stat -->
<!ELEMENT tlob                 (qty)>
<!-- Double plays, fielding actions where two outs are made -->
<!ELEMENT dp                   (qty,dptpi+)>
<!-- Triple plays, same as above, but three outs -->
<!ELEMENT tp                   (qty,dptpi+)>

<!-- qty is a generic element in which to store the number for each stat in the DTD -->
<!ELEMENT qty                  (#PCDATA)>
<!-- Some stats show the players season-to-date running total for that stat -->
<!ELEMENT runningtotal         (#PCDATA)>
<!-- All of the elements ending in "i" are "incidents" used to group the extra information given with -->
<!-- that stat. This was necessary since these stats may be accomplished by a player more than once in -->
<!-- a game, prompting multiple incident groups.) -->
<!ELEMENT x2b3bi               (against,qty)>
<!ELEMENT hri                  (inning,against,on,out)>
<!-- The inning in which the stat was accomplished. -->
<!ELEMENT inning               (#PCDATA)>
<!-- The person(s) against whom the stat was accomplished. -->
<!ELEMENT against              (player+)>
<!-- How many runners were on base when a home run was hit. -->
<!ELEMENT on                   (#PCDATA)>
<!-- How many outs the team had when a home run was hit. -->
<!ELEMENT out                  (#PCDATA)>
<!ELEMENT sbcspoi              (base,against,qty)>
<!-- The base where an sb, cs, or po occurred. -->
<!ELEMENT base                 (#PCDATA)>
<!ELEMENT oai                  (against,base,qty)>
<!ELEMENT ei                   (errortype,qty)>
<!-- The type of error made (i.e., on a catch, a throw, etc. -->
<!ELEMENT errortype            (#PCDATA)>
<!ELEMENT dptpi                (player+,qty)>

<!-- The linescore shows the team's score for each inning, along with the final. -->
<!-- A stand-alone linescore might be thought of as a minimalistic boxscore. -->

<!ELEMENT linescore            (teamline+,linescorenote?)>
<!ELEMENT teamline             (teamname,inningscore+,teamfinalscore)>
<!ATTLIST teamline home        (home|visiting) #REQUIRED>
<!ELEMENT inningscore          (#PCDATA)>
<!-- linescorenote allows for a special kind of note indicating a game that was ended *not* -->
<!-- at the end of an inning (i.e., "Two outs when winning run scored." -->
<!ELEMENT linescorenote        (#PCDATA)>

<!-- pitching, teampitching, and pitcher are analagous to batting, teambatting, and batter, right down to  -->
<!-- the dual table-paragraph, mandatory-nonmandatory presentation -->

<!ELEMENT pitching             (teampitching+)>
<!ELEMENT teampitching         (teamname,pitcher+)>

<!ELEMENT pitcher              (player,
                               decision*,
                               ip,hp,rp,er,bbp,sop,hrp,era,
                               e?,ibb?,hbp?,wp?,b?,(pi,st)?,(gb,fb)?,bf?,pitchedbattersnote?)>

<!-- decsisions are oft-cited but complicated statistics awarded to pitchers, such as wins, losses, and saves -->
<!ELEMENT decision             (decisiontype,runningtotal)>
<!ELEMENT decisiontype         (#PCDATA)>
<!-- Innings pitched -->
<!ELEMENT ip                   (qty)>
<!-- Hits allowed ("hp" for hits-pitcher, to distinguish them from batters' hits, as with other stats below. -->
<!ELEMENT hp                   (qty)>
<!-- Runs allowed -->
<!ELEMENT rp                   (qty)>
<!-- Earned runs allowed, a quite complicated calculation -->
<!ELEMENT er                   (qty)>
<!-- Bases on balls allowed -->
<!ELEMENT bbp                  (qty)>
<!-- Strikeouts made -->
<!ELEMENT sop                  (qty)>
<!-- Home runs allowed -->
<!ELEMENT hrp                  (qty)>
<!-- The pitcher's season-to-date earned-run average after the end of the game, the average number of earned runs -->
<!-- allowed over a nine-inning period -->
<!ELEMENT era                  (qty)>
<!-- Intentional bases on balls -->
<!ELEMENT ibb                  (qty,against)>
<!-- Batters hit by a pitch and thus awarded first base -->
<!ELEMENT hbp                  (qty,against)>
<!-- Wild pitch, a special kind of pitcher's error -->
<!ELEMENT wp                   (qty)>
<!-- Balks, a complicated infraction -->
<!ELEMENT b                    (qty)>
<!-- Pitches thrown -->
<!ELEMENT pi                   (qty)>
<!-- Strikes thrown -->
<!ELEMENT st                   (qty)>
<!-- Ground ball outs made by pitcher's defense during his play -->
<!ELEMENT gb                   (qty)>
<!-- Fly ball outs made by pitcher's defense during his play -->
<!ELEMENT fb                   (qty)>
<!-- Batters faced -->
<!ELEMENT bf                   (qty)>
<!-- A season-to-date total for the decision element -->
<!ELEMENT runningrecord        (#PCDATA)>
<!-- A special note to show time pitched not reflected by ip stat, such as -->
<!-- "Jones pitched to three batters in the 8th" -->
<!ELEMENT pitchedbattersnote   (numberbatters,battersinning)>
<!ELEMENT numberbatters        (#PCDATA)>
<!ELEMENT battersinning        (#PCDATA)>

<!-- The finalmatter sums up some information only incidental to the game itself. -->

<!ELEMENT finalmatter          (umpires?,time?,attendance?,
                               conditions?,link?)>
<!-- The names and positions of the game's umpires. -->
<!ELEMENT umpires              (umpire+)>
<!ELEMENT umpire               (position?,umpirename)>
<!ELEMENT umpirename           (firstname?,lastname)>
<!-- The elapsed time of the game. -->
<!ELEMENT time                 (#PCDATA)>
<!-- The game's official attendance. -->
<!ELEMENT attendance           (#PCDATA)>
<!-- The climactic conditions under which the game was played. -->
<!ELEMENT conditions           (indoors|(weather,wind?))>
<!-- For domed stadiums. -->
<!ELEMENT indoors              (#PCDATA)>
<!ELEMENT weather              (temperature,skyconditions)>
<!ELEMENT temperature          (#PCDATA)>
<!-- Cloud, sunny, etc. -->
<!ELEMENT skyconditions        (#PCDATA)>
<!ELEMENT wind                 (speed,direction)>
<!ELEMENT speed                (#PCDATA)>
<!-- Direction expressed in terms of the field of play, such as "in from left" or "out to right." -->
<!ELEMENT direction            (#PCDATA)>
<!-- A link to a fuller, textual game description. -->
<!ELEMENT link                 (#PCDATA)>

<!NOTATION jpeg SYSTEM "netscape.exe">