|
Text.XML.Expat.Internal.IO |
|
|
|
|
Description |
Low-level interface to Expat. Unless speed is paramount, this should
normally be avoided in favour of the interfaces provided by
Text.XML.Expat.SAX and Text.XML.Expat.Tree, etc. Basic usage is:
- Make a new parser: newParser.
- Set up callbacks on the parser: setStartElementHandler, etc.
- Feed data into the parser: parse, parse' or parseChunk. Some of
these functions must be wrapped in withParser.
|
|
Synopsis |
|
|
|
|
Parser Setup
|
|
data Parser |
Instances | |
|
|
newParser :: Maybe Encoding -> IO Parser |
Create a Parser.
|
|
Parsing
|
|
parse :: Parser -> ByteString -> IO (Maybe XMLParseError) |
parse data feeds lazy ByteString data into a Parser. It returns
Nothing on success, or Just the parse error.
|
|
parse' :: Parser -> ByteString -> IO (Maybe XMLParseError) |
parse data feeds strict ByteString data into a Parser. It returns
Nothing on success, or Just the parse error.
|
|
withParser |
:: Parser | | -> (ParserPtr -> IO a) | Computation where parseChunk and other low-level functions may be used
| -> IO a | | Most of the low-level functions take a ParserPtr so are required to be
called inside withParser.
|
|
|
type ParserPtr = Ptr Parser_struct |
|
data Parser_struct |
|
|
parseChunk :: ParserPtr -> ByteString -> Bool -> IO (Maybe XMLParseError) |
parseChunk data False feeds strict ByteString data into a
Parser. The end of the data is indicated by passing True for the
final parameter. It returns Nothing on success, or Just the parse error.
|
|
data Encoding |
Encoding types available for the document encoding.
| Constructors | |
|
|
data XMLParseError |
Parse error, consisting of message text and error location
| Constructors | | Instances | |
|
|
getParseLocation :: ParserPtr -> IO XMLParseLocation |
|
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 | |
|
|
Parser Callbacks
|
|
type XMLDeclarationHandler = ParserPtr -> CString -> CString -> CInt -> IO Bool |
The type of the "XML declaration" callback. Parameters are version,
encoding (which can be nullPtr), and standalone declaration, where -1 = no
declaration, 0 = no and 1 = yes. Return True to continue parsing as
normal, or False to terminate the parse.
|
|
type StartElementHandler = ParserPtr -> CString -> [(CString, CString)] -> IO Bool |
The type of the "element started" callback. The first parameter is the
element name; the second are the (attribute, value) pairs. Return True to
continue parsing as normal, or False to terminate the parse.
|
|
type EndElementHandler = ParserPtr -> CString -> IO Bool |
The type of the "element ended" callback. The parameter is the element
name. Return True to continue parsing as normal, or False to terminate the
parse.
|
|
type CharacterDataHandler = ParserPtr -> CStringLen -> IO Bool |
The type of the "character data" callback. The parameter is the
character data processed. This callback may be called more than once while
processing a single conceptual block of text. Return True to continue
parsing as normal, or False to terminate the parse.
|
|
type ExternalEntityRefHandler = Parser -> CString -> CString -> CString -> CString -> IO Bool |
The type of the "external entity reference" callback. See the expat
documentation.
|
|
type SkippedEntityHandler = ParserPtr -> CString -> Int -> IO Bool |
Set a skipped entity handler. This is called in two situations:
1. An entity reference is encountered for which no declaration has been read
and this is not an error.
2. An internal entity reference is read, but not expanded, because
XML_SetDefaultHandler has been called.
|
|
type StartCDataHandler = ParserPtr -> IO Bool |
The type of the "start cdata" callback. Return True to continue
parsing as normal, or False to terminate the parse.
|
|
type EndCDataHandler = ParserPtr -> IO Bool |
The type of the "end cdata" callback. Return True to continue
parsing as normal, or False to terminate the parse.
|
|
type CommentHandler = ParserPtr -> CString -> IO Bool |
The type of the "comment" callback. The parameter is the comment text.
Return True to continue parsing as normal, or False to terminate the parse.
|
|
type ProcessingInstructionHandler = ParserPtr -> CString -> CString -> IO Bool |
The type of the "processing instruction" callback. The first parameter
is the first word in the processing instruction. The second parameter is
the rest of the characters in the processing instruction after skipping all
whitespace after the initial word. Return True to continue parsing as normal,
or False to terminate the parse.
|
|
setXMLDeclarationHandler :: Parser -> XMLDeclarationHandler -> IO () |
Attach a XMLDeclarationHandler to a Parser.
|
|
setStartElementHandler :: Parser -> StartElementHandler -> IO () |
Attach a StartElementHandler to a Parser.
|
|
setEndElementHandler :: Parser -> EndElementHandler -> IO () |
Attach an EndElementHandler to a Parser.
|
|
setCharacterDataHandler :: Parser -> CharacterDataHandler -> IO () |
Attach an CharacterDataHandler to a Parser.
|
|
setStartCDataHandler :: Parser -> StartCDataHandler -> IO () |
Attach a StartCDataHandler to a Parser.
|
|
setEndCDataHandler :: Parser -> EndCDataHandler -> IO () |
Attach a EndCDataHandler to a Parser.
|
|
setProcessingInstructionHandler :: Parser -> ProcessingInstructionHandler -> IO () |
Attach a ProcessingInstructionHandler to a Parser.
|
|
setCommentHandler :: Parser -> CommentHandler -> IO () |
Attach a CommentHandler to a Parser.
|
|
setExternalEntityRefHandler :: Parser -> ExternalEntityRefHandler -> IO () |
|
setSkippedEntityHandler :: Parser -> SkippedEntityHandler -> IO () |
|
setUseForeignDTD :: Parser -> Bool -> IO () |
|
Lower-level interface
|
|
parseExternalEntityReference |
|
|
data ExpatHandlers |
|
Helpers
|
|
encodingToString :: Encoding -> String |
|
Produced by Haddock version 2.7.2 |