|
|
|
|
|
Description |
An extended variant of Node intended to implement the entire XML
specification. DTDs are not yet supported, however.
The names conflict with those in Tree so you must use qualified import
if you want to use both modules.
|
|
Synopsis |
|
|
|
|
Tree structure
|
|
type Document a tag text = DocumentG a [] tag text |
A pure representation of an XML document that uses a list as its container type.
|
|
data DocumentG a c tag text |
Document representation of the XML document, intended to support the entire
XML specification. DTDs are not yet supported, however.
| Constructors | | Instances | |
|
|
type Node a tag text = NodeG a [] tag text |
A pure tree representation that uses a list as its container type,
extended variant.
In the hexpat package, a list of nodes has the type [Node tag text], but note
that you can also use the more general type function ListOf to give a list of
any node type, using that node's associated list type, e.g.
ListOf (UNode Text).
|
|
data NodeG a c tag text |
Extended variant of the tree representation of the XML document, intended
to support the entire XML specification. DTDs are not yet supported, however.
c is the container type for the element's children, which is [] in the
hexpat package, and a monadic list type for hexpat-iteratee.
tag is the tag type, which can either be one of several string types,
or a special type from the Text.XML.Expat.Namespaced or
Text.XML.Expat.Qualified modules.
text is the string type for text content.
a is the type of the annotation. One of the things this can be used for
is to store the XML parse location, which is useful for error handling.
Note that some functions in the Text.XML.Expat.Cursor module need to create
new nodes through the MkElementClass type class. Normally this can only be done
if a is a Maybe type or () (so it can provide the Nothing value for the annotation
on newly created nodes). Or, you can write your own MkElementClass instance.
Apart from that, there is no requirement for a to be a Maybe type.
| Constructors | Element | | eName :: !tag | | eAttributes :: ![(tag, text)] | | eChildren :: c (NodeG a c tag text) | | eAnn :: a | |
| Text !text | | CData !text | | Misc (Misc text) | |
| Instances | |
|
|
type UDocument a text = Document a text text |
Type alias for an extended document with unqualified tag names where
tag and text are the same string type
|
|
type LDocument tag text = Document XMLParseLocation tag text |
Type alias for an extended document, annotated with parse location
|
|
type ULDocument text = Document XMLParseLocation text text |
Type alias for an extended document with unqualified tag names where
tag and text are the same string type, annotated with parse location
|
|
type UNode a text = Node a text text |
Type alias for an extended node with unqualified tag names where
tag and text are the same string type
|
|
type LNode tag text = Node XMLParseLocation tag text |
Type alias for an extended node, annotated with parse location
|
|
type ULNode text = LNode text text |
Type alias for an extended node with unqualified tag names where
tag and text are the same string type, annotated with parse location
|
|
Generic document/node manipulation
|
|
module Text.XML.Expat.Internal.DocumentClass |
|
module Text.XML.Expat.Internal.NodeClass |
|
Annotation-specific
|
|
modifyAnnotation :: (a -> a) -> Node a tag text -> Node a tag text |
Modify this node's annotation (non-recursively) if it's an element, otherwise no-op.
|
|
mapAnnotation :: (a -> b) -> Node a tag text -> Node b tag text |
Modify this node's annotation and all its children recursively if it's an element, otherwise no-op.
|
|
mapDocumentAnnotation :: (a -> b) -> Document a tag text -> Document b tag text |
Modify the annotation of every node in the document recursively.
|
|
Qualified nodes
|
|
type QDocument a text = Document a (QName text) text |
Type alias for an extended document where qualified names are used for tags
|
|
type QLDocument text = Document XMLParseLocation (QName text) text |
Type alias for an extended document where qualified names are used for tags, annotated with parse location
|
|
type QNode a text = Node a (QName text) text |
Type alias for an extended node where qualified names are used for tags
|
|
type QLNode text = LNode (QName text) text |
Type alias for an extended node where qualified names are used for tags, annotated with parse location
|
|
module Text.XML.Expat.Internal.Qualified |
|
Namespaced nodes
|
|
type NDocument a text = Document a (NName text) text |
Type alias for an extended document where namespaced names are used for tags
|
|
type NLDocument text = Document XMLParseLocation (NName text) text |
Type alias for an extended document where namespaced names are used for tags, annotated with parse location
|
|
type NNode a text = Node a (NName text) text |
Type alias for an extended node where namespaced names are used for tags
|
|
type NLNode text = LNode (NName text) text |
Type alias for an extended node where namespaced names are used for tags, annotated with parse location
|
|
module Text.XML.Expat.Internal.Namespaced |
|
Parse to tree
|
|
data ParseOptions tag text |
Constructors | ParseOptions | | overrideEncoding :: Maybe Encoding | The encoding parameter, if provided, overrides the document's
encoding declaration.
| entityDecoder :: Maybe (tag -> Maybe text) | If provided, entity references (i.e. and friends) will
be decoded into text using the supplied lookup function
|
|
|
|
|
defaultParseOptions :: ParseOptions tag text |
|
data Encoding |
Encoding types available for the document encoding.
| Constructors | |
|
|
parse |
|
|
parse' |
|
|
data XMLParseError |
Parse error, consisting of message text and error location
| Constructors | | Instances | |
|
|
data XMLParseLocation |
Specifies a location of an event within the input text
| Constructors | XMLParseLocation | | xmlLineNumber :: Int64 | Line number of the event
| xmlColumnNumber :: Int64 | Column number of the event
| xmlByteIndex :: Int64 | Byte index of event from start of document
| xmlByteCount :: Int64 | The number of bytes in the event
|
|
| Instances | |
|
|
Variant that throws exceptions
|
|
parseThrowing |
:: (GenericXMLString tag, GenericXMLString text) | | => ParseOptions tag text | Parse options
| -> ByteString | Input text (a lazy ByteString)
| -> LDocument tag text | | Lazily parse XML to tree. In the event of an error, throw XMLParseException.
parseThrowing can throw an exception from pure code, which is generally a bad
way to handle errors, because Haskell's lazy evaluation means it's hard to
predict where it will be thrown from. However, it may be acceptable in
situations where it's not expected during normal operation, depending on the
design of your program.
|
|
|
data XMLParseException |
An exception indicating an XML parse error, used by the ..Throwing variants.
| Constructors | | Instances | |
|
|
Convert from SAX
|
|
saxToTree :: (GenericXMLString tag, Monoid text) => [(SAXEvent tag text, a)] -> (Document a tag text, Maybe XMLParseError) |
A lower level function that lazily converts a SAX stream into a tree structure.
Variant that takes annotations for start tags.
|
|
Abstraction of string types
|
|
class (Monoid s, Eq s) => GenericXMLString s where |
An abstraction for any string type you want to use as xml text (that is,
attribute values or element text content). If you want to use a
new string type with hexpat, you must make it an instance of
GenericXMLString.
| | Methods | | | Instances | |
|
|
Produced by Haddock version 2.7.2 |