libxml-sax-0.7.6: Bindings for the libXML2 SAX interface
Copyright2010 John Millikin
LicenseMIT
Maintainerjmillikin@gmail.com
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.XML.LibXML.SAX

Description

Bindings for the libXML2 SAX interface

Synopsis

Parser

data Parser m Source #

A Parser tracks the internal state of a LibXML parser context.

As LibXML is a very stateful library, parsers must operate within either the IO or ST monad. Use newParserIO or newParserST to create parsers in the appropriate monad.

In general, clients should prefer newParserST, because ST values can be safely computed with no side effects.

newParserIO Source #

Arguments

:: Maybe Text

An optional filename or URI

-> IO (Parser IO) 

newParserST Source #

Arguments

:: Maybe Text

An optional filename or URI

-> ST s (Parser (ST s)) 

Parser input

parseComplete :: Parser m -> m () Source #

Finish parsing any buffered data, and check that the document was closed correctly.

Callbacks

data Callback m a Source #

setCallback :: Parser m -> Callback m a -> a -> m () Source #

Set a callback computation to run when a particular parse event occurs. The callback should return True to continue parsing, or False to abort.

Alternatively, callbacks may throw an Exception to abort parsing. The exception will be propagated through to the caller of parseBytes or parseComplete.

clearCallback :: Parser m -> Callback m a -> m () Source #

Remove a callback from the parser. This might also change the parser's behavior, such as automatically expanding entity references when no parsedReference callback is set.

Parse events

parsedReference :: Callback m (Text -> m Bool) Source #

If parsedReference is set, entity references in element and attribute content will reported separately from text, and will not be automatically expanded.

Use this when processing documents in passthrough mode, to preserve existing entity references.

parsedCDATA :: Callback m (Text -> m Bool) Source #

If parsedCDATA is set, it receives any text contained in CDATA blocks. By default, all text is received by parsedCharacters.

parsedWhitespace :: Callback m (Text -> m Bool) Source #

If parsedWhitespace is set, it receives any whitespace marked as ignorable by the document's DTD. By default, all text is received by parsedCharacters.

Warning and error reporting