-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Streaming XML parser based on conduits.
--   
--   This library provides an alternative, hopefully higher-level
--   implementation for the parsing part of <tt>xml-conduit</tt>.
@package xml-conduit-parse
@version 0.3.1.1


-- | Low-level primitives.
module Data.Conduit.Parser.XML.Internal
type AttributeMap = Map Name [Content]

-- | Parse an <a>EventBeginDocument</a>.
beginDocument :: (MonadCatch m) => ConduitParser Event m ()

-- | Parse an <a>EventEndDocument</a>.
endDocument :: (MonadCatch m) => ConduitParser Event m ()

-- | Parse an <a>EventBeginDoctype</a>.
beginDoctype :: (MonadCatch m) => ConduitParser Event m (Text, Maybe ExternalID)

-- | Parse an <a>EventEndDoctype</a>.
endDoctype :: (MonadCatch m) => ConduitParser Event m ()

-- | Parse an <a>EventInstruction</a>.
instruction :: (MonadCatch m) => ConduitParser Event m Instruction

-- | Parse an <a>EventBeginElement</a>.
beginElement :: (MonadCatch m) => ConduitParser Event m (Name, AttributeMap)

-- | Parse an <a>EventEndElement</a>.
endElement :: (MonadCatch m) => ConduitParser Event m Name

-- | Parse a <a>ContentEntity</a> (within an <a>EventContent</a>).
contentEntity :: (MonadCatch m) => ConduitParser Event m Text

-- | Parse a <a>ContentText</a> (within an <a>EventContent</a>).
contentText :: (MonadCatch m) => ConduitParser Event m Text

-- | Parse an <a>EventComment</a>.
comment :: (MonadCatch m) => ConduitParser Event m Text

-- | Parse an <a>EventCDATA</a>.
cdata :: (MonadCatch m) => ConduitParser Event m Text

-- | Parse a textual <a>EventContent</a> or an <a>EventCDATA</a>.
text :: (MonadCatch m) => ConduitParser Event m Text


-- | High-level primitives to parse a stream of XML <a>Event</a>s.
module Data.Conduit.Parser.XML

-- | Parse an XML tag, depending on its name and attributes. This is the
--   most generic tag parser.
--   
--   Comments, instructions and whitespace are ignored.
tag :: MonadCatch m => (Name -> Maybe a) -> (a -> AttrParser b) -> (b -> ConduitParser Event m c) -> ConduitParser Event m c

-- | Like <a>tag</a>, but match a single tag name.
tagName :: MonadCatch m => Name -> AttrParser a -> (a -> ConduitParser Event m b) -> ConduitParser Event m b

-- | Like <a>tag</a>, but use a predicate to select tag names.
tagPredicate :: MonadCatch m => (Name -> Bool) -> AttrParser a -> (a -> ConduitParser Event m b) -> ConduitParser Event m b

-- | Like <a>tagName</a>, but expect no attributes at all.
tagNoAttr :: MonadCatch m => Name -> ConduitParser Event m a -> ConduitParser Event m a

-- | Like <a>tagName</a>, but ignore all attributes.
tagIgnoreAttrs :: MonadCatch m => Name -> ConduitParser Event m a -> ConduitParser Event m a

-- | Parse an XML tag, whatever its name and attributes.
--   
--   Comments, instructions and whitespace are ignored.
anyTag :: MonadCatch m => (Name -> [(Name, [Content])] -> ConduitParser Event m a) -> ConduitParser Event m a
type AttributeMap = Map Name [Content]
data AttrParser a

-- | Parse a single attribute using a specific name and a custom parsing
--   function for its value.
attr :: Name -> (Text -> Maybe a) -> AttrParser a

-- | Parse a single textual attribute.
textAttr :: Name -> AttrParser Text

-- | Parse a single attribute, whatever its name or value.
anyAttr :: AttrParser (Name, [Content])

-- | Consume all remaining unparsed attributes.
ignoreAttrs :: AttrParser ()

