]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blob - src/TSN/XML/GameInfo.hs
Begin the implementation of TSN.XML.GameInfo.
[dead/htsn-import.git] / src / TSN / XML / GameInfo.hs
1 -- | GameInfo represents a collection of DTDs that we don't really
2 -- handle but want to make available. The raw XML gets stored in the
3 -- database along with the XML_File_ID, but we don't parse any of it.
4 --
5 -- See also: TSN.XML.SportInfo
6 --
7 module TSN.XML.GameInfo (
8 dtds,
9 from_xml )
10 where
11
12 import Data.Time.Clock ( UTCTime )
13 import Text.XML.HXT.Core ( XmlTree )
14 import Text.XML.HXT.DOM.ShowXml ( xshow )
15
16 import TSN.Parse (
17 parse_message,
18 parse_xmlfid,
19 parse_xml_time_stamp )
20
21 -- | The DTDs for everything that we consider "Game Info."
22 --
23 -- TODO: This is the list from the old implementation. We need to
24 -- make sure that we are really receiving XML for these DTDs
25 -- (i.e. the names are correct).
26 --
27 dtds :: [String]
28 dtds =
29 [ "CBASK_Lineup_XML.dtd",
30 "cbaskpreviewxml.dtd",
31 "cflpreviewxml.dtd",
32 "Matchup_NBA_NHL_XML.dtd",
33 "mlbpreviewxml.dtd",
34 "MLB_Gaming_Matchup_XML.dtd",
35 "MLB.dtd",
36 "MLB_Lineup_XML.dtd",
37 "MLB_Matchup_XML.dtd",
38 "MLS_Preview_XML.dtd",
39 "NBA_Gaming_Matchup_XML.dtd",
40 "NBA.dtd",
41 "NBA_Playoff_Matchup_XML.dtd",
42 "NBALineupXML.dtd",
43 "nbapreviewxml.dtd",
44 "NCAA_FB_Preview_XML.dtd",
45 "nflpreviewxml.dtd",
46 "NFL_NCAA_FB_Matchup_XML.dtd",
47 "nhlpreviewxml.dtd",
48 "recapxml.dtd",
49 "WorldBaseballPreviewXML.dtd" ]
50
51
52 -- | The data structure that holds the XML representation of a
53 -- GameInfo message.
54 --
55 data Message =
56 Message {
57 dtd :: String,
58 xml_file_id :: Int,
59 time_stamp :: UTCTime,
60 xml :: String }
61 deriving (Eq, Show)
62
63
64 from_xml :: String -> XmlTree -> Either String Message
65 from_xml dtdname xmltree = do
66 xmlfid <- parse_xmlfid xmltree
67 timestamp <- parse_xml_time_stamp xmltree
68 message <- parse_message xmltree
69 return $ Message dtdname (fromInteger xmlfid) timestamp (xshow [message])
70