|
|
|
|
|
Description |
This module provides functions to parse an XML document to a lazy
stream of SAX events.
|
|
Synopsis |
|
| | data XMLParseError = XMLParseError String XMLParseLocation | | data XMLParseLocation = XMLParseLocation {} | | data ParserOptions tag text = ParserOptions {} | | | | textFromCString :: GenericXMLString text => CString -> IO text | | parse :: (GenericXMLString tag, GenericXMLString text) => ParserOptions tag text -> ByteString -> [SAXEvent tag text] | | parseLocations :: (GenericXMLString tag, GenericXMLString text) => ParserOptions tag text -> ByteString -> [(SAXEvent tag text, XMLParseLocation)] | | parseLocationsThrowing :: (GenericXMLString tag, GenericXMLString text) => ParserOptions tag text -> ByteString -> [(SAXEvent tag text, XMLParseLocation)] | | parseThrowing :: (GenericXMLString tag, GenericXMLString text) => ParserOptions tag text -> ByteString -> [SAXEvent tag text] | | defaultParserOptions :: ParserOptions tag text | | data XMLParseException = XMLParseException XMLParseError | | parseSAX :: (GenericXMLString tag, GenericXMLString text) => Maybe Encoding -> ByteString -> [SAXEvent tag text] | | parseSAXLocations :: (GenericXMLString tag, GenericXMLString text) => Maybe Encoding -> ByteString -> [(SAXEvent tag text, XMLParseLocation)] | | parseSAXLocationsThrowing :: (GenericXMLString tag, GenericXMLString text) => Maybe Encoding -> ByteString -> [(SAXEvent tag text, XMLParseLocation)] | | parseSAXThrowing :: (GenericXMLString tag, GenericXMLString text) => Maybe Encoding -> ByteString -> [SAXEvent tag text] | | class (Monoid s, Eq s) => GenericXMLString s where | |
|
|
|
XML primitives
|
|
|
Encoding types available for the document encoding.
| Constructors | |
|
|
|
Parse error, consisting of message text and error location
| Constructors | | Instances | |
|
|
|
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 | |
|
|
SAX-style parse
|
|
data ParserOptions tag text | Source |
|
Constructors | ParserOptions | | parserEncoding :: 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
|
|
|
|
|
|
Constructors | StartElement tag [(tag, text)] | | EndElement tag | | CharacterData text | | FailDocument XMLParseError | |
| Instances | |
|
|
|
Converts a CString to a GenericXMLString type.
|
|
|
|
|
|
|
|
|
:: (GenericXMLString tag, GenericXMLString text) | | => ParserOptions tag text | Optional encoding override
| -> ByteString | Input text (a lazy ByteString)
| -> [(SAXEvent tag text, XMLParseLocation)] | | A variant of parseSAX that gives a document location with each SAX event.
In the event of an error, throw XMLParseException.
parseLocationsThrowing 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.
|
|
|
|
:: (GenericXMLString tag, GenericXMLString text) | | => ParserOptions tag text | Parser options
| -> ByteString | input text (a lazy ByteString)
| -> [SAXEvent tag text] | | Lazily parse XML to SAX events. 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.
|
|
|
|
|
Variants that throw exceptions
|
|
|
An exception indicating an XML parse error, used by the ..Throwing variants.
| Constructors | | Instances | |
|
|
Deprecated parse functions
|
|
|
|
|
|
|
|
parseSAXLocationsThrowing | Source |
|
|
|
|
|
|
Abstraction of string types
|
|
|
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.6.1 |