hxt-9.3.1.14: A collection of tools for processing XML with Haskell.

CopyrightCopyright (C) 2011 Uwe Schmidt
LicenseMIT
MaintainerUwe Schmidt (uwe@fh-wedel.de)
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Text.XML.HXT.Arrow.ProcessDocument

Description

Compound arrows for reading, parsing, validating and writing XML documents

All arrows use IO and a global state for options, errorhandling, ...

Synopsis

Documentation

parseXmlDocument :: Bool -> Bool -> Bool -> Bool -> IOStateArrow s XmlTree XmlTree Source

XML parser

Input tree must be a root tree with a text tree as child containing the document to be parsed. The parser generates from the input string a tree of a wellformed XML document, processes the DTD (parameter substitution, conditional DTD parts, ...) and substitutes all general entity references. Next step is character reference substitution. Last step is the document validation. Validation can be controlled by an extra parameter.

Example:

parseXmlDocument True    -- parse and validate document

parseXmlDocument False   -- only parse document, don't validate

This parser is useful for applications processing correct XML documents.

parseHtmlDocument :: IOStateArrow s XmlTree XmlTree Source

HTML parser

Input tree must be a root tree with a text tree as child containing the document to be parsed. The parser tries to parse everything as HTML, if the HTML document is not wellformed XML or if errors occur, warnings are generated. The warnings can be issued, or suppressed.

Example: parseHtmlDocument True : parse document and issue warnings

This parser is useful for applications like web crawlers, where the pages may contain arbitray errors, but the application is only interested in parts of the document, e.g. the plain text.

validateDocument :: IOStateArrow s XmlTree XmlTree Source

Document validation

Input must be a complete document tree. The document is validated with respect to the DTD spec. Only useful for XML documents containing a DTD.

If the document is valid, it is transformed with respect to the DTD, normalization of attribute values, adding default values, sorting attributes by name,...

If no error was found, result is the normalized tree, else the error status is set in the list of attributes of the root node "/" and the document content is removed from the tree.

propagateAndValidateNamespaces :: IOStateArrow s XmlTree XmlTree Source

Namespace propagation

Input must be a complete document tree. The namespace declarations are evaluated and all element and attribute names are processed by splitting the name into prefix, local part and namespace URI.

Naames are checked with respect to the XML namespace definition

If no error was found, result is the unchanged input tree, else the error status is set in the list of attributes of the root node "/" and the document content is removed from the tree.

getDocumentContents :: String -> IOStateArrow s b XmlTree Source

creates a new document root, adds all options as attributes to the document root and calls getXmlContents.

If the document name is the empty string, the document will be read from standard input.

For supported protocols see getXmlContents