Text.XML.HaXml.Schema.Schema

HaXml-1.25.4: Utilities for manipulating XML documents

Safe Haskell | None
Language | Haskell98

Text.XML.HaXml.Schema.Schema

Synopsis

- class SchemaType a where
- class SimpleType a where
- class Extension t s where
- class Restricts t s | t -> s where
- class FwdDecl fd a | fd -> a
- getAttribute :: (SimpleType a, Show a) => String -> Element Posn -> Posn -> XMLParser a
- between :: PolyParse p => Occurs -> p a -> p [a]
- data Occurs = Occurs (Maybe Int) (Maybe Int)
- parseSimpleType :: SimpleType t => XMLParser t
- parseText :: XMLParser String
- data AnyElement
  - = (SchemaType a, Show a) => ANYSchemaType a
  - | UnconvertedANY (Content Posn)
- parseAnyElement :: XMLParser AnyElement
- data Content i
  - = CElem (Element i) i
  - | CString Bool CharData i
  - | CRef Reference i
  - | CMisc Misc i
- type XMLParser a = Parser (Content Posn) a
- posnElement :: [String] -> XMLParser (Posn, Element Posn)
- posnElementWith :: (String -> String -> Bool) -> [String] -> XMLParser (Posn, Element Posn)
- element :: [String] -> XMLParser (Element Posn)
- interior :: Element Posn -> XMLParser a -> XMLParser a
- text :: XMLParser String
- module Text.ParserCombinators.Poly
- module Text.Parse
- module Text.XML.HaXml.OneOfN
- toXMLElement :: String -> [[Attribute]] -> [[Content ()]] -> [Content ()]
- toXMLText :: String -> [Content ()]
- toXMLAnyElement :: AnyElement -> [Content ()]
- toXMLAttribute :: SimpleType a => String -> a -> [Attribute]
- addXMLAttributes :: [[Attribute]] -> [Content ()] -> [Content ()]

# Documentation

class SchemaType a where #

A SchemaType promises to interconvert between a generic XML content tree and a Haskell value, according to the rules of XSD.

Minimal complete definition

parseSchemaType, schemaTypeToXML

Methods

parseSchemaType :: String -> XMLParser a #

schemaTypeToXML :: String -> a -> [Content ()] #

Instances

