hextream-0.1.0.0: Streaming-friendly XML parsers

Safe HaskellNone
LanguageHaskell2010

Data.XML.Parser.Low

Description

Low-level XML parsers:

  • parsed tokens are small and may overlap; it is not possible to tokenize XML document in a stateless way
  • parsers are reversible: all formatting details are retained (e.g. whitespacing)

All documentation examples assume the following setup:

:set -XOverloadedStrings
import Data.Attoparsec.ByteString
Synopsis

Documentation

data Reference Source #

Entity reference, or character reference.

Constructors

EntityRef Text 
CharRef Char 

data Content Source #

Raw text or reference.

Instances
Eq Content Source # 
Instance details

Defined in Data.XML.Parser.Low

Methods

(==) :: Content -> Content -> Bool #

(/=) :: Content -> Content -> Bool #

Ord Content Source # 
Instance details

Defined in Data.XML.Parser.Low

Read Content Source # 
Instance details

Defined in Data.XML.Parser.Low

Show Content Source # 
Instance details

Defined in Data.XML.Parser.Low

expandContent :: Alternative m => EntityDecoder -> Content -> m Text Source #

Expand content reference, if any.

expandContents :: Alternative m => Monad m => EntityDecoder -> [Content] -> m Text Source #

Same as expandContent, but on a list. Provided for convenience.

expandReference :: Alternative m => EntityDecoder -> Reference -> m Text Source #

Resolve reference into raw text.

expandReference' :: Reference -> Maybe Text Source #

Same as expandReference decodePredefinedEntities, provided for convenience.

tokenQuote :: CharParsing m => m Char Source #

Single or double quote.

tokenReference :: CharParsing m => Monad m => m Reference Source #

https://www.w3.org/TR/REC-xml/#NT-Reference

>>> parseOnly tokenReference "<"
Right (CharRef '<')
>>> parseOnly tokenReference "&docdate;"
Right (EntityRef "docdate")

tokenInstructionOpen :: CharParsing m => Monad m => m Text Source #

Return processing instruction name.

>>> parseOnly tokenInstructionOpen "<?php"
Right "php"

tokenDoctypeOpen :: CharParsing m => m () Source #

<!DOCTYPE

tokenStartTagOpen :: CharParsing m => Monad m => m QName Source #

Return tag name.

>>> parseOnly tokenStartTagOpen "<foo"
Right (QName {namePrefix = "", nameLocal = "foo"})

tokenEndTagOpen :: CharParsing m => Monad m => m QName Source #

Return tag name.

>>> parseOnly tokenEndTagOpen "</foo"
Right (QName {namePrefix = "", nameLocal = "foo"})