hxt-relaxng-9.1.5.5: The HXT RelaxNG validator
Safe HaskellNone
LanguageHaskell98

Text.XML.HXT.RelaxNG.DataTypeLibUtils

Description

exports helper functions for the integration of new datatype-libraries

Synopsis

Documentation

errorMsgEqual :: DatatypeName -> String -> String -> String Source #

errorMsgDataTypeNotAllowed :: String -> String -> [(String, String)] -> String -> String Source #

errorMsgDataTypeNotAllowed0 :: String -> String -> String Source #

errorMsgDataTypeNotAllowed2 :: String -> String -> String -> String -> String Source #

errorMsgDataLibQName :: String -> String -> String -> String Source #

errorMsgParam :: LocalName -> String -> String -> String Source #

Error Message for the equality test of two datatype values

  • 1.parameter : datatype
  • 2.parameter : datatype value
  • 3.parameter : datatype value

example:

errorMsgEqual "Int" "21" "42" -> "Datatype Int with value = 21 expected, but value = 42 found"

rng_length :: String Source #

type FunctionTable = [(String, String -> String -> Bool)] Source #

Function table type

fctTableString :: FunctionTable Source #

Function table for string tests, XML document value is first operand, schema value second

fctTableList :: FunctionTable Source #

Function table for list tests, XML document value is first operand, schema value second

stringValid :: DatatypeName -> Integer -> Integer -> ParamList -> CheckString Source #

Tests whether a "string" datatype value is between the lower and upper bound of the datatype and matches all parameters.

All tests are performed on the string value.

  • 1.parameter : datatype
  • 2.parameter : lower bound of the datatype range
  • 3.parameter : upper bound of the datatype range (-1 = no upper bound)
  • 4.parameter : list of parameters
  • 5.parameter : datatype value to be checked
  • return : Just "Errormessage" in case of an error, else Nothing

numberValid :: DatatypeName -> Integer -> Integer -> ParamList -> CheckString Source #

Tests whether a "numeric" datatype value is between the lower and upper bound of the datatype and matches all parameters.

First, the string value is parsed into a numeric representation. If no error occur, all following tests are performed on the numeric value.

  • 1.parameter : datatype
  • 2.parameter : lower bound of the datatype range
  • 3.parameter : upper bound of the datatype range (-1 = no upper bound)
  • 4.parameter : list of parameters
  • 5.parameter : datatype value to be checked
  • return : Just "Errormessage" in case of an error, else Nothing

numParamValid :: (Integer -> Integer -> Bool) -> String -> String -> Bool Source #

tests whether a string value matches a numeric param

valid example:

<data type="CHAR"> <param name="maxLength">5</param> </data>

invalid example:

<data type="CHAR"> <param name="minLength">foo</param> </data>

data CheckA a b Source #

Instances

Instances details
ArrowZero CheckA Source # 
Instance details

Defined in Text.XML.HXT.RelaxNG.DataTypeLibUtils

Methods

zeroArrow :: CheckA b c

ArrowPlus CheckA Source # 
Instance details

Defined in Text.XML.HXT.RelaxNG.DataTypeLibUtils

Methods

(<+>) :: CheckA b c -> CheckA b c -> CheckA b c

Arrow CheckA Source # 
Instance details

Defined in Text.XML.HXT.RelaxNG.DataTypeLibUtils

Methods

arr :: (b -> c) -> CheckA b c

first :: CheckA b c -> CheckA (b, d) (c, d)

second :: CheckA b c -> CheckA (d, b) (d, c)

(***) :: CheckA b c -> CheckA b' c' -> CheckA (b, b') (c, c')

(&&&) :: CheckA b c -> CheckA b c' -> CheckA b (c, c')

Category CheckA Source # 
Instance details

Defined in Text.XML.HXT.RelaxNG.DataTypeLibUtils

Methods

id :: forall (a :: k). CheckA a a

(.) :: forall (b :: k) (c :: k) (a :: k). CheckA b c -> CheckA a b -> CheckA a c

type CheckString = CheckA String String Source #

type CheckInteger = CheckA Integer Integer Source #

performCheck :: CheckA a b -> a -> Maybe String Source #

run a check and deliver Just an error message or Nothing

ok :: CheckA a a Source #

every thing is fine

failure :: (a -> String) -> CheckA a b Source #

always failure

assert :: (a -> Bool) -> (a -> String) -> CheckA a a Source #

perform a simple check with a predicate p, when the predicate holds, assert acts as identity, else an error message is generated

assertMaybe :: (a -> Maybe b) -> (a -> String) -> CheckA a b Source #

perform a simple check with a Maybe function, Nothing indicates error

checkWith :: (a -> b) -> CheckA b c -> CheckA a a Source #

perform a check, but convert the value before checking