-- | GameInfo represents a collection of DTDs that we don't really -- handle but want to make available. The raw XML gets stored in the -- database along with the XML_File_ID, but we don't parse any of it. -- -- See also: TSN.XML.SportInfo -- module TSN.XML.GameInfo ( dtds, from_xml ) where import Data.Time.Clock ( UTCTime ) import Text.XML.HXT.Core ( XmlTree ) import Text.XML.HXT.DOM.ShowXml ( xshow ) import TSN.Parse ( parse_message, parse_xmlfid, parse_xml_time_stamp ) -- | The DTDs for everything that we consider "Game Info." -- -- TODO: This is the list from the old implementation. We need to -- make sure that we are really receiving XML for these DTDs -- (i.e. the names are correct). -- dtds :: [String] dtds = [ "CBASK_Lineup_XML.dtd", "cbaskpreviewxml.dtd", "cflpreviewxml.dtd", "Matchup_NBA_NHL_XML.dtd", "mlbpreviewxml.dtd", "MLB_Gaming_Matchup_XML.dtd", "MLB.dtd", "MLB_Lineup_XML.dtd", "MLB_Matchup_XML.dtd", "MLS_Preview_XML.dtd", "NBA_Gaming_Matchup_XML.dtd", "NBA.dtd", "NBA_Playoff_Matchup_XML.dtd", "NBALineupXML.dtd", "nbapreviewxml.dtd", "NCAA_FB_Preview_XML.dtd", "nflpreviewxml.dtd", "NFL_NCAA_FB_Matchup_XML.dtd", "nhlpreviewxml.dtd", "recapxml.dtd", "WorldBaseballPreviewXML.dtd" ] -- | The data structure that holds the XML representation of a -- GameInfo message. -- data Message = Message { dtd :: String, xml_file_id :: Int, time_stamp :: UTCTime, xml :: String } deriving (Eq, Show) from_xml :: String -> XmlTree -> Either String Message from_xml dtdname xmltree = do xmlfid <- parse_xmlfid xmltree timestamp <- parse_xml_time_stamp xmltree message <- parse_message xmltree return $ Message dtdname (fromInteger xmlfid) timestamp (xshow [message])