Text.XML.HaXml.Types

HaXml-1.20.2: Utilities for manipulating XML documents

Text.XML.HaXml.Types

Contents

- A simple symbol table mapping strings (references) to values.
  - Symbol table operations
- XML Types
  - The top-level document container
  - The main document content
  - Administrative parts of the document
  - The DTD
    - content model
    - attribute model
    - conditional sections
  - References
  - Entities
  - Basic value types

Description

This module defines an internal (generic) representation for XML documents including their DTDs.

History: The original module was derived by hand from the XML specification, following the grammar precisely. Then we simplified the types, removing layers of indirection and redundancy, and generally making things easier to work with. Then we allowed PEReferences to be ubiquitous, by removing them from the types and resolving all PE references at parse-time. Finally, we added a per-document symbol table for GEReferences, and a whitespace-significance flag for plaintext.

Synopsis

- type SymTab a = [(String, a)]
- emptyST :: SymTab a
- addST :: String -> a -> SymTab a -> SymTab a
- lookupST :: String -> SymTab a -> Maybe a
- data Document i = Document Prolog (SymTab EntityDef) (Element i) [Misc]
- data Element i = Elem Name [Attribute] [Content i]
- data ElemTag = ElemTag Name [Attribute]
- data Content i
  - = CElem (Element i) i
  - | CString Bool CharData i
  - | CRef Reference i
  - | CMisc Misc i
- type Attribute = (Name, AttValue)
- data AttValue = AttValue [Either String Reference]
- info :: Content t -> t
- data Prolog = Prolog (Maybe XMLDecl) [Misc] (Maybe DocTypeDecl) [Misc]
- data XMLDecl = XMLDecl VersionInfo (Maybe EncodingDecl) (Maybe SDDecl)
- data Misc
  - = Comment Comment
  - | PI ProcessingInstruction
- type ProcessingInstruction = (PITarget, String)
- type SDDecl = Bool
- type VersionInfo = String
- type Comment = String
- type PITarget = String
- data DocTypeDecl = DTD Name (Maybe ExternalID) [MarkupDecl]
- data MarkupDecl
  - = Element ElementDecl
  - | AttList AttListDecl
  - | Entity EntityDecl
  - | Notation NotationDecl
  - | MarkupMisc Misc
- data ExtSubset = ExtSubset (Maybe TextDecl) [ExtSubsetDecl]
- data ExtSubsetDecl
  - = ExtMarkupDecl MarkupDecl
  - | ExtConditionalSect ConditionalSect
- data ElementDecl = ElementDecl Name ContentSpec
- data ContentSpec
  - = EMPTY
  - | ANY
  - | Mixed Mixed
  - | ContentSpec CP
- data CP
  - = TagName Name Modifier
  - | Choice [CP] Modifier
  - | Seq [CP] Modifier
- data Modifier
  - = None
  - | Query
  - | Star
  - | Plus
- data Mixed
  - = PCDATA
  - | PCDATAplus [Name]
- data AttListDecl = AttListDecl Name [AttDef]
- data AttDef = AttDef Name AttType DefaultDecl
- data AttType
  - = StringType
  - | TokenizedType TokenizedType
  - | EnumeratedType EnumeratedType
- data TokenizedType
  - = ID
  - | IDREF
  - | IDREFS
  - | ENTITY
  - | ENTITIES
  - | NMTOKEN
  - | NMTOKENS
- data EnumeratedType
  - = NotationType NotationType
  - | Enumeration Enumeration
- type NotationType = [Name]
- type Enumeration = [NmToken]
- data DefaultDecl
  - = REQUIRED
  - | IMPLIED
  - | DefaultTo AttValue (Maybe FIXED)
- data FIXED = FIXED
- data ConditionalSect
  - = IncludeSect IncludeSect
  - | IgnoreSect IgnoreSect
- type IncludeSect = [ExtSubsetDecl]
- type IgnoreSect = [IgnoreSectContents]
- data Ignore = Ignore
- data IgnoreSectContents = IgnoreSectContents Ignore [(IgnoreSectContents, Ignore)]
- data Reference
  - = RefEntity EntityRef
  - | RefChar CharRef
- type EntityRef = Name
- type CharRef = Int
- type PEReference = Name
- data EntityDecl
  - = EntityGEDecl GEDecl
  - | EntityPEDecl PEDecl