SchemaType Double # |
Methods parseSchemaType :: String -> XMLParser Double # schemaTypeToXML :: String -> Double -> [Content ()] #
SchemaType Float # |
Methods parseSchemaType :: String -> XMLParser Float # schemaTypeToXML :: String -> Float -> [Content ()] #
SchemaType Int # |
Methods parseSchemaType :: String -> XMLParser Int # schemaTypeToXML :: String -> Int -> [Content ()] #
SchemaType Integer # |
Methods parseSchemaType :: String -> XMLParser Integer # schemaTypeToXML :: String -> Integer -> [Content ()] #
SchemaType PositiveInteger # |
Methods parseSchemaType :: String -> XMLParser PositiveInteger # schemaTypeToXML :: String -> PositiveInteger -> [Content ()] #
SchemaType UnsignedByte # |
Methods parseSchemaType :: String -> XMLParser UnsignedByte # schemaTypeToXML :: String -> UnsignedByte -> [Content ()] #
SchemaType UnsignedShort # |
Methods parseSchemaType :: String -> XMLParser UnsignedShort # schemaTypeToXML :: String -> UnsignedShort -> [Content ()] #
SchemaType UnsignedInt # |
Methods parseSchemaType :: String -> XMLParser UnsignedInt # schemaTypeToXML :: String -> UnsignedInt -> [Content ()] #
SchemaType UnsignedLong # |
Methods parseSchemaType :: String -> XMLParser UnsignedLong # schemaTypeToXML :: String -> UnsignedLong -> [Content ()] #
SchemaType NonNegativeInteger # |
Methods parseSchemaType :: String -> XMLParser NonNegativeInteger # schemaTypeToXML :: String -> NonNegativeInteger -> [Content ()] #
SchemaType Byte # |
Methods parseSchemaType :: String -> XMLParser Byte # schemaTypeToXML :: String -> Byte -> [Content ()] #
SchemaType Short # |
Methods parseSchemaType :: String -> XMLParser Short # schemaTypeToXML :: String -> Short -> [Content ()] #
SchemaType Long # |
Methods parseSchemaType :: String -> XMLParser Long # schemaTypeToXML :: String -> Long -> [Content ()] #
SchemaType NegativeInteger # |
Methods parseSchemaType :: String -> XMLParser NegativeInteger # schemaTypeToXML :: String -> NegativeInteger -> [Content ()] #
SchemaType NonPositiveInteger # |
Methods parseSchemaType :: String -> XMLParser NonPositiveInteger # schemaTypeToXML :: String -> NonPositiveInteger -> [Content ()] #
SchemaType NMTOKENS # |
Methods parseSchemaType :: String -> XMLParser NMTOKENS # schemaTypeToXML :: String -> NMTOKENS -> [Content ()] #
SchemaType NMTOKEN # |
Methods parseSchemaType :: String -> XMLParser NMTOKEN # schemaTypeToXML :: String -> NMTOKEN -> [Content ()] #
SchemaType ENTITIES # |
Methods parseSchemaType :: String -> XMLParser ENTITIES # schemaTypeToXML :: String -> ENTITIES -> [Content ()] #
SchemaType ENTITY # |
Methods parseSchemaType :: String -> XMLParser ENTITY # schemaTypeToXML :: String -> ENTITY -> [Content ()] #
SchemaType IDREFS # |
Methods parseSchemaType :: String -> XMLParser IDREFS # schemaTypeToXML :: String -> IDREFS -> [Content ()] #
SchemaType IDREF # |
Methods parseSchemaType :: String -> XMLParser IDREF # schemaTypeToXML :: String -> IDREF -> [Content ()] #
SchemaType ID # |
Methods parseSchemaType :: String -> XMLParser ID # schemaTypeToXML :: String -> ID -> [Content ()] #
SchemaType NCName # |
Methods parseSchemaType :: String -> XMLParser NCName # schemaTypeToXML :: String -> NCName -> [Content ()] #
SchemaType Name # |
Methods parseSchemaType :: String -> XMLParser Name # schemaTypeToXML :: String -> Name -> [Content ()] #
SchemaType Language # |
Methods parseSchemaType :: String -> XMLParser Language # schemaTypeToXML :: String -> Language -> [Content ()] #
SchemaType Token # |
Methods parseSchemaType :: String -> XMLParser Token # schemaTypeToXML :: String -> Token -> [Content ()] #
SchemaType NormalizedString # |
Methods parseSchemaType :: String -> XMLParser NormalizedString # schemaTypeToXML :: String -> NormalizedString -> [Content ()] #
SchemaType GMonth # |
Methods parseSchemaType :: String -> XMLParser GMonth # schemaTypeToXML :: String -> GMonth -> [Content ()] #
SchemaType GDay # |
Methods parseSchemaType :: String -> XMLParser GDay # schemaTypeToXML :: String -> GDay -> [Content ()] #
SchemaType GMonthDay # |
Methods parseSchemaType :: String -> XMLParser GMonthDay # schemaTypeToXML :: String -> GMonthDay -> [Content ()] #
SchemaType GYear # |
Methods parseSchemaType :: String -> XMLParser GYear # schemaTypeToXML :: String -> GYear -> [Content ()] #
SchemaType GYearMonth # |
Methods parseSchemaType :: String -> XMLParser GYearMonth # schemaTypeToXML :: String -> GYearMonth -> [Content ()] #
SchemaType Date # |
Methods parseSchemaType :: String -> XMLParser Date # schemaTypeToXML :: String -> Date -> [Content ()] #
SchemaType Time # |
Methods parseSchemaType :: String -> XMLParser Time # schemaTypeToXML :: String -> Time -> [Content ()] #
SchemaType DateTime # |
Methods parseSchemaType :: String -> XMLParser DateTime # schemaTypeToXML :: String -> DateTime -> [Content ()] #
SchemaType Duration # |
Methods parseSchemaType :: String -> XMLParser Duration # schemaTypeToXML :: String -> Duration -> [Content ()] #
SchemaType Decimal # |
Methods parseSchemaType :: String -> XMLParser Decimal # schemaTypeToXML :: String -> Decimal -> [Content ()] #
SchemaType NOTATION # |
Methods parseSchemaType :: String -> XMLParser NOTATION # schemaTypeToXML :: String -> NOTATION -> [Content ()] #
SchemaType AnyURI # |
Methods parseSchemaType :: String -> XMLParser AnyURI # schemaTypeToXML :: String -> AnyURI -> [Content ()] #
SchemaType HexBinary # |
Methods parseSchemaType :: String -> XMLParser HexBinary # schemaTypeToXML :: String -> HexBinary -> [Content ()] #
SchemaType Base64Binary # |
Methods parseSchemaType :: String -> XMLParser Base64Binary # schemaTypeToXML :: String -> Base64Binary -> [Content ()] #
SchemaType XsdString # |
Methods parseSchemaType :: String -> XMLParser XsdString # schemaTypeToXML :: String -> XsdString -> [Content ()] #
SchemaType Boolean # |
Methods parseSchemaType :: String -> XMLParser Boolean # schemaTypeToXML :: String -> Boolean -> [Content ()] #
SchemaType AnyElement # |
Methods parseSchemaType :: String -> XMLParser AnyElement # schemaTypeToXML :: String -> AnyElement -> [Content ()] #

