Text.XML.HaXml.Types

HaXml-1.25.3: Utilities for manipulating XML documents

Safe Haskell | Safe
Language | Haskell98

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
  - Namespaces
  - 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 QName [Attribute] [Content i]
- data ElemTag = ElemTag QName [Attribute]
- data Content i
  - = CElem (Element i) i
  - | CString Bool CharData i
  - | CRef Reference i
  - | CMisc Misc i
- type Attribute = (QName, 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 QName (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 QName ContentSpec
- data ContentSpec
  - = EMPTY
  - | ANY
  - | Mixed Mixed
  - | ContentSpec CP
- data CP
  - = TagName QName Modifier
  - | Choice [CP] Modifier
  - | Seq [CP] Modifier
- data Modifier
  - = None
  - | Query
  - | Star
  - | Plus
- data Mixed
  - = PCDATA
  - | PCDATAplus [QName]
- data AttListDecl = AttListDecl QName [AttDef]
- data AttDef = AttDef QName 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
- data QName
  - = N Name
  - | QN Namespace Name
- data Namespace = Namespace {
  - nsPrefix :: String
  - nsURI :: 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 (Document i) |
Show i => Show (Document i) |

## The main document content

data Element i

Constructors

Elem QName [Attribute] [Content i] |

Instances

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

data ElemTag

Constructors

ElemTag QName [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 (Content i) |
Show i => Show (Content i) |
Verbatim (Content i) |

type Attribute = (QName, AttValue)

data AttValue

Constructors

AttValue [Either String Reference] |

Instances

Eq AttValue |
Show AttValue |
Verbatim AttValue |

info :: Content t -> t

## Administrative parts of the document

data Prolog

Constructors

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

Instances

Eq Prolog |
Show Prolog |

data XMLDecl

Constructors

XMLDecl VersionInfo (Maybe EncodingDecl) (Maybe SDDecl) |

Instances

Eq XMLDecl |
Show XMLDecl |

data Misc

Constructors

Comment Comment |
PI ProcessingInstruction |

Instances

Eq Misc |
Show 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 QName (Maybe ExternalID) [MarkupDecl] |

Instances

Eq DocTypeDecl |
Show DocTypeDecl |

data MarkupDecl

Constructors

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

Instances

Eq MarkupDecl |
Show MarkupDecl |

data ExtSubset

Constructors

ExtSubset (Maybe TextDecl) [ExtSubsetDecl] |

Instances

Eq ExtSubset |
Show ExtSubset |

data ExtSubsetDecl

Constructors

ExtMarkupDecl MarkupDecl |
ExtConditionalSect ConditionalSect |

Instances

Eq ExtSubsetDecl |
Show ExtSubsetDecl |

data ElementDecl

Constructors

ElementDecl QName ContentSpec |

Instances

Eq ElementDecl |
Show ElementDecl |

data ContentSpec

Constructors

EMPTY |
ANY |
Mixed Mixed |
ContentSpec CP |

Instances

Eq ContentSpec |
Show ContentSpec |

data CP

Constructors

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

Instances

Eq 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 |

data Mixed

Constructors

PCDATA |
PCDATAplus [QName] |

Instances

Eq Mixed |
Show Mixed |

### attribute model

data AttListDecl

Constructors

AttListDecl QName [AttDef] |

Instances

Eq AttListDecl |
Show AttListDecl |

data AttDef

Constructors

AttDef QName AttType DefaultDecl |

Instances

Eq AttDef |
Show AttDef |

data AttType

Constructors

StringType |
TokenizedType TokenizedType |
EnumeratedType EnumeratedType |

Instances

Eq AttType |
Show AttType |

data TokenizedType

Constructors

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

Instances

Eq TokenizedType |
Show TokenizedType |

data EnumeratedType

Constructors

NotationType NotationType |
Enumeration Enumeration |

Instances

Eq EnumeratedType |
Show EnumeratedType |

type NotationType = [Name]

type Enumeration = [NmToken]

data DefaultDecl

Constructors

REQUIRED |
IMPLIED |
DefaultTo AttValue (Maybe FIXED) |

Instances

Eq DefaultDecl |
Show DefaultDecl |

data FIXED

Constructors

FIXED |

Instances

Eq FIXED |
Show FIXED |

### conditional sections

data ConditionalSect

Constructors

IncludeSect IncludeSect |
IgnoreSect IgnoreSect |

Instances

Eq ConditionalSect |
Show ConditionalSect |

type IncludeSect = [ExtSubsetDecl]

type IgnoreSect = [IgnoreSectContents]

data Ignore

Constructors

Ignore |

Instances

Eq Ignore |
Show Ignore |

data IgnoreSectContents

Constructors

IgnoreSectContents Ignore [(IgnoreSectContents, Ignore)] |

Instances

Eq IgnoreSectContents |
Show 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 |
Show EntityDecl |

data GEDecl

Constructors

GEDecl Name EntityDef |

Instances

Eq GEDecl |
Show GEDecl |

data PEDecl

Constructors

PEDecl Name PEDef |

Instances

Eq PEDecl |
Show PEDecl |

data EntityDef

Constructors

DefEntityValue EntityValue |
DefExternalID ExternalID (Maybe NDataDecl) |

Instances

Eq EntityDef |
Show 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 |
Show NDataDecl |

data TextDecl

Constructors

TextDecl (Maybe VersionInfo) EncodingDecl |

Instances

Eq TextDecl |
Show TextDecl |

data ExtParsedEnt i

Constructors

ExtParsedEnt (Maybe TextDecl) (Content i) |

Instances

Eq (ExtParsedEnt i) |
Show i => Show (ExtParsedEnt i) |

data ExtPE

Constructors

ExtPE (Maybe TextDecl) [ExtSubsetDecl] |

Instances

Eq ExtPE |
Show ExtPE |

data NotationDecl

Constructors

NOTATION Name (Either ExternalID PublicID) |

Instances

Eq NotationDecl |
Show NotationDecl |

newtype PublicID

Constructors

PUBLICID PubidLiteral |

Instances

Eq PublicID |
Show PublicID |

newtype EncodingDecl

Constructors

EncodingDecl String |

Instances

Eq EncodingDecl |
Show 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 |

## Namespaces

data QName

A QName is a (possibly) qualified name, in the sense of XML namespaces.

Constructors

N Name |
QN Namespace Name |

Instances

Eq QName |
Ord QName |
Show QName |

data Namespace

Namespaces are not defined in the XML spec itself, but at http://www.w3.org/TR/xml-names

Constructors

Namespace |
Fields nsPrefix :: String nsURI :: String

Instances

Eq Namespace |
Show Namespace |

## Basic value types

type Name = String

type Names = [Name]

type NmToken = String

type NmTokens = [NmToken]

type CharData = String

type CDSect = CharData