hexpat-0.20.13: XML parser/formatter based on expat
Safe HaskellNone
LanguageHaskell98

Text.XML.Expat.SAX

Description

This module provides functions to parse an XML document to a lazy stream of SAX events.

Synopsis

XML primitives

data Encoding Source #

Constructors

ASCII 
UTF8 
UTF16 
ISO88591 

data XMLParseError Source #

Parse error, consisting of message text and error location

Constructors

XMLParseError String XMLParseLocation 

Instances

Instances details
NFData XMLParseError Source # 
Instance details

Defined in Text.XML.Expat.Internal.IO

Methods

rnf :: XMLParseError -> ()

Show XMLParseError Source # 
Instance details

Defined in Text.XML.Expat.Internal.IO

Methods

showsPrec :: Int -> XMLParseError -> ShowS

show :: XMLParseError -> String

showList :: [XMLParseError] -> ShowS

Eq XMLParseError Source # 
Instance details

Defined in Text.XML.Expat.Internal.IO

data XMLParseLocation Source #

Specifies a location of an event within the input text

Constructors

XMLParseLocation 

Fields

Instances

Instances details
NFData XMLParseLocation Source # 
Instance details

Defined in Text.XML.Expat.Internal.IO

Methods

rnf :: XMLParseLocation -> ()

Show XMLParseLocation Source # 
Instance details

Defined in Text.XML.Expat.Internal.IO

Methods

showsPrec :: Int -> XMLParseLocation -> ShowS

show :: XMLParseLocation -> String

showList :: [XMLParseLocation] -> ShowS

Eq XMLParseLocation Source # 
Instance details

Defined in Text.XML.Expat.Internal.IO

SAX-style parse

data ParseOptions tag text Source #

Constructors

ParseOptions 

Fields

  • 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

data SAXEvent tag text Source #

Constructors

XMLDeclaration text (Maybe text) (Maybe Bool) 
StartElement tag [(tag, text)] 
EndElement tag 
CharacterData text 
StartCData 
EndCData 
ProcessingInstruction text text 
Comment text 
FailDocument XMLParseError 

Instances

Instances details
(NFData tag, NFData text) => NFData (SAXEvent tag text) Source # 
Instance details

Defined in Text.XML.Expat.SAX

Methods

rnf :: SAXEvent tag text -> ()

(Show tag, Show text) => Show (SAXEvent tag text) Source # 
Instance details

Defined in Text.XML.Expat.SAX

Methods

showsPrec :: Int -> SAXEvent tag text -> ShowS

show :: SAXEvent tag text -> String

showList :: [SAXEvent tag text] -> ShowS

(Eq tag, Eq text) => Eq (SAXEvent tag text) Source # 
Instance details

Defined in Text.XML.Expat.SAX

Methods

(==) :: SAXEvent tag text -> SAXEvent tag text -> Bool

(/=) :: SAXEvent tag text -> SAXEvent tag text -> Bool

parse Source #

Arguments

:: (GenericXMLString tag, GenericXMLString text) 
=> ParseOptions tag text

Parse options

-> ByteString

Input text (a lazy ByteString)

-> [SAXEvent tag text] 

Lazily parse XML to SAX events. In the event of an error, FailDocument is the last element of the output list.

parseG Source #

Arguments

:: (GenericXMLString tag, GenericXMLString text, List l) 
=> ParseOptions tag text

Parse options

-> l ByteString

Input text (a lazy ByteString)

-> l (SAXEvent tag text) 

Parse a generalized list of ByteStrings containing XML to SAX events. In the event of an error, FailDocument is the last element of the output list.

parseLocations Source #

Arguments

:: (GenericXMLString tag, GenericXMLString text) 
=> ParseOptions tag text

Parse options

-> ByteString

Input text (a lazy ByteString)

-> [(SAXEvent tag text, XMLParseLocation)] 

A variant of parseSAX that gives a document location with each SAX event.

parseLocationsG Source #

Arguments

:: (GenericXMLString tag, GenericXMLString text, List l) 
=> ParseOptions tag text

Parse options

-> l ByteString

Input text (a lazy ByteString)

-> l (SAXEvent tag text, XMLParseLocation) 

Parse a generalized list of ByteStrings containing XML to SAX events. In the event of an error, FailDocument is the last element of the output list.

parseLocationsThrowing Source #

Arguments

:: (GenericXMLString tag, GenericXMLString text) 
=> ParseOptions 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.

parseThrowing Source #

Arguments

:: (GenericXMLString tag, GenericXMLString text) 
=> ParseOptions tag text

Parse 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

data XMLParseException Source #

An exception indicating an XML parse error, used by the ..Throwing variants.

Instances

Instances details
Exception XMLParseException Source # 
Instance details

Defined in Text.XML.Expat.SAX

Show XMLParseException Source # 
Instance details

Defined in Text.XML.Expat.SAX

Methods

showsPrec :: Int -> XMLParseException -> ShowS

show :: XMLParseException -> String

showList :: [XMLParseException] -> ShowS

Eq XMLParseException Source # 
Instance details

Defined in Text.XML.Expat.SAX

Abstraction of string types

class (Monoid s, Eq s) => GenericXMLString s where Source #

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

gxNullString :: s -> Bool Source #

gxToString :: s -> String Source #

gxFromString :: String -> s Source #

gxFromChar :: Char -> s Source #

gxHead :: s -> Char Source #

gxTail :: s -> s Source #

gxBreakOn :: Char -> s -> (s, s) Source #

gxFromByteString :: ByteString -> s Source #

gxToByteString :: s -> ByteString Source #

Instances

Instances details
GenericXMLString ByteString Source # 
Instance details

Defined in Text.XML.Expat.SAX

GenericXMLString Text Source # 
Instance details

Defined in Text.XML.Expat.SAX

Methods

gxNullString :: Text -> Bool Source #

gxToString :: Text -> String Source #

gxFromString :: String -> Text Source #

gxFromChar :: Char -> Text Source #

gxHead :: Text -> Char Source #

gxTail :: Text -> Text Source #

gxBreakOn :: Char -> Text -> (Text, Text) Source #

gxFromByteString :: ByteString -> Text Source #

gxToByteString :: Text -> ByteString Source #

GenericXMLString String Source # 
Instance details

Defined in Text.XML.Expat.SAX

Methods

gxNullString :: String -> Bool Source #

gxToString :: String -> String Source #

gxFromString :: String -> String Source #

gxFromChar :: Char -> String Source #

gxHead :: String -> Char Source #

gxTail :: String -> String Source #

gxBreakOn :: Char -> String -> (String, String) Source #

gxFromByteString :: ByteString -> String Source #

gxToByteString :: String -> ByteString Source #