- data GEDecl = GEDecl Name EntityDef
- data PEDecl = PEDecl Name PEDef
- data EntityDef
  - = DefEntityValue EntityValue
  - | DefExternalID ExternalID (Maybe NDataDecl)
- data PEDef
  - = PEDefEntityValue EntityValue
  - | PEDefExternalID ExternalID
- data ExternalID
  - = SYSTEM SystemLiteral
  - | PUBLIC PubidLiteral SystemLiteral
- newtype NDataDecl = NDATA Name
- data TextDecl = TextDecl (Maybe VersionInfo) EncodingDecl
- data ExtParsedEnt i = ExtParsedEnt (Maybe TextDecl) (Content i)
- data ExtPE = ExtPE (Maybe TextDecl) [ExtSubsetDecl]
- data NotationDecl = NOTATION Name (Either ExternalID PublicID)
- newtype PublicID = PUBLICID PubidLiteral
- newtype EncodingDecl = EncodingDecl String
- data EntityValue = EntityValue [EV]
- data EV
  - = EVString String
  - | EVRef Reference
- newtype PubidLiteral = PubidLiteral String
- newtype SystemLiteral = SystemLiteral String
- type Name = String
- type Names = [Name]
- type NmToken = String
- type NmTokens = [NmToken]
- type CharData = String
- type CDSect = CharData

# A simple symbol table mapping strings (references) to values.

type SymTab a = [(String, a)]

## Symbol table operations

emptyST :: SymTab a

addST :: String -> a -> SymTab a -> SymTab a

lookupST :: String -> SymTab a -> Maybe a

# XML Types

## The top-level document container

data Document i

The symbol table stored in a document holds all its general entity reference definitions.

Constructors

Document Prolog (SymTab EntityDef) (Element i) [Misc] |

Instances

Functor Document |
Eq i => Eq (Document i) |

## The main document content

data Element i

Constructors

Elem Name [Attribute] [Content i] |

Instances

Functor Element |
Eq i => Eq (Element i) |
Verbatim (Element i) |

data ElemTag

Constructors

ElemTag Name [Attribute] |

Instances

Eq ElemTag |

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 |
Eq i => Eq (Content i) |
Verbatim (Content i) |

type Attribute = (Name, AttValue)

data AttValue

Constructors

AttValue [Either String Reference] |

Instances

Eq AttValue |
Show AttValue |

info :: Content t -> t

## Administrative parts of the document

data Prolog

Constructors

Prolog (Maybe XMLDecl) [Misc] (Maybe DocTypeDecl) [Misc] |

Instances

Eq Prolog |

data XMLDecl

Constructors

XMLDecl VersionInfo (Maybe EncodingDecl) (Maybe SDDecl) |

Instances

Eq XMLDecl |

data Misc

Constructors

Comment Comment |
PI ProcessingInstruction |

Instances

Eq Misc |

type ProcessingInstruction = (PITarget, String)

type SDDecl = Bool

type VersionInfo = String

type Comment = String

type PITarget = String

## The DTD

### content model

data DocTypeDecl

Constructors

DTD Name (Maybe ExternalID) [MarkupDecl] |

Instances

Eq DocTypeDecl |

data MarkupDecl

Constructors

Element ElementDecl |
AttList AttListDecl |
Entity EntityDecl |
Notation NotationDecl |
MarkupMisc Misc |

Instances

Eq MarkupDecl |

data ExtSubset

Constructors

ExtSubset (Maybe TextDecl) [ExtSubsetDecl] |

Instances

Eq ExtSubset |

data ExtSubsetDecl

Constructors

ExtMarkupDecl MarkupDecl |
ExtConditionalSect ConditionalSect |

Instances

Eq ExtSubsetDecl |

data ElementDecl

Constructors

ElementDecl Name ContentSpec |

Instances

Eq ElementDecl |

data ContentSpec

Constructors

EMPTY |
ANY |
Mixed Mixed |
ContentSpec CP |

Instances

Eq ContentSpec |

data CP

Constructors

TagName Name Modifier |
Choice [CP] Modifier |
Seq [CP] Modifier |

Instances

Eq CP |
Show CP |
Show CP |

data Modifier

Constructors

None | Just One
Query | Zero Or One
Star | Zero Or More
Plus | One Or More

Instances

