xml2js 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec_status +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/xml2js.rb +5 -0
- data/lib/xml2js/node_modules/sax/LICENSE +41 -0
- data/lib/xml2js/node_modules/sax/README.md +225 -0
- data/lib/xml2js/node_modules/sax/lib/sax.js +1565 -0
- data/lib/xml2js/node_modules/sax/package.json +61 -0
- data/lib/xml2js/node_modules/xml2js/LICENSE +19 -0
- data/lib/xml2js/node_modules/xml2js/README.md +406 -0
- data/lib/xml2js/node_modules/xml2js/lib/bom.js +12 -0
- data/lib/xml2js/node_modules/xml2js/lib/builder.js +127 -0
- data/lib/xml2js/node_modules/xml2js/lib/defaults.js +72 -0
- data/lib/xml2js/node_modules/xml2js/lib/parser.js +357 -0
- data/lib/xml2js/node_modules/xml2js/lib/processors.js +34 -0
- data/lib/xml2js/node_modules/xml2js/lib/xml2js.js +37 -0
- data/lib/xml2js/node_modules/xml2js/package.json +280 -0
- data/lib/xml2js/node_modules/xmlbuilder/.npmignore +5 -0
- data/lib/xml2js/node_modules/xmlbuilder/CHANGELOG.md +423 -0
- data/lib/xml2js/node_modules/xmlbuilder/LICENSE +21 -0
- data/lib/xml2js/node_modules/xmlbuilder/README.md +85 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/Utility.js +73 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLAttribute.js +31 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLCData.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLComment.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDAttList.js +50 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDElement.js +35 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDEntity.js +56 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDNotation.js +37 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDeclaration.js +40 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocType.js +107 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocument.js +48 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocumentCB.js +402 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLElement.js +111 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLNode.js +432 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js +35 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLRaw.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStreamWriter.js +279 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStringWriter.js +334 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStringifier.js +163 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLText.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLWriterBase.js +90 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/index.js +53 -0
- data/lib/xml2js/node_modules/xmlbuilder/package.json +65 -0
- data/lib/xml2js/package-lock.json +25 -0
- data/lib/xml2js/parser.js +33 -0
- data/lib/xml2js/parser.rb +31 -0
- data/lib/xml2js/version.rb +3 -0
- data/xml2js.gemspec +30 -0
- metadata +154 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLDeclaration, XMLNode, isObject,
|
4
|
+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
5
|
+
hasProp = {}.hasOwnProperty;
|
6
|
+
|
7
|
+
isObject = require('./Utility').isObject;
|
8
|
+
|
9
|
+
XMLNode = require('./XMLNode');
|
10
|
+
|
11
|
+
module.exports = XMLDeclaration = (function(superClass) {
|
12
|
+
extend(XMLDeclaration, superClass);
|
13
|
+
|
14
|
+
function XMLDeclaration(parent, version, encoding, standalone) {
|
15
|
+
var ref;
|
16
|
+
XMLDeclaration.__super__.constructor.call(this, parent);
|
17
|
+
if (isObject(version)) {
|
18
|
+
ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
|
19
|
+
}
|
20
|
+
if (!version) {
|
21
|
+
version = '1.0';
|
22
|
+
}
|
23
|
+
this.version = this.stringify.xmlVersion(version);
|
24
|
+
if (encoding != null) {
|
25
|
+
this.encoding = this.stringify.xmlEncoding(encoding);
|
26
|
+
}
|
27
|
+
if (standalone != null) {
|
28
|
+
this.standalone = this.stringify.xmlStandalone(standalone);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
XMLDeclaration.prototype.toString = function(options) {
|
33
|
+
return this.options.writer.set(options).declaration(this);
|
34
|
+
};
|
35
|
+
|
36
|
+
return XMLDeclaration;
|
37
|
+
|
38
|
+
})(XMLNode);
|
39
|
+
|
40
|
+
}).call(this);
|
@@ -0,0 +1,107 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, isObject,
|
4
|
+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
5
|
+
hasProp = {}.hasOwnProperty;
|
6
|
+
|
7
|
+
isObject = require('./Utility').isObject;
|
8
|
+
|
9
|
+
XMLNode = require('./XMLNode');
|
10
|
+
|
11
|
+
XMLDTDAttList = require('./XMLDTDAttList');
|
12
|
+
|
13
|
+
XMLDTDEntity = require('./XMLDTDEntity');
|
14
|
+
|
15
|
+
XMLDTDElement = require('./XMLDTDElement');
|
16
|
+
|
17
|
+
XMLDTDNotation = require('./XMLDTDNotation');
|
18
|
+
|
19
|
+
module.exports = XMLDocType = (function(superClass) {
|
20
|
+
extend(XMLDocType, superClass);
|
21
|
+
|
22
|
+
function XMLDocType(parent, pubID, sysID) {
|
23
|
+
var ref, ref1;
|
24
|
+
XMLDocType.__super__.constructor.call(this, parent);
|
25
|
+
this.documentObject = parent;
|
26
|
+
if (isObject(pubID)) {
|
27
|
+
ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
|
28
|
+
}
|
29
|
+
if (sysID == null) {
|
30
|
+
ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
|
31
|
+
}
|
32
|
+
if (pubID != null) {
|
33
|
+
this.pubID = this.stringify.dtdPubID(pubID);
|
34
|
+
}
|
35
|
+
if (sysID != null) {
|
36
|
+
this.sysID = this.stringify.dtdSysID(sysID);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
XMLDocType.prototype.element = function(name, value) {
|
41
|
+
var child;
|
42
|
+
child = new XMLDTDElement(this, name, value);
|
43
|
+
this.children.push(child);
|
44
|
+
return this;
|
45
|
+
};
|
46
|
+
|
47
|
+
XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
48
|
+
var child;
|
49
|
+
child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
50
|
+
this.children.push(child);
|
51
|
+
return this;
|
52
|
+
};
|
53
|
+
|
54
|
+
XMLDocType.prototype.entity = function(name, value) {
|
55
|
+
var child;
|
56
|
+
child = new XMLDTDEntity(this, false, name, value);
|
57
|
+
this.children.push(child);
|
58
|
+
return this;
|
59
|
+
};
|
60
|
+
|
61
|
+
XMLDocType.prototype.pEntity = function(name, value) {
|
62
|
+
var child;
|
63
|
+
child = new XMLDTDEntity(this, true, name, value);
|
64
|
+
this.children.push(child);
|
65
|
+
return this;
|
66
|
+
};
|
67
|
+
|
68
|
+
XMLDocType.prototype.notation = function(name, value) {
|
69
|
+
var child;
|
70
|
+
child = new XMLDTDNotation(this, name, value);
|
71
|
+
this.children.push(child);
|
72
|
+
return this;
|
73
|
+
};
|
74
|
+
|
75
|
+
XMLDocType.prototype.toString = function(options) {
|
76
|
+
return this.options.writer.set(options).docType(this);
|
77
|
+
};
|
78
|
+
|
79
|
+
XMLDocType.prototype.ele = function(name, value) {
|
80
|
+
return this.element(name, value);
|
81
|
+
};
|
82
|
+
|
83
|
+
XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
84
|
+
return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
85
|
+
};
|
86
|
+
|
87
|
+
XMLDocType.prototype.ent = function(name, value) {
|
88
|
+
return this.entity(name, value);
|
89
|
+
};
|
90
|
+
|
91
|
+
XMLDocType.prototype.pent = function(name, value) {
|
92
|
+
return this.pEntity(name, value);
|
93
|
+
};
|
94
|
+
|
95
|
+
XMLDocType.prototype.not = function(name, value) {
|
96
|
+
return this.notation(name, value);
|
97
|
+
};
|
98
|
+
|
99
|
+
XMLDocType.prototype.up = function() {
|
100
|
+
return this.root() || this.documentObject;
|
101
|
+
};
|
102
|
+
|
103
|
+
return XMLDocType;
|
104
|
+
|
105
|
+
})(XMLNode);
|
106
|
+
|
107
|
+
}).call(this);
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
|
4
|
+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
5
|
+
hasProp = {}.hasOwnProperty;
|
6
|
+
|
7
|
+
isPlainObject = require('./Utility').isPlainObject;
|
8
|
+
|
9
|
+
XMLNode = require('./XMLNode');
|
10
|
+
|
11
|
+
XMLStringifier = require('./XMLStringifier');
|
12
|
+
|
13
|
+
XMLStringWriter = require('./XMLStringWriter');
|
14
|
+
|
15
|
+
module.exports = XMLDocument = (function(superClass) {
|
16
|
+
extend(XMLDocument, superClass);
|
17
|
+
|
18
|
+
function XMLDocument(options) {
|
19
|
+
XMLDocument.__super__.constructor.call(this, null);
|
20
|
+
options || (options = {});
|
21
|
+
if (!options.writer) {
|
22
|
+
options.writer = new XMLStringWriter();
|
23
|
+
}
|
24
|
+
this.options = options;
|
25
|
+
this.stringify = new XMLStringifier(options);
|
26
|
+
this.isDocument = true;
|
27
|
+
}
|
28
|
+
|
29
|
+
XMLDocument.prototype.end = function(writer) {
|
30
|
+
var writerOptions;
|
31
|
+
if (!writer) {
|
32
|
+
writer = this.options.writer;
|
33
|
+
} else if (isPlainObject(writer)) {
|
34
|
+
writerOptions = writer;
|
35
|
+
writer = this.options.writer.set(writerOptions);
|
36
|
+
}
|
37
|
+
return writer.document(this);
|
38
|
+
};
|
39
|
+
|
40
|
+
XMLDocument.prototype.toString = function(options) {
|
41
|
+
return this.options.writer.set(options).document(this);
|
42
|
+
};
|
43
|
+
|
44
|
+
return XMLDocument;
|
45
|
+
|
46
|
+
})(XMLNode);
|
47
|
+
|
48
|
+
}).call(this);
|
@@ -0,0 +1,402 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
|
4
|
+
hasProp = {}.hasOwnProperty;
|
5
|
+
|
6
|
+
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
|
7
|
+
|
8
|
+
XMLElement = require('./XMLElement');
|
9
|
+
|
10
|
+
XMLCData = require('./XMLCData');
|
11
|
+
|
12
|
+
XMLComment = require('./XMLComment');
|
13
|
+
|
14
|
+
XMLRaw = require('./XMLRaw');
|
15
|
+
|
16
|
+
XMLText = require('./XMLText');
|
17
|
+
|
18
|
+
XMLProcessingInstruction = require('./XMLProcessingInstruction');
|
19
|
+
|
20
|
+
XMLDeclaration = require('./XMLDeclaration');
|
21
|
+
|
22
|
+
XMLDocType = require('./XMLDocType');
|
23
|
+
|
24
|
+
XMLDTDAttList = require('./XMLDTDAttList');
|
25
|
+
|
26
|
+
XMLDTDEntity = require('./XMLDTDEntity');
|
27
|
+
|
28
|
+
XMLDTDElement = require('./XMLDTDElement');
|
29
|
+
|
30
|
+
XMLDTDNotation = require('./XMLDTDNotation');
|
31
|
+
|
32
|
+
XMLAttribute = require('./XMLAttribute');
|
33
|
+
|
34
|
+
XMLStringifier = require('./XMLStringifier');
|
35
|
+
|
36
|
+
XMLStringWriter = require('./XMLStringWriter');
|
37
|
+
|
38
|
+
module.exports = XMLDocumentCB = (function() {
|
39
|
+
function XMLDocumentCB(options, onData, onEnd) {
|
40
|
+
var writerOptions;
|
41
|
+
options || (options = {});
|
42
|
+
if (!options.writer) {
|
43
|
+
options.writer = new XMLStringWriter(options);
|
44
|
+
} else if (isPlainObject(options.writer)) {
|
45
|
+
writerOptions = options.writer;
|
46
|
+
options.writer = new XMLStringWriter(writerOptions);
|
47
|
+
}
|
48
|
+
this.options = options;
|
49
|
+
this.writer = options.writer;
|
50
|
+
this.stringify = new XMLStringifier(options);
|
51
|
+
this.onDataCallback = onData || function() {};
|
52
|
+
this.onEndCallback = onEnd || function() {};
|
53
|
+
this.currentNode = null;
|
54
|
+
this.currentLevel = -1;
|
55
|
+
this.openTags = {};
|
56
|
+
this.documentStarted = false;
|
57
|
+
this.documentCompleted = false;
|
58
|
+
this.root = null;
|
59
|
+
}
|
60
|
+
|
61
|
+
XMLDocumentCB.prototype.node = function(name, attributes, text) {
|
62
|
+
var ref1;
|
63
|
+
if (name == null) {
|
64
|
+
throw new Error("Missing node name");
|
65
|
+
}
|
66
|
+
if (this.root && this.currentLevel === -1) {
|
67
|
+
throw new Error("Document can only have one root node");
|
68
|
+
}
|
69
|
+
this.openCurrent();
|
70
|
+
name = name.valueOf();
|
71
|
+
if (attributes == null) {
|
72
|
+
attributes = {};
|
73
|
+
}
|
74
|
+
attributes = attributes.valueOf();
|
75
|
+
if (!isObject(attributes)) {
|
76
|
+
ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
|
77
|
+
}
|
78
|
+
this.currentNode = new XMLElement(this, name, attributes);
|
79
|
+
this.currentNode.children = false;
|
80
|
+
this.currentLevel++;
|
81
|
+
this.openTags[this.currentLevel] = this.currentNode;
|
82
|
+
if (text != null) {
|
83
|
+
this.text(text);
|
84
|
+
}
|
85
|
+
return this;
|
86
|
+
};
|
87
|
+
|
88
|
+
XMLDocumentCB.prototype.element = function(name, attributes, text) {
|
89
|
+
if (this.currentNode && this.currentNode instanceof XMLDocType) {
|
90
|
+
return this.dtdElement.apply(this, arguments);
|
91
|
+
} else {
|
92
|
+
return this.node(name, attributes, text);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
XMLDocumentCB.prototype.attribute = function(name, value) {
|
97
|
+
var attName, attValue;
|
98
|
+
if (!this.currentNode || this.currentNode.children) {
|
99
|
+
throw new Error("att() can only be used immediately after an ele() call in callback mode");
|
100
|
+
}
|
101
|
+
if (name != null) {
|
102
|
+
name = name.valueOf();
|
103
|
+
}
|
104
|
+
if (isObject(name)) {
|
105
|
+
for (attName in name) {
|
106
|
+
if (!hasProp.call(name, attName)) continue;
|
107
|
+
attValue = name[attName];
|
108
|
+
this.attribute(attName, attValue);
|
109
|
+
}
|
110
|
+
} else {
|
111
|
+
if (isFunction(value)) {
|
112
|
+
value = value.apply();
|
113
|
+
}
|
114
|
+
if (!this.options.skipNullAttributes || (value != null)) {
|
115
|
+
this.currentNode.attributes[name] = new XMLAttribute(this, name, value);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
return this;
|
119
|
+
};
|
120
|
+
|
121
|
+
XMLDocumentCB.prototype.text = function(value) {
|
122
|
+
var node;
|
123
|
+
this.openCurrent();
|
124
|
+
node = new XMLText(this, value);
|
125
|
+
this.onData(this.writer.text(node, this.currentLevel + 1));
|
126
|
+
return this;
|
127
|
+
};
|
128
|
+
|
129
|
+
XMLDocumentCB.prototype.cdata = function(value) {
|
130
|
+
var node;
|
131
|
+
this.openCurrent();
|
132
|
+
node = new XMLCData(this, value);
|
133
|
+
this.onData(this.writer.cdata(node, this.currentLevel + 1));
|
134
|
+
return this;
|
135
|
+
};
|
136
|
+
|
137
|
+
XMLDocumentCB.prototype.comment = function(value) {
|
138
|
+
var node;
|
139
|
+
this.openCurrent();
|
140
|
+
node = new XMLComment(this, value);
|
141
|
+
this.onData(this.writer.comment(node, this.currentLevel + 1));
|
142
|
+
return this;
|
143
|
+
};
|
144
|
+
|
145
|
+
XMLDocumentCB.prototype.raw = function(value) {
|
146
|
+
var node;
|
147
|
+
this.openCurrent();
|
148
|
+
node = new XMLRaw(this, value);
|
149
|
+
this.onData(this.writer.raw(node, this.currentLevel + 1));
|
150
|
+
return this;
|
151
|
+
};
|
152
|
+
|
153
|
+
XMLDocumentCB.prototype.instruction = function(target, value) {
|
154
|
+
var i, insTarget, insValue, len, node;
|
155
|
+
this.openCurrent();
|
156
|
+
if (target != null) {
|
157
|
+
target = target.valueOf();
|
158
|
+
}
|
159
|
+
if (value != null) {
|
160
|
+
value = value.valueOf();
|
161
|
+
}
|
162
|
+
if (Array.isArray(target)) {
|
163
|
+
for (i = 0, len = target.length; i < len; i++) {
|
164
|
+
insTarget = target[i];
|
165
|
+
this.instruction(insTarget);
|
166
|
+
}
|
167
|
+
} else if (isObject(target)) {
|
168
|
+
for (insTarget in target) {
|
169
|
+
if (!hasProp.call(target, insTarget)) continue;
|
170
|
+
insValue = target[insTarget];
|
171
|
+
this.instruction(insTarget, insValue);
|
172
|
+
}
|
173
|
+
} else {
|
174
|
+
if (isFunction(value)) {
|
175
|
+
value = value.apply();
|
176
|
+
}
|
177
|
+
node = new XMLProcessingInstruction(this, target, value);
|
178
|
+
this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
|
179
|
+
}
|
180
|
+
return this;
|
181
|
+
};
|
182
|
+
|
183
|
+
XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
|
184
|
+
var node;
|
185
|
+
this.openCurrent();
|
186
|
+
if (this.documentStarted) {
|
187
|
+
throw new Error("declaration() must be the first node");
|
188
|
+
}
|
189
|
+
node = new XMLDeclaration(this, version, encoding, standalone);
|
190
|
+
this.onData(this.writer.declaration(node, this.currentLevel + 1));
|
191
|
+
return this;
|
192
|
+
};
|
193
|
+
|
194
|
+
XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
|
195
|
+
this.openCurrent();
|
196
|
+
if (root == null) {
|
197
|
+
throw new Error("Missing root node name");
|
198
|
+
}
|
199
|
+
if (this.root) {
|
200
|
+
throw new Error("dtd() must come before the root node");
|
201
|
+
}
|
202
|
+
this.currentNode = new XMLDocType(this, pubID, sysID);
|
203
|
+
this.currentNode.rootNodeName = root;
|
204
|
+
this.currentNode.children = false;
|
205
|
+
this.currentLevel++;
|
206
|
+
this.openTags[this.currentLevel] = this.currentNode;
|
207
|
+
return this;
|
208
|
+
};
|
209
|
+
|
210
|
+
XMLDocumentCB.prototype.dtdElement = function(name, value) {
|
211
|
+
var node;
|
212
|
+
this.openCurrent();
|
213
|
+
node = new XMLDTDElement(this, name, value);
|
214
|
+
this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
|
215
|
+
return this;
|
216
|
+
};
|
217
|
+
|
218
|
+
XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
219
|
+
var node;
|
220
|
+
this.openCurrent();
|
221
|
+
node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
222
|
+
this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
|
223
|
+
return this;
|
224
|
+
};
|
225
|
+
|
226
|
+
XMLDocumentCB.prototype.entity = function(name, value) {
|
227
|
+
var node;
|
228
|
+
this.openCurrent();
|
229
|
+
node = new XMLDTDEntity(this, false, name, value);
|
230
|
+
this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
|
231
|
+
return this;
|
232
|
+
};
|
233
|
+
|
234
|
+
XMLDocumentCB.prototype.pEntity = function(name, value) {
|
235
|
+
var node;
|
236
|
+
this.openCurrent();
|
237
|
+
node = new XMLDTDEntity(this, true, name, value);
|
238
|
+
this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
|
239
|
+
return this;
|
240
|
+
};
|
241
|
+
|
242
|
+
XMLDocumentCB.prototype.notation = function(name, value) {
|
243
|
+
var node;
|
244
|
+
this.openCurrent();
|
245
|
+
node = new XMLDTDNotation(this, name, value);
|
246
|
+
this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
|
247
|
+
return this;
|
248
|
+
};
|
249
|
+
|
250
|
+
XMLDocumentCB.prototype.up = function() {
|
251
|
+
if (this.currentLevel < 0) {
|
252
|
+
throw new Error("The document node has no parent");
|
253
|
+
}
|
254
|
+
if (this.currentNode) {
|
255
|
+
if (this.currentNode.children) {
|
256
|
+
this.closeNode(this.currentNode);
|
257
|
+
} else {
|
258
|
+
this.openNode(this.currentNode);
|
259
|
+
}
|
260
|
+
this.currentNode = null;
|
261
|
+
} else {
|
262
|
+
this.closeNode(this.openTags[this.currentLevel]);
|
263
|
+
}
|
264
|
+
delete this.openTags[this.currentLevel];
|
265
|
+
this.currentLevel--;
|
266
|
+
return this;
|
267
|
+
};
|
268
|
+
|
269
|
+
XMLDocumentCB.prototype.end = function() {
|
270
|
+
while (this.currentLevel >= 0) {
|
271
|
+
this.up();
|
272
|
+
}
|
273
|
+
return this.onEnd();
|
274
|
+
};
|
275
|
+
|
276
|
+
XMLDocumentCB.prototype.openCurrent = function() {
|
277
|
+
if (this.currentNode) {
|
278
|
+
this.currentNode.children = true;
|
279
|
+
return this.openNode(this.currentNode);
|
280
|
+
}
|
281
|
+
};
|
282
|
+
|
283
|
+
XMLDocumentCB.prototype.openNode = function(node) {
|
284
|
+
if (!node.isOpen) {
|
285
|
+
if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
|
286
|
+
this.root = node;
|
287
|
+
}
|
288
|
+
this.onData(this.writer.openNode(node, this.currentLevel));
|
289
|
+
return node.isOpen = true;
|
290
|
+
}
|
291
|
+
};
|
292
|
+
|
293
|
+
XMLDocumentCB.prototype.closeNode = function(node) {
|
294
|
+
if (!node.isClosed) {
|
295
|
+
this.onData(this.writer.closeNode(node, this.currentLevel));
|
296
|
+
return node.isClosed = true;
|
297
|
+
}
|
298
|
+
};
|
299
|
+
|
300
|
+
XMLDocumentCB.prototype.onData = function(chunk) {
|
301
|
+
this.documentStarted = true;
|
302
|
+
return this.onDataCallback(chunk);
|
303
|
+
};
|
304
|
+
|
305
|
+
XMLDocumentCB.prototype.onEnd = function() {
|
306
|
+
this.documentCompleted = true;
|
307
|
+
return this.onEndCallback();
|
308
|
+
};
|
309
|
+
|
310
|
+
XMLDocumentCB.prototype.ele = function() {
|
311
|
+
return this.element.apply(this, arguments);
|
312
|
+
};
|
313
|
+
|
314
|
+
XMLDocumentCB.prototype.nod = function(name, attributes, text) {
|
315
|
+
return this.node(name, attributes, text);
|
316
|
+
};
|
317
|
+
|
318
|
+
XMLDocumentCB.prototype.txt = function(value) {
|
319
|
+
return this.text(value);
|
320
|
+
};
|
321
|
+
|
322
|
+
XMLDocumentCB.prototype.dat = function(value) {
|
323
|
+
return this.cdata(value);
|
324
|
+
};
|
325
|
+
|
326
|
+
XMLDocumentCB.prototype.com = function(value) {
|
327
|
+
return this.comment(value);
|
328
|
+
};
|
329
|
+
|
330
|
+
XMLDocumentCB.prototype.ins = function(target, value) {
|
331
|
+
return this.instruction(target, value);
|
332
|
+
};
|
333
|
+
|
334
|
+
XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
|
335
|
+
return this.declaration(version, encoding, standalone);
|
336
|
+
};
|
337
|
+
|
338
|
+
XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
|
339
|
+
return this.doctype(root, pubID, sysID);
|
340
|
+
};
|
341
|
+
|
342
|
+
XMLDocumentCB.prototype.e = function(name, attributes, text) {
|
343
|
+
return this.element(name, attributes, text);
|
344
|
+
};
|
345
|
+
|
346
|
+
XMLDocumentCB.prototype.n = function(name, attributes, text) {
|
347
|
+
return this.node(name, attributes, text);
|
348
|
+
};
|
349
|
+
|
350
|
+
XMLDocumentCB.prototype.t = function(value) {
|
351
|
+
return this.text(value);
|
352
|
+
};
|
353
|
+
|
354
|
+
XMLDocumentCB.prototype.d = function(value) {
|
355
|
+
return this.cdata(value);
|
356
|
+
};
|
357
|
+
|
358
|
+
XMLDocumentCB.prototype.c = function(value) {
|
359
|
+
return this.comment(value);
|
360
|
+
};
|
361
|
+
|
362
|
+
XMLDocumentCB.prototype.r = function(value) {
|
363
|
+
return this.raw(value);
|
364
|
+
};
|
365
|
+
|
366
|
+
XMLDocumentCB.prototype.i = function(target, value) {
|
367
|
+
return this.instruction(target, value);
|
368
|
+
};
|
369
|
+
|
370
|
+
XMLDocumentCB.prototype.att = function() {
|
371
|
+
if (this.currentNode && this.currentNode instanceof XMLDocType) {
|
372
|
+
return this.attList.apply(this, arguments);
|
373
|
+
} else {
|
374
|
+
return this.attribute.apply(this, arguments);
|
375
|
+
}
|
376
|
+
};
|
377
|
+
|
378
|
+
XMLDocumentCB.prototype.a = function() {
|
379
|
+
if (this.currentNode && this.currentNode instanceof XMLDocType) {
|
380
|
+
return this.attList.apply(this, arguments);
|
381
|
+
} else {
|
382
|
+
return this.attribute.apply(this, arguments);
|
383
|
+
}
|
384
|
+
};
|
385
|
+
|
386
|
+
XMLDocumentCB.prototype.ent = function(name, value) {
|
387
|
+
return this.entity(name, value);
|
388
|
+
};
|
389
|
+
|
390
|
+
XMLDocumentCB.prototype.pent = function(name, value) {
|
391
|
+
return this.pEntity(name, value);
|
392
|
+
};
|
393
|
+
|
394
|
+
XMLDocumentCB.prototype.not = function(name, value) {
|
395
|
+
return this.notation(name, value);
|
396
|
+
};
|
397
|
+
|
398
|
+
return XMLDocumentCB;
|
399
|
+
|
400
|
+
})();
|
401
|
+
|
402
|
+
}).call(this);
|