5 module Rakka.Validation
9 import Control.Applicative
10 import Control.Arrow.Unicode
11 import Control.Monad.Trans
12 import Control.Monad.Unicode
14 import System.Directory
15 import System.FilePath
16 import Text.XML.HXT.Arrow.XmlState
17 import Text.XML.HXT.DOM.TypeDefs
18 import Text.XML.HXT.RelaxNG
20 loadSchema ∷ FilePath → IO (IOSArrow XmlTree XmlTree)
22 = do [schema] ← runX ( setErrorMsgHandler False fail
24 validateSchemaWithRelax fpath
26 pure $ validateDocumentWithRelax schema
28 doesLocalDirExist ∷ IO Bool
29 doesLocalDirExist = doesDirectoryExist "schemas"
31 getValidator ∷ MonadIO m ⇒ FilePath → m (IOSArrow XmlTree XmlTree)
34 do let schemaPath = "schemas" </> fname
35 localDirExists ← doesLocalDirExist
36 if localDirExists then
39 getDataFileName ("schemas" </> fname) ≫= loadSchema