-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast XML generation library -- -- Library for high-performance XML generation. @package xmlgen @version 0.6.2.0 -- | This module provides combinators for generating XML documents. -- -- As an example, suppose you want to generate the following XML -- document: -- --
--   <?xml version="1.0"?>
--   <people>
--     <person age="32">Stefan</person>
--     <person age="4">Judith</person>
--   </people>
--   
-- -- Then you could use the following Haskell code: -- --
--   let people = [("Stefan", "32"), ("Judith", "4")]
--   in doc defaultDocInfo $
--        xelem "people" $
--          xelems $ map ((name, age) -> xelem "person" (xattr "age" age <#> xtext name)) people
--   
module Text.XML.Generator -- | The type Xml t represent a piece of XML of type t, -- where t is usually one of Elem, Attr, or -- Doc. data Xml t -- | A piece of XML at the document level. data Doc -- | The DocInfo type contains all information of an XML document -- except the root element. data DocInfo DocInfo :: Bool -> Maybe String -> Xml Doc -> Xml Doc -> DocInfo -- | Value of the standalone attribute in the <?xml ... -- ?> header docInfo_standalone :: DocInfo -> Bool -- | Document type (N.B.: rendering does not escape this value) docInfo_docType :: DocInfo -> Maybe String -- | Content before the root element docInfo_preMisc :: DocInfo -> Xml Doc -- | Content after the root element docInfo_postMisc :: DocInfo -> Xml Doc -- | Constructs an XML document from a DocInfo value and the root -- element. doc :: DocInfo -> Xml Elem -> Xml Doc -- | The default document info (standalone, without document type, without -- content before/after the root element). defaultDocInfo :: DocInfo -- | Type for representing presence or absence of an XML namespace. data Namespace -- | Namespace prefix. type Prefix = Text -- | Namespace URI. type Uri = Text -- | A type for names type Name = Text -- | Constructs a qualified XML namespace. The given URI must not be the -- empty string. namespace :: Prefix -> Uri -> Namespace -- | A Namespace value denoting the absence of any XML namespace -- information. noNamespace :: Namespace -- | A Namespace value denoting the default namespace. -- -- defaultNamespace :: Namespace -- | A piece of XML at the element level. data Elem -- | Construct a simple-named element with the given children. xelem :: AddChildren c => Name -> c -> Xml Elem -- | Construct an element with the given children. xelemQ :: AddChildren c => Namespace -> Name -> c -> Xml Elem -- | Construct a simple-named element without any children. xelemEmpty :: Name -> Xml Elem -- | Construct an element without any children. xelemQEmpty :: Namespace -> Name -> Xml Elem -- | Class for adding children to an element. -- -- The various instances of this class allow the addition of different -- kinds of children. class AddChildren c -- | Merges a list of elements into a single piece of XML at the element -- level. xelems :: [Xml Elem] -> Xml Elem -- | No elements at all. noElems :: Xml Elem -- | The expression xelemWithText n t constructs an XML element -- with name n and text content t. xelemWithText :: Name -> TextContent -> Xml Elem -- | An infix synonym for mappend. (<>) :: Monoid m => m -> m -> m -- | Shortcut for constructing pairs. Used in combination with xelem -- for separating child-attributes from child-elements. (<#>) :: a -> b -> (a, b) -- | A piece of XML at the attribute level. data Attr -- | Construct a simple-named attribute by escaping its value. xattr :: Name -> TextContent -> Xml Attr -- | Construct an attribute by escaping its value. xattrQ :: Namespace -> Name -> TextContent -> Xml Attr -- | Construct an attribute without escaping its value. Note: -- attribute values are quoted with double quotes. xattrQRaw :: Namespace -> Name -> Builder -> Xml Attr -- | Merge a list of attributes into a single piece of XML at the attribute -- level. xattrs :: [Xml Attr] -> Xml Attr -- | The empty attribute list. noAttrs :: Xml Attr -- | Text content subject to escaping. type TextContent = Text -- | Constructs a text node by escaping the given argument. xtext :: TextContent -> Xml Elem -- | Constructs a text node without escaping the given argument. xtextRaw :: Builder -> Xml Elem -- | Constructs a reference to the named entity. Note: no escaping -- is performed on the name of the entity xentityRef :: Name -> Xml Elem -- | An empty, polymorphic piece of XML. xempty :: Renderable t => Xml t -- | Class providing methods for adding processing instructions and -- comments. class Renderable t => Misc t where xprocessingInstruction target content = Xml $ do { env <- ask; return (mkRenderable $ fromString " fromString target <> fromChar ' ' <> fromString content <> fromString "?>", env) } xcomment content = Xml $ do { env <- ask; return (mkRenderable $ fromString "", env) } xprocessingInstruction :: Misc t => String -> String -> Xml t xcomment :: Misc t => String -> Xml t -- | Renders a given piece of XML. xrender :: (Renderable r, XmlOutput t) => Xml r -> t -- | Instances of the XmlOutput class may serve as target of -- serializing an XML document. class XmlOutput t fromBuilder :: XmlOutput t => Builder -> t -- | Any type subject to rendering must implement this type class. class Renderable t -- | Document info for XHTML 1.0 frameset. xhtmlFramesetDocInfo :: DocInfo -- | Document info for XHTML 1.0 strict. xhtmlStrictDocInfo :: DocInfo -- | Document info for XHTML 1.0 transitional. xhtmlTransitionalDocInfo :: DocInfo -- | Constructs the root element of an XHTML document. xhtmlRootElem :: Text -> Xml Elem -> Xml Elem instance Show Namespace instance Eq Namespace instance Renderable Doc instance Renderable Attr instance Renderable Elem instance XmlOutput ByteString instance XmlOutput ByteString instance XmlOutput Builder instance Misc Doc instance Misc Elem instance Monoid (Xml Elem) instance AddChildren () instance AddChildren String instance AddChildren TextContent instance AddChildren (Xml Attr, [Xml Elem]) instance AddChildren (Xml Attr, Xml Elem) instance AddChildren (Xml Elem) instance AddChildren (Xml Attr) instance Monoid (Xml Attr)