]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/Heartbeat.hs
Add SportInfo support for NFLRushingLeadersXML.dtd.
[dead/htsn-import.git] / src / TSN / XML / Heartbeat.hs
index a3a169347385b3197f018af5d914c4b1c5a6e266..8fafba1c6c80d6435793a1345ab733329ebfc9a9 100644 (file)
@@ -3,12 +3,14 @@
 -- | Handle documents defined by Heartbeat.dtd.
 --
 module TSN.XML.Heartbeat (
+  dtd,
   verify,
   -- * Tests
   heartbeat_tests )
 where
 
 -- System imports.
+import Data.Time.Clock ( UTCTime )
 import Data.Tuple.Curry ( uncurryN )
 import Test.Tasty ( TestTree, testGroup )
 import Test.Tasty.HUnit ( (@?=), testCase )
@@ -24,9 +26,15 @@ import Text.XML.HXT.Core (
 
 -- Local imports.
 import TSN.DbImport ( ImportResult(..) )
+import TSN.Picklers ( xp_time_stamp )
 import Xml ( pickle_unpickle, unpickleable )
 
 
+-- | The DTD to which this module corresponds.
+--
+dtd :: String
+dtd = "Heartbeat.dtd"
+
 -- | The data structure that holds the XML representation of a
 --   Heartbeat message.
 --
@@ -34,7 +42,7 @@ data Message =
   Message {
     xml_file_id :: Int,
     heading :: String,
-    time_stamp :: String }
+    time_stamp :: UTCTime }
   deriving (Eq, Show)
 
 
@@ -47,7 +55,7 @@ pickle_message =
     xpWrap (from_tuple, to_tuple) $
     xpTriple (xpElem "XML_File_ID" xpInt)
              (xpElem "heading" xpText)
-             (xpElem "time_stamp" xpText)
+             (xpElem "time_stamp" xp_time_stamp)
   where
     from_tuple = uncurryN Message
     to_tuple m = (xml_file_id m,
@@ -63,7 +71,7 @@ verify :: XmlTree -> IO ImportResult
 verify xml = do
   let root_element = unpickleDoc pickle_message xml
   return $ case root_element of
-    Nothing -> ImportFailed "Could not unpickle document in import_generic."
+    Nothing -> ImportFailed "Could not unpickle document to be verified."
     Just _  -> ImportSkipped "Heartbeat received. Thump."
 
 --