-- | Parse a tag content using a custom parsing function.
content :: MonadCatch m => (Text -> Maybe a) -> ConduitParser Event m a

-- | Parse a tag content as <a>Text</a>.
--   
--   This parser fails if the tag is empty. To get <a>mempty</a> instead of
--   failing, use <tt>textContent &lt;|&gt; mempty</tt>.
textContent :: MonadCatch m => ConduitParser Event m Text

-- | Parses a byte stream into <a>Event</a>s. This function is implemented
--   fully in Haskell using attoparsec-text for parsing. The produced error
--   messages do not give line/column information, so you may prefer to
--   stick with the parser provided by libxml-enumerator. However, this has
--   the advantage of not relying on any C libraries.
--   
--   This relies on <a>detectUtf</a> to determine character encoding, and
--   <a>parseText'</a> to do the actual parsing.
parseBytes :: MonadThrow m => ParseSettings -> Conduit ByteString m Event
parseBytesPos :: MonadThrow m => ParseSettings -> Conduit ByteString m EventPos

-- | Alias for <a>parseText'</a>
parseText :: (MonadThrow m) => ParseSettings -> Conduit Text m Event

-- | Same as <a>parseText'</a>, but includes the position of each event.
--   
--   Since 1.2.4
parseTextPos :: MonadThrow m => ParseSettings -> Conduit Text m EventPos

-- | Automatically determine which UTF variant is being used. This function
--   first checks for BOMs, removing them as necessary, and then check for
--   the equivalent of &lt;?xml for each of UTF-8, UTF-16LE<i>BE, and
--   UTF-32LE</i>BE. It defaults to assuming UTF-8.
detectUtf :: MonadThrow m => Conduit ByteString m Text

-- | A helper function which reads a file from disk using
--   <tt>enumFile</tt>, detects character encoding using <a>detectUtf</a>,
--   parses the XML using <a>parseBytes</a>, and then hands off control to
--   your supplied parser.
parseFile :: MonadResource m => ParseSettings -> FilePath -> Producer m Event

-- | Parse an event stream from a lazy <a>ByteString</a>.
parseLBS :: MonadThrow m => ParseSettings -> ByteString -> Producer m Event
data ParseSettings :: *
type DecodeEntities = Text -> Content
psDecodeEntities :: ParseSettings -> DecodeEntities

-- | Whether the original xmlns attributes should be retained in the parsed
--   values. For more information on motivation, see:
--   
--   <a>https://github.com/snoyberg/xml/issues/38</a>
--   
--   Default: False
--   
--   Since 1.2.1
psRetainNamespaces :: ParseSettings -> Bool

-- | Default implementation of <a>DecodeEntities</a>: handles numeric
--   entities and the five standard character entities (lt, gt, amp, quot,
--   apos).
decodeXmlEntities :: DecodeEntities

-- | HTML4-compliant entity decoder. Handles numerics, the five standard
--   character entities, and the additional 248 entities defined by HTML 4
--   and XHTML 1.
--   
--   Note that HTML 5 introduces a drastically larger number of entities,
--   and this code does not recognize most of them.
decodeHtmlEntities :: DecodeEntities
data XmlException :: *
XmlException :: String -> Maybe Event -> XmlException
[xmlErrorMessage] :: XmlException -> String
[xmlBadInput] :: XmlException -> Maybe Event
InvalidEndElement :: Name -> Maybe Event -> XmlException
InvalidEntity :: String -> Maybe Event -> XmlException
MissingAttribute :: String -> XmlException
UnparsedAttributes :: [(Name, [Content])] -> XmlException
instance GHC.Base.Monad Data.Conduit.Parser.XML.AttrParser
instance GHC.Base.Functor Data.Conduit.Parser.XML.AttrParser
instance GHC.Base.Applicative Data.Conduit.Parser.XML.AttrParser
instance GHC.Base.Alternative Data.Conduit.Parser.XML.AttrParser
instance Control.Monad.Catch.MonadThrow Data.Conduit.Parser.XML.AttrParser
