Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- module Data.XML.Parser.Low.Entity
- module Data.XML.Parser.Low.Name
- data Reference
- data Content
- expandContent :: Alternative m => EntityDecoder -> Content -> m Text
- expandContents :: Alternative m => Monad m => EntityDecoder -> [Content] -> m Text
- expandReference :: Alternative m => EntityDecoder -> Reference -> m Text
- expandReference' :: Reference -> Maybe Text
- tokenSingleQuote :: CharParsing m => m Char
- tokenDoubleQuote :: CharParsing m => m Char
- tokenQuote :: CharParsing m => m Char
- tokenWhitespace :: CharParsing m => m String
- tokenEqual :: CharParsing m => Monad m => m ()
- tokenReference :: CharParsing m => Monad m => m Reference
- tokenContent :: CharParsing m => Monad m => String -> m Content
- tokenEntityDeclarationOpen :: CharParsing m => m ()
- tokenInstructionOpen :: CharParsing m => Monad m => m Text
- tokenInstructionClose :: CharParsing m => m ()
- tokenCdataOpen :: CharParsing m => m ()
- tokenCdataClose :: CharParsing m => m ()
- tokenCommentOpen :: CharParsing m => m ()
- tokenCommentClose :: CharParsing m => m ()
- tokenDoctypeOpen :: CharParsing m => m ()
- tokenXmlDeclarationOpen :: CharParsing m => m ()
- tokenXmlDeclarationClose :: CharParsing m => m ()
- tokenEmptyElementTagClose :: CharParsing m => m ()
- tokenStartTagOpen :: CharParsing m => Monad m => m QName
- tokenEndTagOpen :: CharParsing m => Monad m => m QName
- tokenElementClose :: CharParsing m => m ()
Documentation
module Data.XML.Parser.Low.Entity
module Data.XML.Parser.Low.Name
Entity reference, or character reference.
Raw text or reference.
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.
tokenSingleQuote :: CharParsing m => m Char Source #
'
tokenDoubleQuote :: CharParsing m => m Char Source #
"
tokenQuote :: CharParsing m => m Char Source #
Single or double quote.
tokenEqual :: CharParsing m => Monad m => m () Source #
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")
tokenContent :: CharParsing m => Monad m => String -> m Content Source #
tokenEntityDeclarationOpen :: CharParsing m => m () Source #
<!ENTITY
tokenInstructionOpen :: CharParsing m => Monad m => m Text Source #
Return processing instruction name.
>>>
parseOnly tokenInstructionOpen "<?php"
Right "php"
tokenInstructionClose :: CharParsing m => m () Source #
?>
tokenCdataOpen :: CharParsing m => m () Source #
tokenCdataClose :: CharParsing m => m () Source #
tokenCommentOpen :: CharParsing m => m () Source #
<!--
tokenCommentClose :: CharParsing m => m () Source #
-->
tokenDoctypeOpen :: CharParsing m => m () Source #
<!DOCTYPE
tokenXmlDeclarationOpen :: CharParsing m => m () Source #
<?xml
tokenXmlDeclarationClose :: CharParsing m => m () Source #
?>
tokenEmptyElementTagClose :: CharParsing m => m () Source #
/>
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"})
tokenElementClose :: CharParsing m => m () Source #
>