git.iko.soy/typeable/xml-conduit-writer
on master help sign in
Bring back document{A,D,AD} removed in previous commits.
fd202f1Nick
src/Text/XML/Writer.hs+37−1
unifiedsplit
@@ -17,7 +17,11 @@
17module Text.XML.Writer
17module Text.XML.Writer
18 (
18 (
19 -- * Documents
19 -- * Documents
20− document, soap
20+ document
21+ , documentA
22+ , documentD
23+ , documentAD
24+ , soap
21 , pprint
25 , pprint
22 -- * Elements
26 -- * Elements
23 , XML
27 , XML
@@ -62,6 +66,38 @@ document name children = Document { documentPrologue = Prologue def def def
62 , documentEpilogue = def
66 , documentEpilogue = def
63 }
67 }
64
68
69+
70+-- | Create a simple Document starting with a root element with attributes.
71+documentA :: Name -- ^ Root node name
72+ -> [(Name, Text)] -- ^ Attributes
73+ -> XML -- ^ Contents
74+ -> Document
75+documentA name attrs children = Document { documentPrologue = Prologue def def def
76+ , documentRoot = Element name (M.fromList attrs) (render children)
77+ , documentEpilogue = def
78+ }
79+
80+-- | Create a simple Document starting with a root element with a doctype.
81+documentD :: Name -- ^ Root node name
82+ -> Maybe Doctype -- ^ DOCTYPE
83+ -> XML -- ^ Contents
84+ -> Document
85+documentD name dt children = Document { documentPrologue = Prologue def dt def
86+ , documentRoot = Element name def (render children)
87+ , documentEpilogue = def
88+ }
89+
90+-- | Create a simple Document starting with a root element with attributes and doctype.
91+documentAD :: Name -- ^ Root node name
92+ -> [(Name, Text)] -- ^ Attributes
93+ -> Maybe Doctype -- ^ DOCTYPE
94+ -> XML -- ^ Contents
95+ -> Document
96+documentAD name attrs dt children = Document { documentPrologue = Prologue def dt def
97+ , documentRoot = Element name (M.fromList attrs) (render children)
98+ , documentEpilogue = def
99+ }
100+
65-- | Render document using xml-conduit's pretty-printer.
101-- | Render document using xml-conduit's pretty-printer.
66pprint :: Document -> IO ()
102pprint :: Document -> IO ()
67pprint = TL.putStrLn . renderText def { rsPretty = True }
103pprint = TL.putStrLn . renderText def { rsPretty = True }