@@ -193,16 +193,32 @@ module.exports = class XMLNode
193193 @children .push child
194194 return @
195195
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+
196210 # Creates the document type declaration
197211 #
198212 # `pubID` the public identifier of the external subset
199213 # `sysID` the system identifier of the external subset
200214 doctype : (pubID , sysID ) ->
215+ doc = @ document ()
201216 XMLDocType = require ' ./XMLDocType'
202- doctype = new XMLDocType @ , pubID, sysID
203- @ document () .doctype = doctype
217+ doctype = new XMLDocType doc , pubID, sysID
218+ doc .doctype = doctype
204219 return doctype
205220
221+
206222 # Gets the parent node
207223 up : () ->
208224 if @isRoot
@@ -277,6 +293,7 @@ module.exports = class XMLNode
277293 dat : (value ) -> @ cdata value
278294 com : (value ) -> @ comment value
279295 doc : () -> @ document ()
296+ dec : (version , encoding , standalone ) -> @ declaration version, encoding, standalone
280297 dtd : (pubID , sysID ) -> @ doctype pubID, sysID
281298 e : (name , attributes , text ) -> @ element name, attributes, text
282299 n : (name , attributes , text ) -> @ node name, attributes, text
0 commit comments