| hxt-8.5.4: A collection of tools for processing XML with Haskell. | Source code | Contents | Index

Text.XML.HXT.Arrow.ProcessDocument

Portability | portable
Stability | experimental
Maintainer | Uwe Schmidt (uwe@fh-wedel.de)

Description
Version : $Id: ProcessDocument.hs,v 1.3 20060830 16:20:52 hxml Exp $ Compound arrows for reading, parsing, validating and writing XML documents All arrows use IO and a global state for options, errorhandling, ...
Synopsis

parseXmlDocument :: Bool -> IOStateArrow s XmlTree XmlTree
parseHtmlDocument :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> IOStateArrow s XmlTree XmlTree
validateDocument :: IOStateArrow s XmlTree XmlTree
propagateAndValidateNamespaces :: IOStateArrow s XmlTree XmlTree
getDocumentContents :: Attributes -> String -> IOStateArrow s b XmlTree

Documentation

parseXmlDocument :: 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 :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> 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 :: Attributes -> 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`
Produced by Haddock version 2.4.2