@@ -36,6 +36,7 @@ module Text.XML.Writer
3636 ) where
3737
3838import Text.XML
39+import Control.Monad
3940import Control.Monad.Writer.Strict
4041import Data.Default ()
4142import qualified Data.DList as DL
@@ -58,37 +59,6 @@ document name children = Document { documentPrologue = Prologue def def def
5859 , documentEpilogue = def
5960 }
6061
61−-- | Create a simple Document starting with a root element with attributes.
62−documentA :: Name -- ^ Root node name
63− -> [(Name, Text)] -- ^ Attributes
64− -> XML -- ^ Contents
65− -> Document
66−documentA name attrs children = Document { documentPrologue = Prologue def def def
67− , documentRoot = Element name (M.fromList attrs) (render children)
68− , documentEpilogue = def
69− }
70−
71−-- | Create a simple Document starting with a root element with a doctype.
72−documentD :: Name -- ^ Root node name
73− -> Maybe Doctype -- ^ DOCTYPE
74− -> XML -- ^ Contents
75− -> Document
76−documentD name dt children = Document { documentPrologue = Prologue def dt def
77− , documentRoot = Element name def (render children)
78− , documentEpilogue = def
79− }
80−
81−-- | Create a simple Document starting with a root element with attributes and doctype.
82−documentAD :: Name -- ^ Root node name
83− -> [(Name, Text)] -- ^ Attributes
84− -> Maybe Doctype -- ^ DOCTYPE
85− -> XML -- ^ Contents
86− -> Document
87−documentAD name attrs dt children = Document { documentPrologue = Prologue def dt def
88− , documentRoot = Element name (M.fromList attrs) (render children)
89− , documentEpilogue = def
90− }
91−
9262-- | Render document using xml-conduit's pretty-printer.
9363pprint :: Document -> IO ()
9464pprint = TL.putStrLn . renderText def { rsPretty = True }
@@ -130,11 +100,11 @@ content :: Text -> XML
130100content = node . NodeContent
131101
132102-- | Mass-convert to nodes.
133−--
103+--
134104-- > let array = element "container" $ many "wrapper" [1..3]
135−--
105+--
136106-- Which gives:
137−--
107+--
138108-- > <container>
139109-- > <wrapper>1</wrapper>
140110-- > <wrapper>2</wrapper>