Eq Modifier |
Show Modifier |
Show Modifier |

data Mixed

Constructors

PCDATA |
PCDATAplus [Name] |

Instances

Eq Mixed |

### attribute model

data AttListDecl

Constructors

AttListDecl Name [AttDef] |

Instances

Eq AttListDecl |

data AttDef

Constructors

AttDef Name AttType DefaultDecl |

Instances

Eq AttDef |

data AttType

Constructors

StringType |
TokenizedType TokenizedType |
EnumeratedType EnumeratedType |

Instances

Eq AttType |

data TokenizedType

Constructors

ID |
IDREF |
IDREFS |
ENTITY |
ENTITIES |
NMTOKEN |
NMTOKENS |

Instances

Eq TokenizedType |

data EnumeratedType

Constructors

NotationType NotationType |
Enumeration Enumeration |

Instances

Eq EnumeratedType |

type NotationType = [Name]

type Enumeration = [NmToken]

data DefaultDecl

Constructors

REQUIRED |
IMPLIED |
DefaultTo AttValue (Maybe FIXED) |

Instances

Eq DefaultDecl |

data FIXED

Constructors

FIXED |

Instances

Eq FIXED |

### conditional sections

data ConditionalSect

Constructors

IncludeSect IncludeSect |
IgnoreSect IgnoreSect |

Instances

Eq ConditionalSect |

type IncludeSect = [ExtSubsetDecl]

type IgnoreSect = [IgnoreSectContents]

data Ignore

Constructors

Ignore |

Instances

Eq Ignore |

data IgnoreSectContents

Constructors

IgnoreSectContents Ignore [(IgnoreSectContents, Ignore)] |

Instances

Eq IgnoreSectContents |

## References

data Reference

Constructors

RefEntity EntityRef |
RefChar CharRef |

Instances

Eq Reference |
Show Reference |
Verbatim Reference |

type EntityRef = Name

type CharRef = Int

type PEReference = Name

## Entities

data EntityDecl

Constructors

EntityGEDecl GEDecl |
EntityPEDecl PEDecl |

Instances

Eq EntityDecl |

data GEDecl

Constructors

GEDecl Name EntityDef |

Instances

Eq GEDecl |

data PEDecl

Constructors

PEDecl Name PEDef |

Instances

Eq PEDecl |

data EntityDef

Constructors

DefEntityValue EntityValue |
DefExternalID ExternalID (Maybe NDataDecl) |

Instances

Eq EntityDef |

data PEDef

Constructors

PEDefEntityValue EntityValue |
PEDefExternalID ExternalID |

Instances

Eq PEDef |
Show PEDef |

data ExternalID

Constructors

SYSTEM SystemLiteral |
PUBLIC PubidLiteral SystemLiteral |

Instances

Eq ExternalID |
Show ExternalID |

newtype NDataDecl

Constructors

NDATA Name |

Instances

Eq NDataDecl |

data TextDecl

Constructors

TextDecl (Maybe VersionInfo) EncodingDecl |

Instances

Eq TextDecl |

data ExtParsedEnt i

Constructors

ExtParsedEnt (Maybe TextDecl) (Content i) |

Instances

Eq i => Eq (ExtParsedEnt i) |

data ExtPE

Constructors

ExtPE (Maybe TextDecl) [ExtSubsetDecl] |

Instances

Eq ExtPE |

data NotationDecl

Constructors

NOTATION Name (Either ExternalID PublicID) |

Instances

Eq NotationDecl |

newtype PublicID

Constructors

PUBLICID PubidLiteral |

Instances

Eq PublicID |

newtype EncodingDecl

Constructors

EncodingDecl String |

Instances

Eq EncodingDecl |

data EntityValue

Constructors

EntityValue [EV] |

Instances

Eq EntityValue |
Show EntityValue |

data EV

Constructors

EVString String |
EVRef Reference |

Instances

Eq EV |
Show EV |

newtype PubidLiteral

Constructors

PubidLiteral String |

Instances

Eq PubidLiteral |
Show PubidLiteral |

newtype SystemLiteral

Constructors

SystemLiteral String |

Instances

Eq SystemLiteral |
Show SystemLiteral |

## Basic value types

type Name = String

type Names = [Name]

type NmToken = String

type NmTokens = [NmToken]

type CharData = String

type CDSect = CharData