-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathXMLDTDElement.coffee
More file actions
35 lines (28 loc) · 1.04 KB
/
XMLDTDElement.coffee
File metadata and controls
35 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
XMLNode = require './XMLNode'
NodeType = require './NodeType'
# Represents an attribute
module.exports = class XMLDTDElement extends XMLNode
# Initializes a new instance of `XMLDTDElement`
#
# `parent` the parent `XMLDocType` element
# `name` element name
# `value` element content (defaults to #PCDATA)
constructor: (parent, name, value) ->
super parent
if not name?
throw new Error "Missing DTD element name. " + @debugInfo()
if not value
value = '(#PCDATA)'
if Array.isArray value
value = '(' + value.join(',') + ')'
@name = @stringify.name name
@type = NodeType.ElementDeclaration
@value = @stringify.dtdElementValue value
# Converts the XML fragment to string
#
# `options.pretty` pretty prints the result
# `options.indent` indentation for pretty print
# `options.offset` how many indentations to add to every line for pretty print
# `options.newline` newline sequence for pretty print
toString: (options) ->
@options.writer.dtdElement @, @options.writer.filterOptions(options)