HaXml-1.24: Utilities for manipulating XML documents

Safe Haskell | Safe-Inferred

Text.XML.HaXml.Schema.HaskellTypeModel

Description

A type model for Haskell datatypes that bears a reasonable correspondence to the XSD type model.

Synopsis

- type Comment = Maybe String
- data Module = Module {
  - module_name :: XName
  - module_xsd_ns :: Maybe XName
  - module_re_exports :: [Decl]
  - module_import_only :: [Decl]
  - module_decls :: [Decl]
  }
- data Decl
  - = NamedSimpleType XName XName Comment
  - | RestrictSimpleType XName XName [Restrict] Comment
  - | ExtendSimpleType XName XName [Attribute] Comment
  - | UnionSimpleTypes XName [XName] Comment
  - | EnumSimpleType XName [(XName, Comment)] Comment
  - | ElementsAttrs XName [Element] [Attribute] Comment
  - | ElementsAttrsAbstract XName [(XName, Maybe XName)] Comment
  - | ElementOfType Element
  - | ElementAbstractOfType XName XName [(XName, Maybe XName)] Comment
  - | Choice XName [Element] Comment
  - | Group XName [Element] Comment
  - | RestrictComplexType XName XName Comment
  - | ExtendComplexType XName XName [Element] [Attribute] [Element] [Attribute] (Maybe XName) Bool [XName] Comment
  - | ExtendComplexTypeAbstract XName XName [(XName, Maybe XName)] (Maybe XName) [XName] Comment
  - | XSDInclude XName Comment
  - | XSDImport XName (Maybe XName) Comment
  - | XSDComment Comment
- data Element
  - = Element {
    - elem_name :: XName
    - elem_type :: XName
    - elem_modifier :: Modifier
    - elem_byRef :: Bool
    - elem_locals :: [Decl]
    - elem_substs :: Maybe [XName]
    - elem_comment :: Comment
    }
  - | OneOf {
    - elem_oneOf :: [[Element]]
    - elem_modifier :: Modifier
    - elem_comment :: Comment
    }
  - | AnyElem {
    - elem_modifier :: Modifier
    - elem_comment :: Comment
    }
  - | Text
- data Attribute = Attribute {
  - attr_name :: XName
  - attr_type :: XName
  - attr_required :: Bool
  - attr_comment :: Comment
  }
- data Modifier
  - = Single
  - | Optional
  - | Range Occurs
- data Restrict
  - = RangeR Occurs Comment
  - | Pattern String Comment
  - | Enumeration [(String, Comment)]
  - | StrLength Occurs Comment
- mkModule :: String -> Schema -> [Decl] -> Module

# Documentation

type Comment = Maybe String

Comments can be attached to most things, but not all of them will exist.

data Module

The whole Haskell module.

Constructors

Module |
Fields module_name :: XName module_xsd_ns :: Maybe XName module_re_exports :: [Decl] module_import_only :: [Decl] module_decls :: [Decl]

data Decl

There are essentially simple types, and complex types, each of which can be either restricted or extended. There are four kinds of complex type: choices, sequences, named groups, or a simple element with content.

Constructors

NamedSimpleType XName XName Comment |
RestrictSimpleType XName XName [Restrict] Comment |
ExtendSimpleType XName XName [Attribute] Comment |
UnionSimpleTypes XName [XName] Comment |
EnumSimpleType XName [(XName, Comment)] Comment |
ElementsAttrs XName [Element] [Attribute] Comment |
ElementsAttrsAbstract XName [(XName, Maybe XName)] Comment |
ElementOfType Element |
ElementAbstractOfType XName XName [(XName, Maybe XName)] Comment |
Choice XName [Element] Comment |
Group XName [Element] Comment |
RestrictComplexType XName XName Comment |
ExtendComplexType XName XName [Element] [Attribute] [Element] [Attribute] (Maybe XName) Bool [XName] Comment |
ExtendComplexTypeAbstract XName XName [(XName, Maybe XName)] (Maybe XName) [XName] Comment |
XSDInclude XName Comment |
XSDImport XName (Maybe XName) Comment |
XSDComment Comment |

Instances

Eq Decl |
Show Decl |

data Element

Constructors

Element |
Fields elem_name :: XName elem_type :: XName elem_modifier :: Modifier elem_byRef :: Bool elem_locals :: [Decl] elem_substs :: Maybe [XName] elem_comment :: Comment
OneOf |
Fields elem_oneOf :: [[Element]] elem_modifier :: Modifier elem_comment :: Comment
AnyElem |
Fields elem_modifier :: Modifier elem_comment :: Comment
Text |

Instances

Eq Element |
Show Element |

data Attribute

Constructors

Attribute |
Fields attr_name :: XName attr_type :: XName attr_required :: Bool attr_comment :: Comment

Instances

Eq Attribute |
Show Attribute |

data Modifier

Constructors

Single |
Optional |
Range Occurs |

Instances

Eq Modifier |
Show Modifier |

data Restrict

Restrictions on simpleType

Constructors

RangeR Occurs Comment |
Pattern String Comment |
Enumeration [(String, Comment)] |
StrLength Occurs Comment |

Instances

Eq Restrict |
Show Restrict |

mkModule :: String -> Schema -> [Decl] -> Module

A helper for building the formal Module structure.