- | dtd == "Odds_XML.dtd" = do
- let m = unpickleDoc xpickle xml :: Maybe Odds.Message
- let errmsg = "Could not unpickle Odds_XML."
- maybe (return $ ImportFailed errmsg) migrate_and_import m
+ | dtd == ScheduleChanges.dtd = go ScheduleChanges.pickle_message
+
+ | dtd == Scores.dtd = go Scores.pickle_message
+
+ -- SportInfo and GameInfo appear last in the guards
+ | dtd == Weather.dtd =
+ if Weather.is_type1 xml
+ then go Weather.pickle_message
+ else do
+ -- We want these to "succeed" so that they're deleted.
+ -- We already know we can't parse them.
+ let msg = "Unsupported weatherxml.dtd type (" ++ path ++ ")"
+ return $ ImportUnsupported msg
+
+ | dtd `elem` GameInfo.dtds = do
+ let either_m = GameInfo.parse_xml dtd xml
+ case either_m of
+ -- This might give us a slightly better error
+ -- message than the default 'errmsg'.
+ Left err -> return $ ImportFailed err
+ Right m -> migrate_and_import m
+
+ | dtd `elem` SportInfo.dtds = do
+ let either_m = SportInfo.parse_xml dtd xml
+ case either_m of
+ -- This might give us a slightly better error
+ -- message than the default 'errmsg'.
+ Left err -> return $ ImportFailed err
+ Right m -> migrate_and_import m