+ -- SportInfo and GameInfo appear least in the guards
+ | dtd == Weather.dtd = do
+ let m = unpickleDoc Weather.pickle_message xml
+ maybe (return $ ImportFailed errmsg) migrate_and_import m
+
+ | 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
+
+ | otherwise = do
+ let infomsg =
+ "Unrecognized DTD in " ++ path ++ ": " ++ dtd ++ "."
+ return $ ImportUnsupported infomsg
+
+ where
+ errmsg = "Could not unpickle " ++ dtd ++ "."
+
+
+-- | Entry point of the program. It twiddles some knobs for
+-- configuration options and then calls 'import_file' on each XML
+-- file given on the command-line.
+--
+-- Any file successfully processed is then optionally removed, and
+-- we're done.
+--