dtd-types-0.1.0.0: Basic types for representing XML DTDs

Portabilityportable
MaintainerYitzchak Gale <gale@sefer.org>

Data.XML.DTD.Types

Contents

Description

This module provides types to represent an XML Document Type Declaration (DTD) as defined in W3C specifications (http://www.w3.org/XML/Core/#Publications). It is intended to be compatible with and extend the set of types in Data.XML.Types provided by the xml-types package.

Following the philosophy of Data.XML.Types, the types in this module are not intended to be a strict and complete representation of the model in the W3C specifications; rather, they are intended to be convenient and type-safe for the kinds of processing of DTDs that are commonly done in practice. As such, this model is compatible with both Version 1.0 and Version 1.1 of the XML specification.

Therefore, these types are not suitable for type-level validation of the syntax of a DTD. For example: these types are more lenient than the specs about the characters that are allowed in various locations in a DTD; entities of various kinds only appear as distinct syntactic elements in places where they are commonly needed when processing DTDs; etc.

Conditional sections are not represented in these types. They should be handled directly by parsers and renderers, if needed.

Synopsis

DTD structure

data DTD Source

A DTD is a sequence components in any order.

Instances

data DTDTextDecl Source

The ?xml text declaration at the beginning of a DTD.

Constructors

DTDTextDecl 

data DTDComponent Source

The kinds of components that can appear in a DTD.

Constructors

DTDEntityDecl EntityDecl

Entity declaration

DTDElementDecl ElementDecl

Element declaration

DTDAttrList AttrList

List of attribute declarions for an element

DTDNotation Notation

A notation declaration

DTDPERef PERef

A parameter entity reference in the top-level flow of the DTD

DTDInstruction Instruction

A processing instruction

DTDComment Text

A comment

Entity declarations and references

data EntityDecl Source

A declaration of an entity. An entity is a textual substitution variable. General entities can be referenced in an XML document conforming to the DTD, and parameter entities can be referenced in the DTD itself. The value of an unparsed entity is not specified in the DTD; it is specified by external syntax declared as a notation elsewhere in the DTD.

Constructors

InternalEntityDecl

An internal general entity

ExternalEntityDecl

An external general entity, parsed or unparsed. It is unparsed if a notation is specified.

ParameterEntityDecl

A parameter entity

data PEContent Source

Parameter entities need to be recursively resolved, so we represent their content as a mixture of nested parameter entity references and free text.

Constructors

PEText Text 
PENested PERef 

type PERef = TextSource

A parameter entity reference

Element declarations

data ElementDecl Source

A declaration of an element.

Constructors

ElementDecl 

Fields

eltDeclName :: Name
 
eltDeclContent :: ContentDecl
 

data ContentModel Source

A model of structured content for an element.

Constructors

CMName Name Repeat

Element name

CMChoice [ContentModel] Repeat

Choice, delimited by "|"

CMSeq [ContentModel] Repeat

Sequence, delimited by ","

data Repeat Source

The number of times a production of content model syntax can repeat.

Attribute declarations

data AttrList Source

A list of attribute declarations for an element.

Constructors

AttrList 

Fields

attrListElementName :: Name

The name of the element to which the attribute declarations apply

attrListDecls :: [AttrDecl]
 

data AttrDecl Source

A declaration of an attribute that can occur in an element.

Constructors

AttrDecl 

Fields

attrDeclName :: Name

The name of the attribute

attrDeclType :: AttrType

The type of the attribute

attrDeclDefault :: AttrDefault

The default value specification

data AttrType Source

The type of value that an attribute can take.

Constructors

AttrStringType

Any text

AttrIDType

A unique ID

AttrIDRefType

A reference to an ID

AttrIDRefsType

One or more references to IDs

AttrEntityType

An unparsed external entity

AttrEntitiesType

One or more unparsed external entities

AttrNmTokenType

A name-like token

AttrNmTokensType

One or more name-like tokens

AttrEnumType [Text]

One of the given values

AttrNotationType [Text]

Specified by external syntax declared as a notation

data AttrDefault Source

A default value specification for an attribute.

Constructors

AttrRequired

No default value; the attribute must always be supplied

AttrImplied

No default value; the attribute is optional

AttrFixed Text

When supplied, the attribute must have the given value

AttrDefaultValue Text

The attribute has the given default value when not supplied

Notation declarations

data Notation Source

A declaration of a notation.

data NotationSource Source

A source for a notation. We do not use the usual ExternalID type here, because for notations it is only optional, not required, for a public ID to be accompanied also by a system ID.

Constructors

NotationSysID Text

A system ID

NotationPubID Text

A public ID

NotationPubSysID Text Text

A public ID with a system ID