1 -- | General XML stuff.
8 import Text.XML.HXT.Core (
25 -- | A list of options passed to 'readDocument' when we parse an XML
26 -- document. We don't validate because the DTDs from TSN are
27 -- wrong. As a result, we don't want to keep useless DTDs
28 -- areound. Thus we disable 'withSubstDTDEntities' which, when
29 -- combined with "withValidate no", prevents HXT from trying to read
32 parse_opts :: SysConfigList
34 [ withPreserveComment no,
36 withSubstDTDEntities no,
40 -- | Given a root element name and a file path, return both the
41 -- original unpickled root "object" and the one that was constructed
42 -- by pickled and unpickling the original. This is used in a number
43 -- of XML tests which pickle/unpickle and then make sure that the
44 -- output is the same as the input.
46 -- We return the object instead of an XmlTree (which would save us
47 -- an unpickle call) because otherwise the type of @a@ in the call
48 -- to 'xpickle' would be ambiguous. By returning some @a@s, we allow
49 -- the caller to annotate its type.
51 pickle_unpickle :: XmlPickler a
55 pickle_unpickle root_element filepath = do
56 -- We need to check only the root message element since
57 -- readDocument produces a bunch of other junk.
58 expected <- runX $ arr_getobj
59 actual <- runX $ arr_getobj
65 return (expected, actual)
67 arr_getobj = readDocument parse_opts filepath