Text.XML.HXT.Arrow.Edit

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

Copyright | Copyright (C) 2011 Uwe Schmidt
License | MIT
Maintainer | Uwe Schmidt (uwe@fh-wedel.de)
Stability | stable
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.XML.HXT.Arrow.Edit

Description

common edit arrows

Synopsis

- canonicalizeAllNodes :: ArrowList a => a XmlTree XmlTree
- canonicalizeForXPath :: ArrowList a => a XmlTree XmlTree
- canonicalizeContents :: ArrowList a => a XmlTree XmlTree
- collapseAllXText :: ArrowList a => a XmlTree XmlTree
- collapseXText :: ArrowList a => a XmlTree XmlTree
- xshowEscapeXml :: ArrowXml a => a n XmlTree -> a n String
- escapeXmlRefs :: (Char -> String -> String, Char -> String -> String)
- escapeHtmlRefs :: (Char -> String -> String, Char -> String -> String)
- haskellRepOfXmlDoc :: ArrowList a => a XmlTree XmlTree
- treeRepOfXmlDoc :: ArrowList a => a XmlTree XmlTree
- addHeadlineToXmlDoc :: ArrowXml a => a XmlTree XmlTree
- indentDoc :: ArrowXml a => a XmlTree XmlTree
- numberLinesInXmlDoc :: ArrowList a => a XmlTree XmlTree
- preventEmptyElements :: ArrowList a => [String] -> Bool -> a XmlTree XmlTree
- removeComment :: ArrowXml a => a XmlTree XmlTree
- removeAllComment :: ArrowXml a => a XmlTree XmlTree
- removeWhiteSpace :: ArrowXml a => a XmlTree XmlTree
- removeAllWhiteSpace :: ArrowXml a => a XmlTree XmlTree
- removeDocWhiteSpace :: ArrowXml a => a XmlTree XmlTree
- transfCdata :: ArrowXml a => a XmlTree XmlTree
- transfAllCdata :: ArrowXml a => a XmlTree XmlTree
- transfCharRef :: ArrowXml a => a XmlTree XmlTree
- transfAllCharRef :: ArrowXml a => a XmlTree XmlTree
- substAllXHTMLEntityRefs :: ArrowXml a => a XmlTree XmlTree
- substXHTMLEntityRef :: LA XmlTree XmlTree
- rememberDTDAttrl :: ArrowList a => a XmlTree XmlTree
- addDefaultDTDecl :: ArrowList a => a XmlTree XmlTree
- hasXmlPi :: ArrowXml a => a XmlTree XmlTree
- addXmlPi :: ArrowXml a => a XmlTree XmlTree
- addXmlPiEncoding :: ArrowXml a => String -> a XmlTree XmlTree
- addDoctypeDecl :: ArrowXml a => String -> String -> String -> a XmlTree XmlTree
- addXHtmlDoctypeStrict :: ArrowXml a => a XmlTree XmlTree
- addXHtmlDoctypeTransitional :: ArrowXml a => a XmlTree XmlTree
- addXHtmlDoctypeFrameset :: ArrowXml a => a XmlTree XmlTree

# Documentation

canonicalizeAllNodes :: ArrowList a => a XmlTree XmlTree #

Applies some "Canonical XML" rules to a document tree.

The rule differ slightly for canonical XML and XPath in handling of comments

Note: This is not the whole canonicalization as it is specified by the W3C Recommendation. Adding attribute defaults or sorting attributes in lexicographic order is done by the `transform` function of module `Text.XML.HXT.Validator.Validation`. Replacing entities or line feed normalization is done by the parser.

Rules: remove DTD parts, processing instructions, comments and substitute char refs in attribute values and text

Not implemented yet:

- Whitespace within start and end tags is normalized
- Special characters in attribute values and character content are replaced by character references

canonicalizeForXPath :: ArrowList a => a XmlTree XmlTree #

Canonicalize a tree for XPath Like `canonicalizeAllNodes` but comment nodes are not removed

see `canonicalizeAllNodes`

canonicalizeContents :: ArrowList a => a XmlTree XmlTree #

Canonicalize the contents of a document

substitutes all char refs in text and attribute values, removes CDATA section and combines all sequences of resulting text nodes into a single text node

see `canonicalizeAllNodes`

collapseAllXText :: ArrowList a => a XmlTree XmlTree #

Applies collapseXText recursively.

see also : `collapseXText`

collapseXText :: ArrowList a => a XmlTree XmlTree #

Collects sequences of text nodes in the list of children of a node into one single text node. This is useful, e.g. after char and entity reference substitution

xshowEscapeXml :: ArrowXml a => a n XmlTree -> a n String #

apply an arrow to the input and convert the resulting XML trees into an XML escaped string

This is a save variant for converting a tree into an XML string representation that is parsable with `ReadDocument`. It is implemented with `xshow`, but xshow does no XML escaping. The XML escaping is done with `escapeXmlDoc` before xshow is applied.