class SimpleType a where #

Ultimately, an XML parser will find some plain text as the content of a simpleType, which will need to be parsed. We use a TextParser, because values of simpleTypes can also be given elsewhere, e.g. as attribute values in an XSD definition, e.g. to restrict the permissible values of the simpleType. Such restrictions are therefore implemented as layered parsers.

Minimal complete definition

acceptingParser, simpleTypeText

Methods

acceptingParser :: TextParser a #

simpleTypeText :: a -> String #

Instances

SimpleType Bool # |
Methods acceptingParser :: TextParser Bool # simpleTypeText :: Bool -> String #
SimpleType Double # |
Methods acceptingParser :: TextParser Double # simpleTypeText :: Double -> String #
SimpleType Float # |
Methods acceptingParser :: TextParser Float # simpleTypeText :: Float -> String #
SimpleType Int # |
Methods acceptingParser :: TextParser Int # simpleTypeText :: Int -> String #
SimpleType Integer # |
Methods acceptingParser :: TextParser Integer # simpleTypeText :: Integer -> String #
SimpleType PositiveInteger # |
Methods acceptingParser :: TextParser PositiveInteger # simpleTypeText :: PositiveInteger -> String #
SimpleType UnsignedByte # |
Methods acceptingParser :: TextParser UnsignedByte # simpleTypeText :: UnsignedByte -> String #
SimpleType UnsignedShort # |
Methods acceptingParser :: TextParser UnsignedShort # simpleTypeText :: UnsignedShort -> String #
SimpleType UnsignedInt # |
Methods acceptingParser :: TextParser UnsignedInt # simpleTypeText :: UnsignedInt -> String #
SimpleType UnsignedLong # |
Methods acceptingParser :: TextParser UnsignedLong # simpleTypeText :: UnsignedLong -> String #
SimpleType NonNegativeInteger # |
Methods acceptingParser :: TextParser NonNegativeInteger # simpleTypeText :: NonNegativeInteger -> String #
SimpleType Byte # |
Methods acceptingParser :: TextParser Byte # simpleTypeText :: Byte -> String #
SimpleType Short # |
Methods acceptingParser :: TextParser Short # simpleTypeText :: Short -> String #
SimpleType Long # |
Methods acceptingParser :: TextParser Long # simpleTypeText :: Long -> String #
SimpleType NegativeInteger # |
Methods acceptingParser :: TextParser NegativeInteger # simpleTypeText :: NegativeInteger -> String #
SimpleType NonPositiveInteger # |
Methods acceptingParser :: TextParser NonPositiveInteger # simpleTypeText :: NonPositiveInteger -> String #
SimpleType NMTOKENS # |
Methods acceptingParser :: TextParser NMTOKENS # simpleTypeText :: NMTOKENS -> String #
SimpleType NMTOKEN # |
Methods acceptingParser :: TextParser NMTOKEN # simpleTypeText :: NMTOKEN -> String #
SimpleType ENTITIES # |
Methods acceptingParser :: TextParser ENTITIES # simpleTypeText :: ENTITIES -> String #
SimpleType ENTITY # |
Methods acceptingParser :: TextParser ENTITY # simpleTypeText :: ENTITY -> String #
SimpleType IDREFS # |
Methods acceptingParser :: TextParser IDREFS # simpleTypeText :: IDREFS -> String #
SimpleType IDREF # |
Methods acceptingParser :: TextParser IDREF # simpleTypeText :: IDREF -> String #
SimpleType ID # |
Methods acceptingParser :: TextParser ID # simpleTypeText :: ID -> String #
SimpleType NCName # |
Methods acceptingParser :: TextParser NCName # simpleTypeText :: NCName -> String #
SimpleType Name # |
Methods acceptingParser :: TextParser Name # simpleTypeText :: Name -> String #
SimpleType Language # |
Methods acceptingParser :: TextParser Language # simpleTypeText :: Language -> String #
SimpleType Token # |
Methods acceptingParser :: TextParser Token # simpleTypeText :: Token -> String #
SimpleType NormalizedString # |
Methods acceptingParser :: TextParser NormalizedString # simpleTypeText :: NormalizedString -> String #
SimpleType GMonth # |
Methods acceptingParser :: TextParser GMonth # simpleTypeText :: GMonth -> String #
SimpleType GDay # |
Methods acceptingParser :: TextParser GDay # simpleTypeText :: GDay -> String #
SimpleType GMonthDay # |
Methods acceptingParser :: TextParser GMonthDay # simpleTypeText :: GMonthDay -> String #
SimpleType GYear # |
Methods acceptingParser :: TextParser GYear # simpleTypeText :: GYear -> String #
SimpleType GYearMonth # |
Methods acceptingParser :: TextParser GYearMonth # simpleTypeText :: GYearMonth -> String #
SimpleType Date # |
Methods acceptingParser :: TextParser Date # simpleTypeText :: Date -> String #
SimpleType Time # |
Methods acceptingParser :: TextParser Time # simpleTypeText :: Time -> String #
SimpleType DateTime # |
Methods acceptingParser :: TextParser DateTime # simpleTypeText :: DateTime -> String #
SimpleType Duration # |
Methods acceptingParser :: TextParser Duration # simpleTypeText :: Duration -> String #
SimpleType Decimal # |
Methods acceptingParser :: TextParser Decimal # simpleTypeText :: Decimal -> String #
SimpleType NOTATION # |
Methods acceptingParser :: TextParser NOTATION # simpleTypeText :: NOTATION -> String #
SimpleType AnyURI # |
Methods acceptingParser :: TextParser AnyURI # simpleTypeText :: AnyURI -> String #
SimpleType HexBinary # |
Methods acceptingParser :: TextParser HexBinary # simpleTypeText :: HexBinary -> String #
SimpleType Base64Binary # |
Methods acceptingParser :: TextParser Base64Binary # simpleTypeText :: Base64Binary -> String #
SimpleType XsdString # |
Methods acceptingParser :: TextParser XsdString # simpleTypeText :: XsdString -> String #

