xml-conduit-1.2.4: Pure-Haskell utilities for dealing with XML with the conduit package.

Safe HaskellNone
LanguageHaskell98

Text.XML

Contents

Description

DOM-based parsing and rendering.

This module requires that all entities be resolved at parsing. If you need to interact with unresolved entities, please use Text.XML.Unresolved. This is the recommended module for most uses cases.

While many of the datatypes in this module are simply re-exported from Data.XML.Types, Document, Node and Element are all redefined here to disallow the possibility of unresolved entities. Conversion functions are provided to switch between the two sets of datatypes.

For simpler, bidirectional traversal of the DOM tree, see the Text.XML.Cursor module.

Synopsis

Data types

data Element Source

Constructors

Element 

Instances

Eq Element 
Data Element 
Ord Element 
Show Element 
NFData Element 
ToMarkup Element

Note that the special element name {http:/www.snoyman.comxml2html}ie-cond with the single attribute cond is used to indicate an IE conditional comment.

Typeable * Element 

data Name :: *

Constructors

Name 

Fields

nameLocalName :: Text
 
nameNamespace :: Maybe Text
 
namePrefix :: Maybe Text
 

Parsing

Files

Bytes

sinkDoc :: MonadThrow m => ParseSettings -> Consumer ByteString m Document Source

Text

sinkTextDoc :: MonadThrow m => ParseSettings -> Consumer Text m Document Source

Other

fromEvents :: MonadThrow m => Consumer EventPos m Document Source

Rendering

writeFile :: RenderSettings -> FilePath -> Document -> IO () Source

renderBytes :: (MonadBase base m, PrimMonad base) => RenderSettings -> Document -> ConduitM a ByteString m () Source

Settings

def :: Default a => a

Parsing

data ParseSettings Source

Instances

Default ParseSettings 

psRetainNamespaces :: ParseSettings -> Bool Source

Whether the original xmlns attributes should be retained in the parsed values. For more information on motivation, see:

https://github.com/snoyberg/xml/issues/38

Default: False

Since 1.2.1

Entity decoding

decodeXmlEntities :: DecodeEntities Source

Default implementation of DecodeEntities: handles numeric entities and the five standard character entities (lt, gt, amp, quot, apos).

decodeHtmlEntities :: DecodeEntities Source

HTML4-compliant entity decoder. Handles numerics, the five standard character entities, and the additional 248 entities defined by HTML 4 and XHTML 1.

Note that HTML 5 introduces a drastically larger number of entities, and this code does not recognize most of them.

Rendering

data RenderSettings Source

Instances

Default RenderSettings 

rsNamespaces :: RenderSettings -> [(Text, Text)] Source

Defines some top level namespace definitions to be used, in the form of (prefix, namespace). This has absolutely no impact on the meaning of your documents, but can increase readability by moving commonly used namespace declarations to the top level.

rsAttrOrder :: RenderSettings -> Name -> Map Name Text -> [(Name, Text)] Source

Specify how to turn the unordered attributes used by the Text.XML module into an ordered list.

orderAttrs :: [(Name, [Name])] -> Name -> Map Name Text -> [(Name, Text)] Source

Convenience function to create an ordering function suitable for use as the value of rsAttrOrder. The ordering function is created from an explicit ordering of the attributes, specified as a list of tuples, as follows: In each tuple, the first component is the Name of an element, and the second component is a list of attributes names. When the given element is rendered, the attributes listed, when present, appear first in the given order, followed by any other attributes in arbitrary order. If an element does not appear, all of its attributes are rendered in arbitrary order.

Conversion

fromXMLDocument :: Document -> Either (Set Text) Document Source

toXMLNode :: Node -> Node Source

fromXMLNode :: Node -> Either (Set Text) Node Source

fromXMLElement :: Element -> Either (Set Text) Element Source