1 -- | Minimal XML functionality needed to parse each document's
10 import Data.Maybe ( listToMaybe, mapMaybe )
11 import Test.Tasty ( TestTree, testGroup )
12 import Test.Tasty.HUnit ( (@?=), Assertion, testCase )
13 import Text.Read ( readMaybe )
14 import Text.XML.HXT.Core (
23 -- | A tiny parser written in HXT to extract the "XML_File_ID" element
25 parse_xmlfid :: String -> Maybe Integer
27 listToMaybe . mapMaybe readMaybe . parse
29 parse :: String -> [String]
33 /> hasName "XML_File_ID"
38 -- | The opening "tag" for the XML prologue.
39 xml_prologue :: String
40 xml_prologue = "<?xml "
51 xml_file_id_tests :: TestTree
53 testCase "XML_File_ID is parsed correctly" $ do
54 let xmlfids = ["19908216", "19908216", "19908245", "19908246", "19908247"]
57 check :: String -> Assertion
59 xml <- readFile ("test/xml/" ++ xmlfid ++ ".xml")
60 let actual = parse_xmlfid xml
61 let expected = readMaybe xmlfid