class Extension t s where #

A type t can extend another type s by the addition of extra elements and/or attributes. s is therefore the supertype of t.

Minimal complete definition

supertype

Methods

supertype :: t -> s #

class Restricts t s | t -> s where #

A type t can restrict another type s, that is, t admits fewer values than s, but all the values t does admit also belong to the type s.

Minimal complete definition

restricts

Methods

restricts :: t -> s #

class FwdDecl fd a | fd -> a #

A trick to enable forward-declaration of a type that will be defined properly in another module, higher in the dependency graph. `fd` is a dummy type e.g. the empty `data FwdA`, where `a` is the proper `data A`, not yet available.

getAttribute :: (SimpleType a, Show a) => String -> Element Posn -> Posn -> XMLParser a #

Generated parsers will use `getAttribute` as a convenient wrapper to lift a SchemaAttribute parser into an XMLParser.

between :: PolyParse p => Occurs -> p a -> p [a] #

Between is a list parser that tries to ensure that any range specification (min and max elements) is obeyed when parsing.

data Occurs #

Constructors

Occurs (Maybe Int) (Maybe Int) |

Instances

Eq Occurs # |
Methods (==) :: Occurs -> Occurs -> Bool # (/=) :: Occurs -> Occurs -> Bool #
Show Occurs # |
Methods showsPrec :: Int -> Occurs -> ShowS # show :: Occurs -> String # showList :: [Occurs] -> ShowS #