So the following law holds

    xshowEscapeXml f >>> xread == f

escapeXmlRefs :: (Char -> String -> String, Char -> String -> String) #

escapeHtmlRefs :: (Char -> String -> String, Char -> String -> String) #

haskellRepOfXmlDoc :: ArrowList a => a XmlTree XmlTree #

convert a document into a Haskell representation (with show).

Useful for debugging and trace output. see also : `treeRepOfXmlDoc`, `numberLinesInXmlDoc`

treeRepOfXmlDoc :: ArrowList a => a XmlTree XmlTree #

convert a document into a text representation in tree form.

Useful for debugging and trace output. see also : `haskellRepOfXmlDoc`, `numberLinesInXmlDoc`

addHeadlineToXmlDoc :: ArrowXml a => a XmlTree XmlTree #

indentDoc :: ArrowXml a => a XmlTree XmlTree #

filter for indenting a document tree for pretty printing.

the tree is traversed for inserting whitespace for tag indentation.

whitespace is only inserted or changed at places, where it isn't significant, is's not inserted between tags and text containing non whitespace chars.

whitespace is only inserted or changed at places, where it's not significant. preserving whitespace may be controlled in a document tree by a tag attribute `xml:space`

allowed values for this attribute are `default | preserve`.

input is a complete document tree or a document fragment result is the semantically equivalent formatted tree.

see also : `removeDocWhiteSpace`

numberLinesInXmlDoc :: ArrowList a => a XmlTree XmlTree #

convert a document into a text and add line numbers to the text representation.

Result is a root node with a single text node as child. Useful for debugging and trace output. see also : `haskellRepOfXmlDoc`, `treeRepOfXmlDoc`

preventEmptyElements :: ArrowList a => [String] -> Bool -> a XmlTree XmlTree #

removeComment :: ArrowXml a => a XmlTree XmlTree #

remove a Comment node

removeAllComment :: ArrowXml a => a XmlTree XmlTree #

remove all comments in a tree recursively

removeWhiteSpace :: ArrowXml a => a XmlTree XmlTree #

simple filter for removing whitespace.

no check on sigificant whitespace, e.g. in HTML <pre>-elements, is done.

see also : `removeAllWhiteSpace`, `removeDocWhiteSpace`

removeAllWhiteSpace :: ArrowXml a => a XmlTree XmlTree #

simple recursive filter for removing all whitespace.

removes all text nodes in a tree that consist only of whitespace.

see also : `removeWhiteSpace`, `removeDocWhiteSpace`

removeDocWhiteSpace :: ArrowXml a => a XmlTree XmlTree #

filter for removing all not significant whitespace.

the tree traversed for removing whitespace between elements, that was inserted for indentation and readability. whitespace is only removed at places, where it's not significat preserving whitespace may be controlled in a document tree by a tag attribute `xml:space`

allowed values for this attribute are `default | preserve`

input is root node of the document to be cleaned up, output the semantically equivalent simplified tree

see also : `indentDoc`, `removeAllWhiteSpace`

transfCdata :: ArrowXml a => a XmlTree XmlTree #

converts a CDATA section into normal text nodes

transfAllCdata :: ArrowXml a => a XmlTree XmlTree #

converts CDATA sections in whole document tree into normal text nodes

transfCharRef :: ArrowXml a => a XmlTree XmlTree #

converts a character reference to normal text

transfAllCharRef :: ArrowXml a => a XmlTree XmlTree #

recursively converts all character references to normal text

substAllXHTMLEntityRefs :: ArrowXml a => a XmlTree XmlTree #

substXHTMLEntityRef :: LA XmlTree XmlTree #

rememberDTDAttrl :: ArrowList a => a XmlTree XmlTree #

addDefaultDTDecl :: ArrowList a => a XmlTree XmlTree #

hasXmlPi :: ArrowXml a => a XmlTree XmlTree #

addXmlPi :: ArrowXml a => a XmlTree XmlTree #

add an <?xml version="1.0"?> processing instruction if it's not already there

addXmlPiEncoding :: ArrowXml a => String -> a XmlTree XmlTree #

add an encoding spec to the <?xml version="1.0"?> processing instruction

addDoctypeDecl :: ArrowXml a => String -> String -> String -> a XmlTree XmlTree #

add a doctype declaration to a document

The arguments are the root element name, the PUBLIC id and the SYSTEM id

addXHtmlDoctypeStrict :: ArrowXml a => a XmlTree XmlTree #

add an XHTML strict doctype declaration to a document

add an XHTML strict doctype declaration to a document

addXHtmlDoctypeTransitional :: ArrowXml a => a XmlTree XmlTree #

add an XHTML strict doctype declaration to a document

add an XHTML transitional doctype declaration to a document

addXHtmlDoctypeFrameset :: ArrowXml a => a XmlTree XmlTree #

add an XHTML strict doctype declaration to a document

add an XHTML frameset doctype declaration to a document