ToDb(..),
pickle_unpickle,
unpickleable,
- unsafe_read_document,
+ unsafe_read_invalid_document,
unsafe_unpickle )
False ]
where
check path desc expected = testCase desc $ do
- xmltree <- unsafe_read_document path
+ xmltree <- unsafe_read_invalid_document path
let actual = has_only_single_sms xmltree
actual @?= expected
ToDb(..),
pickle_unpickle,
unpickleable,
- unsafe_read_document,
+ unsafe_read_invalid_document,
unsafe_unpickle )
False ]
where
check path desc expected = testCase desc $ do
- xmltree <- unsafe_read_document path
+ xmltree <- unsafe_read_invalid_document path
let actual = is_type1 xmltree
actual @?= expected
False ]
where
check desc path expected = testCase desc $ do
- xmltree <- unsafe_read_document path
+ xmltree <- unsafe_read_invalid_document path
let actual = teams_are_normal xmltree
actual @?= expected
FromXmlFk(..),
ToDb(..),
parse_opts,
+ parse_opts_novalidate,
pickle_unpickle,
unpickleable,
unsafe_read_document,
+ unsafe_read_invalid_document,
unsafe_unpickle )
where
--
parse_opts :: SysConfigList
parse_opts = [ withRemoveWS yes,
- withSubstDTDEntities no,
- withValidate no ]
+ withSubstDTDEntities no ]
+
+-- | Like 'parse_opts' except we don't validate the document against
+-- its DTD. This is useful when we need to parse a document that we
+-- /know/ is invalid so that we can deliver a better error message.
+--
+parse_opts_novalidate :: SysConfigList
+parse_opts_novalidate = (withValidate no) : parse_opts
-- | Given an @unpickler@ and a @filepath@, attempt to unpickle the
unsafe_read_document :: FilePath -> IO XmlTree
unsafe_read_document filepath =
fmap head $ runX $ readDocument parse_opts filepath
+
+-- | The same as 'unsafe_read_document', except it allows you to read
+-- documents which don't validate against their DTDs.
+--
+unsafe_read_invalid_document :: FilePath -> IO XmlTree
+unsafe_read_invalid_document filepath =
+ fmap head $ runX $ readDocument parse_opts_novalidate filepath