xeno-0.6: A fast event-based XML parser in pure Haskell
Safe HaskellNone
LanguageHaskell2010

Xeno.SAX

Description

SAX parser and API for XML.

Synopsis

Documentation

process :: (Monad m, StringLike str) => Process (m ()) -> str -> m () Source #

Process events with callbacks in the XML input.

data Process a Source #

Parameters to the process function

Constructors

Process 

Fields

  • openF :: !(ByteString -> a)

    Open tag.

  • attrF :: !(ByteString -> ByteString -> a)

    Tag attribute.

  • endOpenF :: !(ByteString -> a)

    End open tag.

  • textF :: !(ByteString -> a)

    Text.

  • closeF :: !(ByteString -> a)

    Close tag.

  • cdataF :: !(ByteString -> a)

    CDATA.

class StringLike str where Source #

Methods

s_index' :: str -> Int -> Word8 Source #

elemIndexFrom' :: Word8 -> str -> Int -> Maybe Int Source #

drop' :: Int -> str -> str Source #

substring' :: str -> Int -> Int -> ByteString Source #

toBS :: str -> ByteString Source #

Instances

Instances details
StringLike ByteString Source # 
Instance details

Defined in Xeno.SAX

Methods

s_index' :: ByteString -> Int -> Word8 Source #

elemIndexFrom' :: Word8 -> ByteString -> Int -> Maybe Int Source #

drop' :: Int -> ByteString -> ByteString Source #

substring' :: ByteString -> Int -> Int -> ByteString Source #

toBS :: ByteString -> ByteString Source #

StringLike ByteStringZeroTerminated Source # 
Instance details

Defined in Xeno.SAX

fold Source #

Arguments

:: (s -> ByteString -> s)

Open tag.

-> (s -> ByteString -> ByteString -> s)

Attribute key/value.

-> (s -> ByteString -> s)

End of open tag.

-> (s -> ByteString -> s)

Text.

-> (s -> ByteString -> s)

Close tag.

-> (s -> ByteString -> s)

CDATA.

-> s 
-> ByteString 
-> Either XenoException s 

Fold over the XML input.

validate :: StringLike str => str -> Bool Source #

Parse the XML but return no result, process no events.

N.B.: Only the lexical correctness of the input string is checked, not its XML semantics (e.g. only if tags are well formed, not whether tags are properly closed)

> :set -XOverloadedStrings
> validate "<b>"
True
> validate "<b"
False

validateEx :: StringLike str => str -> Bool Source #

Parse the XML and checks tags nesting.

dump :: ByteString -> IO () Source #

Parse the XML and pretty print it to stdout.

skipDoctype :: ByteString -> ByteString Source #

Skip initial DOCTYPE declaration