HaXml-1.20.1: Utilities for manipulating XML documentsSource codeContentsIndex
Text.XML.HaXml.Parse
Contents
Parse a whole document
Parse just a DTD
Parse a partial document
Individual parsers for use with xmlParseWith and module SAX
These general utility functions don't belong here
Description
A non-validating XML parser. For the input grammar, see http://www.w3.org/TR/REC-xml.
Synopsis
xmlParse :: String -> String -> Document Posn
xmlParse' :: String -> String -> Either String (Document Posn)
dtdParse :: String -> String -> Maybe DocTypeDecl
dtdParse' :: String -> String -> Either String (Maybe DocTypeDecl)
xmlParseWith :: XParser a -> [(Posn, TokenT)] -> (Either String a, [(Posn, TokenT)])
document :: XParser (Document Posn)
element :: XParser (Element Posn)
content :: XParser (Content Posn)
comment :: XParser Comment
cdsect :: XParser CDSect
chardata :: XParser CharData
reference :: XParser Reference
doctypedecl :: XParser DocTypeDecl
processinginstruction :: XParser ProcessingInstruction
elemtag :: XParser ElemTag
name :: XParser Name
tok :: TokenT -> XParser TokenT
elemOpenTag :: XParser ElemTag
elemCloseTag :: Name -> XParser ()
emptySTs :: SymTabs
type XParser a = Parser SymTabs (Posn, TokenT) a
fst3 :: (a, b, c) -> a
snd3 :: (a, b, c) -> b
thd3 :: (a, b, c) -> c
Parse a whole document
xmlParse :: String -> String -> Document PosnSource
To parse a whole document, xmlParse file content takes a filename (for generating error reports) and the string content of that file. A parse error causes program failure, with message to stderr.
xmlParse' :: String -> String -> Either String (Document Posn)Source
To parse a whole document, xmlParse' file content takes a filename (for generating error reports) and the string content of that file. Any parse error message is passed back to the caller through the Either type.
Parse just a DTD
dtdParse :: String -> String -> Maybe DocTypeDeclSource
To parse just a DTD, dtdParse file content takes a filename (for generating error reports) and the string content of that file. If no DTD was found, you get Nothing rather than an error. However, if a DTD is found but contains errors, the program crashes.
dtdParse' :: String -> String -> Either String (Maybe DocTypeDecl)Source
To parse just a DTD, dtdParse' file content takes a filename (for generating error reports) and the string content of that file. If no DTD was found, you get Right Nothing. If a DTD was found but contains errors, you get a Left message.
Parse a partial document
xmlParseWith :: XParser a -> [(Posn, TokenT)] -> (Either String a, [(Posn, TokenT)])Source
To parse a partial document, e.g. from an XML-based stream protocol, where you may later want to get more document elements from the same stream. Arguments are: a parser for the item you want, and the already-lexed input to parse from. Returns the item you wanted (or an error message), plus the remainder of the input.
Individual parsers for use with xmlParseWith and module SAX
document :: XParser (Document Posn)Source
Return an entire XML document including prolog and trailing junk.
element :: XParser (Element Posn)Source
Return a complete element including all its inner content.
content :: XParser (Content Posn)Source
Return a content particle, e.g. text, element, reference, etc
comment :: XParser CommentSource
Return an XML comment.
cdsect :: XParser CDSectSource
chardata :: XParser CharDataSource
Return parsed freetext (i.e. until the next markup)
reference :: XParser ReferenceSource
Return either a general entity reference, or a character reference.
doctypedecl :: XParser DocTypeDeclSource
Return a DOCTYPE decl, indicating a DTD.
processinginstruction :: XParser ProcessingInstructionSource
Parse a processing instruction.
elemtag :: XParser ElemTagSource
Parse only the parts between angle brackets in an element tag.
name :: XParser NameSource
Return just a name, e.g. element name, attribute name.
tok :: TokenT -> XParser TokenTSource
Return the next token from the input only if it matches the given token.
elemOpenTag :: XParser ElemTagSource
For use with stream parsers - returns the complete opening element tag.
elemCloseTag :: Name -> XParser ()Source
For use with stream parsers - accepts a closing tag, provided it matches the given element name.
emptySTs :: SymTabsSource
Some empty symbol tables for GE and PE references.
type XParser a = Parser SymTabs (Posn, TokenT) aSource
XParser is just a specialisation of the PolyState parser.
These general utility functions don't belong here
fst3 :: (a, b, c) -> aSource
snd3 :: (a, b, c) -> bSource
thd3 :: (a, b, c) -> cSource
Produced by Haddock version 2.6.0