fadno-xml-1.1.1: XML/XSD combinators/schemas/codegen

Safe HaskellSafe
LanguageHaskell2010

Fadno.Xml.XParser

Contents

Description

Deprecated: in favor of XParse

Backtracking combinators for consuming XML productions (elements, attributes).

Synopsis

XParser monad

type XParser m = (Alternative m, MonadState [Element] m, MonadError String m) Source #

Stack entry tracking identified elements.

XParser constraint kind. Stack state + alternative + errors.

parseX :: Monad m => StateT [Element] (ExceptT String m) b -> Element -> m (Either String b) Source #

run XParser on an element.

Stack manipulation

peek :: XParser m => m Element Source #

Stack peek.

push :: XParser m => Element -> m () Source #

Stack push.

pop :: XParser m => m () Source #

Stack pop.

checkStack :: XParser m => m [Element] Source #

Verify populated stack.

Element operations

atEl :: XParser m => QName -> m () Source #

Verify and "consume" current element.

findChild :: XParser m => QName -> m a -> m a Source #

Find child element and act on it.

findChildren :: XParser m => QName -> m a -> m [a] Source #

Find zero or many children and act on them.

anyChildren :: XParser m => m a -> m [a] Source #

Run optional action on all children.

oneChild :: XParser m => m a -> m a Source #

Expect to find one child only, and run action on it.

allChildren :: XParser m => m a -> m [a] Source #

Act on all children.

manyOrdered :: XParser m => m a -> m [a] Source #

Flailing attempt to restore "order" by faking a single-child element one at a time.

Attribute/Text operations

attr :: XParser m => QName -> m String Source #

Expect/consume a particular attribute.

textContent :: XParser m => m String Source #

Get text content, returning empty string if none, per strContent.

QNames

name :: String -> QName Source #

Local-only QName.

xsName :: String -> QName Source #

Special support for XSD QNames.

Utility

readXml :: FilePath -> IO Element Source #

Convenience to read in top element from file.