dtd-text-0.1.2.0: Parse and render XML DTDs

Portabilityportable
MaintainerMontez Fitzpatrick <montezf@gmail.com>
Safe HaskellNone

Data.XML.DTD.Parse

Contents

Description

This module provides a Data.Attoparsec.Text parser for XML Document Type Declaration (DTD) documents. A higher-level interface that implements parameter entity resolution is also provided.

Synopsis

Parsing a DTD

dtd :: Parser DTDSource

Parse a DTD. Parameter entity substitution is not supported by this parser, so parameter entities cannot appear in places where a valid DTD syntax production cannot be determined without resolving them.

parseDTD :: Text -> DTDSource

Parse a DTD from lazy Text while fully resolving the values of all parameter entities whose values are provided internally in the DTD. If the syntax of the DTD is invalid, all declarations up to the first invalid one are returned.

parseDTDWithExtern :: SymTable -> Text -> DTDSource

Parse a DTD from lazy Text while fully resolving the values of parameter entities. The given table of values is used to resolve external parameter entities.

If you need information from the DTD itself to look up the external entities, such as system and public IDs, you might be able to get the information by applying parseDTD to the DTD or part of it for an initial parse.

type SymTable = Map Text TextSource

A symbol table for external parameter entity resolution. The symbol table maps strict Text names to lazy Text values. Typically, the values will have been retrieved from an external resource such as a file or URL.

Top-level DTD structure

textDecl :: Parser DTDTextDeclSource

Parse an ?xml text declaration at the beginning of a DTD.

dtdComponent :: Parser DTDComponentSource

Parse a single component of a DTD. Conditional sections are currently not supported.

Entity declarations and references

entityDecl :: Parser EntityDeclSource

Parse an entity declaration.

entityValue :: Parser [EntityValue]Source

Parse an entity value. An entity value is a quoted string possibly containing parameter entity references.

pERef :: Parser PERefSource

Parse a parameter entity reference

notation :: Parser NotationSource

Parse a declaration of a notation.

notationSrc :: Parser NotationSourceSource

Parse a source for a notation.

Element declarations

elementDecl :: Parser ElementDeclSource

Parse the declaration of an element.

contentDecl :: Parser ContentDeclSource

Parse the content that can occur in an element.

contentModel :: Parser Text ContentModelSource

Parse the model of structured content for an element.

repeatChar :: Parser RepeatSource

Parse a repetition character.

Attribute declarations

attList :: Parser AttListSource

Parse a list of attribute declarations for an element.

attDecl :: Parser AttDeclSource

Parse the three-part declaration of an attribute.

attType :: Parser AttTypeSource

Parse the type of an attribute.

attDefault :: Parser AttDefaultSource

Parse a default value specification for an attribute.

Declarations of comments and processing instructions

instruction :: Parser InstructionSource

Parse a processing instruction.

comment :: Parser TextSource

Parse a comment

Parsing combinators for general DTD syntax

externalID :: Parser ExternalIDSource

Parse an external ID.

name :: Parser TextSource

Parse a DTD name. We are much more liberal than the spec: we allow any characters that will not interfere with other DTD syntax. This parser subsumes both Name and NmToken in the spec, and more.

nameSS :: Parser TextSource

Parse a DTD name followed by optional white space.

quoted :: Parser TextSource

A single-quoted or double-quoted string. The quotation marks are dropped.