-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathXMLDTDNotation.coffee
More file actions
40 lines (32 loc) · 1.39 KB
/
XMLDTDNotation.coffee
File metadata and controls
40 lines (32 loc) · 1.39 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
36
37
38
39
40
XMLNode = require './XMLNode'
NodeType = require './NodeType'
# Represents a NOTATION entry in the DTD
module.exports = class XMLDTDNotation extends XMLNode
# Initializes a new instance of `XMLDTDNotation`
#
# `parent` the parent `XMLDocType` element
# `name` the name of the notation
# `value` an object with external entity details
# `value.pubID` public identifier
# `value.sysID` system identifier
constructor: (parent, name, value) ->
super parent
if not name?
throw new Error "Missing DTD notation name. " + @debugInfo(name)
if not value.pubID and not value.sysID
throw new Error "Public or system identifiers are required for an external entity. " + @debugInfo(name)
@name = @stringify.name name
@type = NodeType.NotationDeclaration
@pubID = @stringify.dtdPubID value.pubID if value.pubID?
@sysID = @stringify.dtdSysID value.sysID if value.sysID?
# DOM level 1
Object.defineProperty @::, 'publicId', get: () -> @pubID
Object.defineProperty @::, 'systemId', get: () -> @sysID
# 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.dtdNotation @, @options.writer.filterOptions(options)