@@ -193,16 +193,32 @@ module.exports = class XMLNode
193
193
@children .push child
194
194
return @
195
195
196
+
197
+ # Creates the xml declaration
198
+ #
199
+ # `version` A version number string, e.g. 1.0
200
+ # `encoding` Encoding declaration, e.g. UTF-8
201
+ # `standalone` standalone document declaration: true or false
202
+ declaration : (version , encoding , standalone ) ->
203
+ doc = @ document ()
204
+ XMLDeclaration = require ' ./XMLDeclaration'
205
+ xmldec = new XMLDeclaration doc, version, encoding, standalone
206
+ doc .xmldec = xmldec
207
+ return doc .root ()
208
+
209
+
196
210
# Creates the document type declaration
197
211
#
198
212
# `pubID` the public identifier of the external subset
199
213
# `sysID` the system identifier of the external subset
200
214
doctype : (pubID , sysID ) ->
215
+ doc = @ document ()
201
216
XMLDocType = require ' ./XMLDocType'
202
- doctype = new XMLDocType @ , pubID, sysID
203
- @ document () .doctype = doctype
217
+ doctype = new XMLDocType doc , pubID, sysID
218
+ doc .doctype = doctype
204
219
return doctype
205
220
221
+
206
222
# Gets the parent node
207
223
up : () ->
208
224
if @isRoot
@@ -277,6 +293,7 @@ module.exports = class XMLNode
277
293
dat : (value ) -> @ cdata value
278
294
com : (value ) -> @ comment value
279
295
doc : () -> @ document ()
296
+ dec : (version , encoding , standalone ) -> @ declaration version, encoding, standalone
280
297
dtd : (pubID , sysID ) -> @ doctype pubID, sysID
281
298
e : (name , attributes , text ) -> @ element name, attributes, text
282
299
n : (name , attributes , text ) -> @ node name, attributes, text
0 commit comments