]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blob - src/Main.hs
Comment out the DTD in Injuries_Detail_XML.xml.
[dead/htsn-import.git] / src / Main.hs
1 {-# LANGUAGE ScopedTypeVariables #-}
2 {-# LANGUAGE OverloadedStrings #-}
3
4 module Main
5 where
6
7 --import Control.Monad.IO.Class ( liftIO )
8 import Data.Maybe ( listToMaybe )
9 --import Database.Groundhog.TH
10 --import Database.Groundhog.Sqlite
11 import Text.Show.Pretty ( ppShow )
12 import Text.XML.HXT.Core (
13 SysConfigList,
14 XmlPickler,
15 no,
16 runX,
17 withPreserveComment,
18 withRemoveWS,
19 withValidate,
20 xpickle,
21 xunpickleDocument,
22 yes )
23
24 import qualified TSN.Injuries as Injuries ( Message )
25 import qualified TSN.InjuriesDetail as InjuriesDetail ( Message )
26
27 parse_opts :: SysConfigList
28 parse_opts =
29 [ withPreserveComment no,
30 withRemoveWS yes,
31 withValidate no ]
32
33 parse_file :: XmlPickler a => FilePath -> IO (Maybe a)
34 parse_file path =
35 fmap listToMaybe $
36 runX ( xunpickleDocument xpickle parse_opts path )
37
38 -- main_sql :: IO ()
39 -- main_sql =
40 -- withSqliteConn "foo.sqlite3" $ runDbConn $ do
41 -- runMigration defaultMigrationLogger $ do
42 -- migrate (undefined :: Injuries.Message)
43 -- migrate (undefined :: Injuries.Listing)
44
45 -- msg :: Maybe Injuries.Message <- liftIO $ parse_file
46 -- "test/xml/injuriesxml.xml"
47 -- case msg of
48 -- Nothing -> return ()
49 -- Just m -> do
50 -- msg_id <- insert m
51 -- return ()
52
53 main :: IO ()
54 main = do
55 msg1 :: Maybe Injuries.Message <- parse_file "test/xml/injuriesxml.xml"
56 putStr $ ppShow msg1
57
58 msg2 :: Maybe InjuriesDetail.Message <- parse_file
59 "test/xml/Injuries_Detail_XML.xml"
60 putStr $ ppShow msg2