parseSimpleType :: SimpleType t => XMLParser t #

Given a TextParser for a SimpleType, make it into an XMLParser, i.e. consuming textual XML content as input rather than a String.

parseText :: XMLParser String #

Parse the textual part of mixed content

data AnyElement #

The xsd:any type. Parsing will always produce an UnconvertedANY.

Constructors

(SchemaType a, Show a) => ANYSchemaType a |
UnconvertedANY (Content Posn) |

Instances

Eq AnyElement # |
Methods (==) :: AnyElement -> AnyElement -> Bool # (/=) :: AnyElement -> AnyElement -> Bool #
Show AnyElement # |
Methods showsPrec :: Int -> AnyElement -> ShowS # show :: AnyElement -> String # showList :: [AnyElement] -> ShowS #
SchemaType AnyElement # |
Methods parseSchemaType :: String -> XMLParser AnyElement # schemaTypeToXML :: String -> AnyElement -> [Content ()] #

parseAnyElement :: XMLParser AnyElement #

data Content i #

Constructors

CElem (Element i) i |
CString Bool CharData i | bool is whether whitespace is significant
CRef Reference i |
CMisc Misc i |

Instances

Functor Content # |
Methods fmap :: (a -> b) -> Content a -> Content b # (<$) :: a -> Content b -> Content a #
Eq (Content i) # |
Methods (==) :: Content i -> Content i -> Bool # (/=) :: Content i -> Content i -> Bool #
Show i => Show (Content i) # |
Methods showsPrec :: Int -> Content i -> ShowS # show :: Content i -> String # showList :: [Content i] -> ShowS #
Verbatim (Content i) # |
Methods verbatim :: Content i -> String #

type XMLParser a = Parser (Content Posn) a #

We need a parsing monad for reading generic XML Content into specific datatypes. This is a specialisation of the Text.ParserCombinators.Poly ones, where the input token type is fixed as XML Content.

posnElement :: [String] -> XMLParser (Posn, Element Posn) #

A specialisation of `posnElementWith (==)`.

posnElementWith :: (String -> String -> Bool) -> [String] -> XMLParser (Posn, Element Posn) #

Get the next content element, checking that it has one of the required tags, using the given matching function. (Skips over comments and whitespace, rejects text and refs. Also returns position of element.)

element :: [String] -> XMLParser (Element Posn) #

Get the next content element, checking that it has one of the required tags. (Skips over comments and whitespace, rejects text and refs.)

interior :: Element Posn -> XMLParser a -> XMLParser a #

Run an XMLParser on the contents of the given element (i.e. not on the current monadic content sequence), checking that the contents are exhausted, before returning the calculated value within the current parser context.

text :: XMLParser String #

`text` is a counterpart to `element`, parsing text content if it exists. Adjacent text and references are coalesced.

module Text.ParserCombinators.Poly

module Text.Parse

module Text.XML.HaXml.OneOfN

toXMLElement :: String -> [[Attribute]] -> [[Content ()]] -> [Content ()] #

toXMLText :: String -> [Content ()] #

toXMLAnyElement :: AnyElement -> [Content ()] #

toXMLAttribute :: SimpleType a => String -> a -> [Attribute] #

addXMLAttributes :: [[Attribute]] -> [Content ()] -> [Content ()] #

For a ComplexType that is an extension of a SimpleType, it is necessary to convert the value to XML first, then add in the extra attributes that constitute the extension.