-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Parse and render DTD files
--
-- Parse and render DTD files
@package dtd
@version 0.4.1
-- | 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.
module Data.DTD.Types.Unresolved
-- | A DTD is a sequence components in any order.
data DTD
DTD :: Maybe DTDTextDecl -> [DTDComponent] -> DTD
dtdTextDecl :: DTD -> Maybe DTDTextDecl
dtdComponents :: DTD -> [DTDComponent]
-- | The ?xml text declaration at the beginning of a DTD.
data DTDTextDecl
DTDTextDecl :: Maybe Text -> Text -> DTDTextDecl
dtdXMLVersion :: DTDTextDecl -> Maybe Text
dtdEncoding :: DTDTextDecl -> Text
-- | The kinds of components that can appear in a DTD.
data DTDComponent
-- | Entity declaration
DTDEntityDecl :: EntityDecl -> DTDComponent
-- | Element declaration
DTDElementDecl :: ElementDecl -> DTDComponent
-- | List of attribute declarions for an element
DTDAttList :: AttList -> DTDComponent
-- | A notation declaration
DTDNotation :: Notation -> DTDComponent
-- | A parameter entity reference in the top-level flow of the DTD
DTDPERef :: PERef -> DTDComponent
-- | A processing instruction
DTDInstruction :: Instruction -> DTDComponent
-- | A comment
DTDComment :: Text -> DTDComponent
-- | 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.
data EntityDecl
InternalGeneralEntityDecl :: Text -> [EntityValue] -> EntityDecl
entityDeclName :: EntityDecl -> Text
entityDeclValue :: EntityDecl -> [EntityValue]
-- | An external general entity is unparsed if a notation is specified.
ExternalGeneralEntityDecl :: Text -> ExternalID -> Maybe Text -> EntityDecl
entityDeclName :: EntityDecl -> Text
entityDeclID :: EntityDecl -> ExternalID
entityDeclNotation :: EntityDecl -> Maybe Text
InternalParameterEntityDecl :: Text -> [EntityValue] -> EntityDecl
entityDeclName :: EntityDecl -> Text
entityDeclValue :: EntityDecl -> [EntityValue]
ExternalParameterEntityDecl :: Text -> ExternalID -> EntityDecl
entityDeclName :: EntityDecl -> Text
entityDeclID :: EntityDecl -> ExternalID
-- | The value of an internal entity may contain references to parameter
-- entities; these references need to be resolved to obtain the actual
-- replacement value of the entity. So we represent the value as a
-- mixture of parameter entity references and free text.
data EntityValue
EntityText :: Text -> EntityValue
EntityPERef :: PERef -> EntityValue
-- | A parameter entity reference. It contains the name of the parameter
-- entity that is being referenced.
type PERef = Text
-- | A declaration of an element.
data ElementDecl
ElementDecl :: Either PERef Text -> ContentDecl -> ElementDecl
eltDeclName :: ElementDecl -> Either PERef Text
eltDeclContent :: ElementDecl -> ContentDecl
-- | The content that can occur in an element.
data ContentDecl
-- | No content
ContentEmpty :: ContentDecl
-- | Unrestricted content
ContentAny :: ContentDecl
-- | Structured element content
ContentElement :: [EntityValue] -> ContentDecl
-- | A mixture of text and elements
ContentMixed :: [Text] -> ContentDecl
ContentPERef :: PERef -> ContentDecl
-- | A model of structured content for an element.
data ContentModel
-- | Element name
CMName :: Text -> Repeat -> ContentModel
-- | Choice, delimited by "|"
CMChoice :: [ContentModel] -> Repeat -> ContentModel
-- | Sequence, delimited by ","
CMSeq :: [ContentModel] -> Repeat -> ContentModel
-- | The number of times a production of content model syntax can repeat.
data Repeat
One :: Repeat
ZeroOrOne :: Repeat
ZeroOrMore :: Repeat
OneOrMore :: Repeat
-- | A list of attribute declarations for an element.
data AttList
AttList :: Either PERef Text -> [AttDeclPERef] -> AttList
-- | The name of the element to which the attribute declarations apply
attListElementName :: AttList -> Either PERef Text
attListDecls :: AttList -> [AttDeclPERef]
-- | A declaration of an attribute that can occur in an element.
data AttDecl
AttDecl :: Text -> AttTypePERef -> AttDefault -> AttDecl
-- | The name of the attribute
attDeclName :: AttDecl -> Text
-- | The type of the attribute
attDeclType :: AttDecl -> AttTypePERef
-- | The default value specification
attDeclDefault :: AttDecl -> AttDefault
data AttDeclPERef
ADPDecl :: AttDecl -> AttDeclPERef
ADPPERef :: PERef -> AttDeclPERef
-- | The type of value that an attribute can take.
data AttType
-- | Any text
AttStringType :: AttType
-- | A unique ID
AttIDType :: AttType
-- | A reference to an ID
AttIDRefType :: AttType
-- | One or more references to IDs
AttIDRefsType :: AttType
-- | An unparsed external entity
AttEntityType :: AttType
-- | One or more unparsed external entities
AttEntitiesType :: AttType
-- | A name-like token
AttNmTokenType :: AttType
-- | One or more name-like tokens
AttNmTokensType :: AttType
-- | One of the given values
AttEnumType :: [Text] -> AttType
-- | Specified by external syntax declared as a notation
AttNotationType :: [Text] -> AttType
data AttTypePERef
ATPType :: AttType -> AttTypePERef
ATPPERef :: PERef -> AttTypePERef
-- | A default value specification for an attribute.
data AttDefault
-- | No default value; the attribute must always be supplied
AttRequired :: AttDefault
-- | No default value; the attribute is optional
AttImplied :: AttDefault
-- | When supplied, the attribute must have the given value
AttFixed :: Text -> AttDefault
-- | The attribute has the given default value when not supplied
AttDefaultValue :: Text -> AttDefault
-- | A declaration of a notation.
data Notation
Notation :: Text -> NotationSource -> Notation
notationName :: Notation -> Text
notationSource :: Notation -> NotationSource
-- | 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.
data NotationSource
-- | A system ID
NotationSysID :: Text -> NotationSource
-- | A public ID
NotationPubID :: Text -> NotationSource
-- | A public ID with a system ID
NotationPubSysID :: Text -> Text -> NotationSource
instance Show DTDTextDecl
instance Eq DTDTextDecl
instance Show EntityValue
instance Eq EntityValue
instance Show EntityDecl
instance Eq EntityDecl
instance Show ContentDecl
instance Eq ContentDecl
instance Show ElementDecl
instance Eq ElementDecl
instance Show Repeat
instance Eq Repeat
instance Show ContentModel
instance Eq ContentModel
instance Show AttType
instance Eq AttType
instance Show AttTypePERef
instance Eq AttTypePERef
instance Show AttDefault
instance Eq AttDefault
instance Show AttDecl
instance Eq AttDecl
instance Show AttDeclPERef
instance Eq AttDeclPERef
instance Show AttList
instance Eq AttList
instance Show NotationSource
instance Eq NotationSource
instance Show Notation
instance Eq Notation
instance Show DTDComponent
instance Eq DTDComponent
instance Show DTD
instance Eq DTD
instance Typeable NotationSource
instance Typeable Notation
instance Typeable AttDefault
instance Typeable AttType
instance Typeable AttDecl
instance Typeable AttList
instance Typeable Repeat
instance Typeable ContentModel
instance Typeable ContentDecl
instance Typeable ElementDecl
instance Typeable EntityValue
instance Typeable EntityDecl
instance Typeable DTDComponent
instance Typeable DTDTextDecl
instance Typeable DTD
-- | 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.
module Data.DTD.Parse.Unresolved
-- | 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.
dtd :: Parser DTD
-- | Parse an ?xml text declaration at the beginning of a
-- DTD.
textDecl :: Parser DTDTextDecl
-- | Parse a single component of a DTD. Conditional sections are
-- currently not supported.
dtdComponent :: Parser DTDComponent
-- | Parse an entity declaration.
entityDecl :: Parser EntityDecl
-- | Parse an entity value. An entity value is a quoted string possibly
-- containing parameter entity references.
entityValue :: Parser [EntityValue]
-- | Parse a parameter entity reference
pERef :: Parser PERef
-- | Parse a declaration of a notation.
notation :: Parser Notation
-- | Parse a source for a notation.
notationSrc :: Parser NotationSource
-- | Parse the declaration of an element.
elementDecl :: Parser ElementDecl
-- | Parse the content that can occur in an element.
contentDecl :: Parser ContentDecl
-- | Parse the model of structured content for an element.
contentModel :: Parser ContentModel
-- | Parse a repetition character.
repeatChar :: Parser Repeat
-- | Parse a list of attribute declarations for an element.
attList :: Parser AttList
-- | Parse the three-part declaration of an attribute.
attDecl :: Parser AttDecl
attDeclPERef :: Parser AttDeclPERef
-- | Parse the type of an attribute.
attType :: Parser AttType
-- | Parse a default value specification for an attribute.
attDefault :: Parser AttDefault
-- | Parse a processing instruction.
instruction :: Parser Instruction
-- | Parse a comment
comment :: Parser Text
-- | Parse an external ID.
externalID :: Parser ExternalID
-- | 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.
name :: Parser Text
-- | Parse a DTD name followed by optional white space.
nameSS :: Parser Text
-- | A single-quoted or double-quoted string. The quotation marks are
-- dropped.
quoted :: Parser Text
-- | Skip zero or more characters of white space
skipWS :: Parser ()
-- | Parse one character of white space.
ws :: Parser Char
instance Eq MarkupText
instance Show MarkupText
instance Eq PreParse
instance Show PreParse
module Data.DTD.Types
-- | A DTD is a sequence components in any order.
data DTD
DTD :: Maybe DTDTextDecl -> [DTDComponent] -> DTD
dtdTextDecl :: DTD -> Maybe DTDTextDecl
dtdComponents :: DTD -> [DTDComponent]
-- | The ?xml text declaration at the beginning of a DTD.
data DTDTextDecl
DTDTextDecl :: Maybe Text -> Text -> DTDTextDecl
dtdXMLVersion :: DTDTextDecl -> Maybe Text
dtdEncoding :: DTDTextDecl -> Text
-- | The kinds of components that can appear in a DTD.
data DTDComponent
-- | Entity declaration
DTDEntityDecl :: EntityDecl -> DTDComponent
-- | Element declaration
DTDElementDecl :: ElementDecl -> DTDComponent
-- | List of attribute declarions for an element
DTDAttList :: AttList -> DTDComponent
-- | A notation declaration
DTDNotation :: Notation -> DTDComponent
-- | A processing instruction
DTDInstruction :: Instruction -> DTDComponent
-- | A comment
DTDComment :: Text -> DTDComponent
data EntityDecl
InternalGeneralEntityDecl :: Text -> Text -> EntityDecl
entityDeclName :: EntityDecl -> Text
entityDeclValue :: EntityDecl -> Text
-- | An external general entity is unparsed if a notation is specified.
ExternalGeneralEntityDecl :: Text -> ExternalID -> Maybe Text -> EntityDecl
entityDeclName :: EntityDecl -> Text
entityDeclID :: EntityDecl -> ExternalID
entityDeclNotation :: EntityDecl -> Maybe Text
-- | A declaration of an element.
data ElementDecl
ElementDecl :: Text -> ContentDecl -> ElementDecl
eltDeclName :: ElementDecl -> Text
eltDeclContent :: ElementDecl -> ContentDecl
-- | The content that can occur in an element.
data ContentDecl
-- | No content
ContentEmpty :: ContentDecl
-- | Unrestricted content
ContentAny :: ContentDecl
-- | Structured element content
ContentElement :: ContentModel -> ContentDecl
-- | A mixture of text and elements
ContentMixed :: [Text] -> ContentDecl
-- | A model of structured content for an element.
data ContentModel
-- | Element name
CMName :: Text -> Repeat -> ContentModel
-- | Choice, delimited by "|"
CMChoice :: [ContentModel] -> Repeat -> ContentModel
-- | Sequence, delimited by ","
CMSeq :: [ContentModel] -> Repeat -> ContentModel
-- | The number of times a production of content model syntax can repeat.
data Repeat
One :: Repeat
ZeroOrOne :: Repeat
ZeroOrMore :: Repeat
OneOrMore :: Repeat
-- | A list of attribute declarations for an element.
data AttList
AttList :: Text -> [AttDecl] -> AttList
-- | The name of the element to which the attribute declarations apply
attListElementName :: AttList -> Text
attListDecls :: AttList -> [AttDecl]
-- | A declaration of an attribute that can occur in an element.
data AttDecl
AttDecl :: Text -> AttType -> AttDefault -> AttDecl
-- | The name of the attribute
attDeclName :: AttDecl -> Text
-- | The type of the attribute
attDeclType :: AttDecl -> AttType
-- | The default value specification
attDeclDefault :: AttDecl -> AttDefault
-- | The type of value that an attribute can take.
data AttType
-- | Any text
AttStringType :: AttType
-- | A unique ID
AttIDType :: AttType
-- | A reference to an ID
AttIDRefType :: AttType
-- | One or more references to IDs
AttIDRefsType :: AttType
-- | An unparsed external entity
AttEntityType :: AttType
-- | One or more unparsed external entities
AttEntitiesType :: AttType
-- | A name-like token
AttNmTokenType :: AttType
-- | One or more name-like tokens
AttNmTokensType :: AttType
-- | One of the given values
AttEnumType :: [Text] -> AttType
-- | Specified by external syntax declared as a notation
AttNotationType :: [Text] -> AttType
-- | A default value specification for an attribute.
data AttDefault
-- | No default value; the attribute must always be supplied
AttRequired :: AttDefault
-- | No default value; the attribute is optional
AttImplied :: AttDefault
-- | When supplied, the attribute must have the given value
AttFixed :: Text -> AttDefault
-- | The attribute has the given default value when not supplied
AttDefaultValue :: Text -> AttDefault
-- | A declaration of a notation.
data Notation
Notation :: Text -> NotationSource -> Notation
notationName :: Notation -> Text
notationSource :: Notation -> NotationSource
-- | 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.
data NotationSource
-- | A system ID
NotationSysID :: Text -> NotationSource
-- | A public ID
NotationPubID :: Text -> NotationSource
-- | A public ID with a system ID
NotationPubSysID :: Text -> Text -> NotationSource
instance Typeable ContentDecl
instance Typeable ElementDecl
instance Typeable EntityDecl
instance Typeable AttList
instance Typeable DTDComponent
instance Typeable DTD
instance Show ContentDecl
instance Eq ContentDecl
instance Show ElementDecl
instance Eq ElementDecl
instance Show EntityDecl
instance Eq EntityDecl
instance Show AttDecl
instance Eq AttDecl
instance Show AttList
instance Eq AttList
instance Show DTDComponent
instance Eq DTDComponent
instance Show DTD
instance Eq DTD
module Data.DTD.Parse
readFile_ :: FilePath -> IO [DTDComponent]
enumFile :: (MonadBaseControl IO m, MonadResource m) => FilePath -> Source m DTDComponent
filePathToEID :: MonadIO m => FilePath -> m ExternalID
uriToEID :: URI -> ExternalID
readEID :: (MonadResource m, MonadBaseControl IO m) => Catalog -> ExternalID -> SchemeMap -> Source m DTDComponent
instance Typeable ResolveException'
instance Typeable ResolveException
instance Show ResolveState
instance Show ResolveException'
instance Show ResolveException
instance Exception ResolveException'
instance Exception ResolveException
-- | A Blaze.ByteString.Builder renderer for XML Document Type
-- Declaration (DTD) documents.
module Data.DTD.Render
-- | A Builder for a DTD.
buildDTD :: DTD -> Builder
-- | A Builder for a DTDTextDecl.
buildDTDTextDecl :: DTDTextDecl -> Builder
-- | A Builder for a DTDComponent.
buildDTDComponent :: DTDComponent -> Builder
-- | A Builder for an EntityDecl.
buildEntityDecl :: EntityDecl -> Builder
-- | A Builder for an ElementDecl.
buildElementDecl :: ElementDecl -> Builder
-- | A Builder for a ContentDecl.
buildContentDecl :: ContentDecl -> Builder
-- | A Builder for a ContentModel.
buildContentModel :: ContentModel -> Builder
-- | A Builder for a Repeat.
buildRepeat :: Repeat -> Builder
-- | A Builder for an AttList.
buildAttList :: AttList -> Builder
-- | A Builder for an AttDecl.
buildAttDecl :: AttDecl -> Builder
-- | A Builder for an AttType.
buildAttType :: AttType -> Builder
-- | A Builder for an AttDefault.
buildAttDefault :: AttDefault -> Builder
-- | A Builder for a Notation.
buildNotation :: Notation -> Builder
-- | A Builder for a NotationSource.
buildNotationSource :: NotationSource -> Builder
-- | A Builder for an Instruction.
buildInstruction :: Instruction -> Builder
-- | A Builder for a comment. The comment text cannot be null,
-- cannot contain two consecutive -, and cannot end in -.
buildComment :: Text -> Builder
-- | A Builder for an ExternalID.
buildExternalID :: ExternalID -> Builder
-- | Build a list of items
buildList :: Text -> (a -> Builder) -> [a] -> Builder
-- | Build a choice expression.
buildChoice :: (a -> Builder) -> [a] -> Builder
-- | Build an optional item.
buildMaybe :: (a -> Builder) -> Maybe a -> Builder
-- | Build a newline.
newline :: Builder
-- | Build a space.
space :: Builder
-- | Build a quoted string.
quote :: Builder -> Builder
-- | Build a string quoted by angle brackets, with an exclamation mark.
pbracket :: Builder -> Builder
-- | Build a string surround by parantheses.
parens :: Builder -> Builder
module Data.DTD.Cache
data DTDCache
applyDTD :: (MonadBaseControl IO m, MonadIO m) => DTDCache -> Document -> m (Either UnresolvedEntity Document)
applyDTD_ :: (MonadBaseControl IO m, MonadIO m) => DTDCache -> Document -> m Document
newDTDCache :: MonadIO m' => Catalog -> SchemeMap -> m' DTDCache
newDTDCacheFile :: MonadIO m => FilePath -> m DTDCache
loadAttrMap :: MonadIO m => DTDCache -> ExternalID -> m (EntityMap, AttrMap)
data UnresolvedEntity
UnresolvedEntity :: Text -> UnresolvedEntity
type AttrMap = Map Name (Map Name Att)
type EntityMap = Map Text Text
data Att
Def :: Text -> Att
Fixed :: Text -> Att
instance Typeable UnknownExternalID
instance Typeable UnresolvedEntity
instance Show UnknownExternalID
instance Show UnresolvedEntity
instance Exception UnresolvedEntity
instance Exception UnknownExternalID