    -- |
    -- This module exports the core functions from the basic validation und simplification libraries.
    -- It also exports some helper functions for easier access to the validation functionality.

    module Text.XML.HXT.RelaxNG.Validator
      ( validateDocumentWithRelaxSchema
      , validateDocumentWithRelax
      , validateSchemaWithRelax
      , validateWithSpezification
      , validateSchemaWithSpezification

      , module Text.XML.HXT.RelaxNG.Validation
      , module Text.XML.HXT.RelaxNG.Simplification
      )
    where

    import Control.Arrow.ListArrows

    import Text.XML.HXT.DOM.Interface

    import Text.XML.HXT.Arrow.XmlArrow
    import Text.XML.HXT.Arrow.XmlState
    import Text.XML.HXT.Arrow.XmlState.TypeDefs

    import Text.XML.HXT.RelaxNG.BasicArrows
    import Text.XML.HXT.RelaxNG.Validation
    import Text.XML.HXT.RelaxNG.Simplification
    import Text.XML.HXT.RelaxNG.Schema        as S

    -- ------------------------------------------------------------

    {- |
       validate a document with a Relax NG schema

       * 1.parameter  : the system configuration option list for validation

       - 2.parameter  : the URI of the Relax NG Schema

       - arrow-input  : the document to be validated, namespaces must have been processed

       - arrow-output : the input document, or in case of validation errors, an empty document with status information in the root

    configuration options evaluated by validateDocumentWithRelaxSchema:

        * 'withRelaxCheckRestr'      : check Relax NG schema restrictions when simplifying the schema (default: on)

        - 'withRelaxValidateExtRef'  : validate a Relax NG schema referenced by a externalRef-Pattern (default: on)

        - 'withRelaxValidateInclude' : validate a Relax NG schema referenced by a include-Pattern (default: on)

    example:

    > validateDocumentWithRelaxSchema [withRelaxCheckRestr yes, withRelaxValidateExtRef no] "testSchema.rng"

    -}

    validateDocumentWithRelaxSchema :: SysConfigList -> String -> IOStateArrow s XmlTree XmlTree
    validateDocumentWithRelaxSchema :: forall s. SysConfigList -> String -> IOStateArrow s XmlTree XmlTree
    validateDocumentWithRelaxSchema SysConfigList
    config String
    relaxSchema
        = ( IOSArrow XmlTree XmlTree -> IOStateArrow s XmlTree XmlTree
    forall b c s0. IOSArrow b c -> IOStateArrow s0 b c
    withoutUserState
            (IOSArrow XmlTree XmlTree -> IOStateArrow s XmlTree XmlTree)
    -> IOSArrow XmlTree XmlTree -> IOStateArrow s XmlTree XmlTree
    forall a b. (a -> b) -> a -> b
    $
            IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall s a b. IOStateArrow s a b -> IOStateArrow s a b
    localSysEnv
            (IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree)
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall a b. (a -> b) -> a -> b
    $
            SysConfigList -> IOSArrow XmlTree XmlTree
    forall s c. SysConfigList -> IOStateArrow s c c
    configSysVars SysConfigList
    config
            IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
            Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    1 ( String
    "start validating document with Relax NG schema: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> String
    forall a. Show a => a -> String
    show String
    relaxSchema )
            IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
            ( ( ( XmlTree -> IOSArrow XmlTree XmlTree
    validate' (XmlTree -> IOSArrow XmlTree XmlTree)
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall c b d.
    (c -> IOSLA (XIOState ()) b d)
    -> IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b d
    forall (a :: * -> * -> *) c b d.
    ArrowList a =>
    (c -> a b d) -> a b c -> a b d
    $< String -> IOSArrow XmlTree XmlTree
    validateSchemaWithRelax String
    relaxSchema)    -- try to validate, only possible if schema is o.k.
                IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
                Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    1 ( String
    "validating document with Relax NG schema done" )
              )
              IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall b c.
    IOSLA (XIOState ()) b c
    -> IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b c
    forall (a :: * -> * -> *) b c. ArrowIf a => a b c -> a b c -> a b c
    `orElse`
              ( String -> IOSArrow XmlTree XmlTree
    forall s. String -> IOStateArrow s XmlTree XmlTree
    setDocumentStatusFromSystemState String
    "validating Relax NG schema"
                IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
                Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    1 ( String
    "no validation done, Relax NG schema is not correct" )
              )
            )
          )
          IOStateArrow s XmlTree XmlTree
    -> IOStateArrow s XmlTree XmlTree -> IOStateArrow s XmlTree XmlTree
    forall b c.
    IOSLA (XIOState s) b b
    -> IOSLA (XIOState s) b c -> IOSLA (XIOState s) b b
    forall (a :: * -> * -> *) b c. ArrowIf a => a b b -> a b c -> a b b
    `when`
          IOStateArrow s XmlTree XmlTree
    forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
    documentStatusOk                                 -- only do something when document status is ok
        where
        validate' :: XmlTree -> IOSArrow XmlTree XmlTree
    validate' XmlTree
    schema
            = String -> IOSArrow XmlTree XmlTree
    forall s. String -> IOStateArrow s XmlTree XmlTree
    setDocumentStatusFromSystemState String
    "read and build Relax NG schema"
              IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
              XmlTree -> IOSArrow XmlTree XmlTree
    validateDocumentWithRelax XmlTree
    schema

    validateSchemaWithRelax         :: String -> IOSArrow XmlTree XmlTree
    validateSchemaWithRelax :: String -> IOSArrow XmlTree XmlTree
    validateSchemaWithRelax String
    relaxSchema
        = Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    2 ( String
    "read and check Relax NG schema document: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> String
    forall a. Show a => a -> String
    show String
    relaxSchema )
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          String -> IOSArrow XmlTree XmlTree
    forall b. String -> IOSArrow b XmlTree
    readForRelax String
    relaxSchema
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          ( let checkSchema :: Bool
    checkSchema = Bool
    True in           -- test option in al
                if Bool
    checkSchema
                then IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    validateWithRelax IOSArrow XmlTree XmlTree
    forall (a :: * -> * -> *) b. ArrowList a => a b XmlTree
    S.relaxSchemaArrow IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall b c d.
    IOSLA (XIOState ()) b c
    -> IOSLA (XIOState ()) b d -> IOSLA (XIOState ()) b d
    forall (a :: * -> * -> *) b c d.
    ArrowIf a =>
    a b c -> a b d -> a b d
    `guards` IOSArrow XmlTree XmlTree
    forall b. IOSLA (XIOState ()) b b
    forall (a :: * -> * -> *) b. ArrowList a => a b b
    this
                else IOSArrow XmlTree XmlTree
    forall b. IOSLA (XIOState ()) b b
    forall (a :: * -> * -> *) b. ArrowList a => a b b
    this
          )
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    2 String
    "create simplified schema"
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          ( (\ (Bool
    b1, (Bool
    b2, Bool
    b3)) -> Bool -> Bool -> Bool -> IOSArrow XmlTree XmlTree
    createSimpleForm Bool
    b1 Bool
    b2 Bool
    b3)
            ((Bool, (Bool, Bool)) -> IOSArrow XmlTree XmlTree)
    -> IOSLA (XIOState ()) XmlTree (Bool, (Bool, Bool))
    -> IOSArrow XmlTree XmlTree
    forall c b d.
    (c -> IOSLA (XIOState ()) b d)
    -> IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b d
    forall (a :: * -> * -> *) c b d.
    ArrowList a =>
    (c -> a b d) -> a b c -> a b d
    $<
            Selector XIOSysState (Bool, (Bool, Bool))
    -> IOSLA (XIOState ()) XmlTree (Bool, (Bool, Bool))
    forall c s b. Selector XIOSysState c -> IOStateArrow s b c
    getSysVar (Selector XIOSysState Bool
    theRelaxCheckRestr     Selector XIOSysState Bool
    -> Selector XIOSysState (Bool, Bool)
    -> Selector XIOSysState (Bool, (Bool, Bool))
    forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
    .&&&.
                       Selector XIOSysState Bool
    theRelaxValidateExtRef Selector XIOSysState Bool
    -> Selector XIOSysState Bool -> Selector XIOSysState (Bool, Bool)
    forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
    .&&&.
                       Selector XIOSysState Bool
    theRelaxValidateInclude
                      )
          )
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          String -> IOSArrow XmlTree XmlTree
    forall s. String -> IOStateArrow s XmlTree XmlTree
    traceDoc String
    "simplified schema"
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    2 String
    "collect and issue schema errors"
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall b c. IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b b
    forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b b
    perform IOSArrow XmlTree XmlTree
    handleSimplificationErrors
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          IOSArrow XmlTree XmlTree
    resetStates
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          String -> IOSArrow XmlTree XmlTree
    forall s. String -> IOStateArrow s XmlTree XmlTree
    setDocumentStatusFromSystemState String
    "validating Relax NG schema"
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          IOSArrow XmlTree XmlTree
    forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
    documentStatusOk
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    2 String
    "Relax NG schema is o.k."

    handleSimplificationErrors      :: IOSArrow XmlTree XmlTree
    handleSimplificationErrors :: IOSArrow XmlTree XmlTree
    handleSimplificationErrors
        = String -> IOSArrow XmlTree XmlTree
    forall s. String -> IOStateArrow s XmlTree XmlTree
    traceDoc String
    "simplification errors"
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          IOSArrow XmlTree XmlTree
    getErrors
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          IOSLA (XIOState ()) XmlTree String
    forall (a :: * -> * -> *). ArrowXml a => a XmlTree String
    getRngAttrDescr
          IOSLA (XIOState ()) XmlTree String
    -> IOSLA (XIOState ()) String XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          (String -> String) -> IOSLA (XIOState ()) String String
    forall b c. (b -> c) -> IOSLA (XIOState ()) b c
    forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
    arr (String
    "Relax NG validation: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++)
          IOSLA (XIOState ()) String String
    -> IOSLA (XIOState ()) String XmlTree
    -> IOSLA (XIOState ()) String XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          Int -> IOSLA (XIOState ()) String XmlTree
    forall (a :: * -> * -> *). ArrowXml a => Int -> a String XmlTree
    mkError Int
    c_err
          IOSLA (XIOState ()) String XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSLA (XIOState ()) String XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
          IOSArrow XmlTree XmlTree
    forall s. IOStateArrow s XmlTree XmlTree
    filterErrorMsg

    {- | validate an XML document with respect to a Relax NG schema

       * 1.parameter  : the valid and simplified schema as XML tree

       - arrow-input  : the document to be validated

       - arrow-output : the validated and unchanged document or the empty document with status information set in the root node
    -}

    validateDocumentWithRelax       :: XmlTree -> IOSArrow XmlTree XmlTree
    validateDocumentWithRelax :: XmlTree -> IOSArrow XmlTree XmlTree
    validateDocumentWithRelax XmlTree
    schema
        = ( Int -> String -> IOSArrow XmlTree XmlTree
    forall s b. Int -> String -> IOStateArrow s b b
    traceMsg Int
    1 String
    "validate document with Relax NG schema"
            IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
            IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall b c. IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b b
    forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b b
    perform ( IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    validateWithRelax (XmlTree -> IOSArrow XmlTree XmlTree
    forall c b. c -> IOSLA (XIOState ()) b c
    forall (a :: * -> * -> *) c b. ArrowList a => c -> a b c
    constA XmlTree
    schema) )
            IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
            String -> IOSArrow XmlTree XmlTree
    forall s. String -> IOStateArrow s XmlTree XmlTree
    setDocumentStatusFromSystemState String
    "validate document with Relax NG schema"
          )
          IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall b c.
    IOSLA (XIOState ()) b b
    -> IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b b
    forall (a :: * -> * -> *) b c. ArrowIf a => a b b -> a b c -> a b b
    `when` IOSArrow XmlTree XmlTree
    forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
    documentStatusOk                           -- only do something when document status is ok

    -- ------------------------------------------------------------

    {- | Relax NG schema validation

        see 'validateSchemaWithRelax' and 'validateWithSpezification'

       * 1.parameter :  Relax NG schema file

       - arrow-input  :  Relax NG Specification in simple form
    -}

    validateSchemaWithSpezification :: String -> IOSArrow XmlTree XmlTree
    validateSchemaWithSpezification :: String -> IOSArrow XmlTree XmlTree
    validateSchemaWithSpezification String
    relaxSchema
        = String -> String -> IOSArrow XmlTree XmlTree
    validateWithSpezification String
    "" String
    relaxSchema

    {- | Document validation

    Validates a xml document with respect to a Relax NG schema

       * 1.parameter :  XML document

       - 2.parameter :  Relax NG schema file

    -}

    validateWithSpezification :: String -> String -> IOSArrow XmlTree XmlTree
    validateWithSpezification :: String -> String -> IOSArrow XmlTree XmlTree
    validateWithSpezification String
    xmlDocument String
    relaxSchema
        = [XmlTree] -> IOSArrow XmlTree XmlTree
    forall {b}. [XmlTree] -> IOSLA (XIOState ()) b XmlTree
    validDoc ([XmlTree] -> IOSArrow XmlTree XmlTree)
    -> IOSLA (XIOState ()) XmlTree [XmlTree]
    -> IOSArrow XmlTree XmlTree
    forall c b d.
    (c -> IOSLA (XIOState ()) b d)
    -> IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b d
    forall (a :: * -> * -> *) c b d.
    ArrowList a =>
    (c -> a b d) -> a b c -> a b d
    $< IOSArrow XmlTree XmlTree -> IOSLA (XIOState ()) XmlTree [XmlTree]
    forall b c. IOSLA (XIOState ()) b c -> IOSLA (XIOState ()) b [c]
    forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b [c]
    listA (String -> IOSArrow XmlTree XmlTree
    validateSchemaWithRelax String
    relaxSchema)
        where
        validDoc :: [XmlTree] -> IOSLA (XIOState ()) b XmlTree
    validDoc [XmlTree
    theSchema]
            | String -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null String
    xmlDocument
                = IOSLA (XIOState ()) b XmlTree
    forall b c. IOSLA (XIOState ()) b c
    forall (a :: * -> * -> *) b c. ArrowList a => a b c
    none
            | Bool
    otherwise
                = IOSLA (XIOState ()) b XmlTree
    -> IOSLA (XIOState ()) b XmlTree
    -> IOSLA (XIOState ()) b XmlTree
    -> IOSLA (XIOState ()) b XmlTree
    forall b c d.
    IOSLA (XIOState ()) b c
    -> IOSLA (XIOState ()) b d
    -> IOSLA (XIOState ()) b d
    -> IOSLA (XIOState ()) b d
    forall (a :: * -> * -> *) b c d.
    ArrowIf a =>
    a b c -> a b d -> a b d -> a b d
    ifA ( String -> IOSLA (XIOState ()) b XmlTree
    forall b. String -> IOSArrow b XmlTree
    readForRelax String
    xmlDocument
                        IOSLA (XIOState ()) b XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSLA (XIOState ()) b XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
                        IOSArrow XmlTree XmlTree
    forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
    normalizeForRelaxValidation
                        IOSArrow XmlTree XmlTree
    -> IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree
    forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
    Category cat =>
    cat a b -> cat b c -> cat a c
    >>>
                        XmlTree -> IOSArrow XmlTree XmlTree
    validateRelax XmlTree
    theSchema
                      )
                  IOSLA (XIOState ()) b XmlTree
    forall b c. IOSLA (XIOState ()) b c
    forall (a :: * -> * -> *) b c. ArrowList a => a b c
    none
                  ( String -> IOSLA (XIOState ()) b XmlTree
    forall b. String -> IOSArrow b XmlTree
    forall (a :: * -> * -> *) n. ArrowXml a => String -> a n XmlTree
    err String
    "Document is not valid with respect to Relax NG Schema" )
        validDoc [XmlTree]
    _
            = String -> IOSLA (XIOState ()) b XmlTree
    forall b. String -> IOSArrow b XmlTree
    forall (a :: * -> * -> *) n. ArrowXml a => String -> a n XmlTree
    err String
    "Relax NG Schema not correct"

    -- ------------------------------------------------------------