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,111 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
|
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
|
+
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
|
8
|
+
|
9
|
+
XMLNode = require('./XMLNode');
|
10
|
+
|
11
|
+
XMLAttribute = require('./XMLAttribute');
|
12
|
+
|
13
|
+
module.exports = XMLElement = (function(superClass) {
|
14
|
+
extend(XMLElement, superClass);
|
15
|
+
|
16
|
+
function XMLElement(parent, name, attributes) {
|
17
|
+
XMLElement.__super__.constructor.call(this, parent);
|
18
|
+
if (name == null) {
|
19
|
+
throw new Error("Missing element name");
|
20
|
+
}
|
21
|
+
this.name = this.stringify.eleName(name);
|
22
|
+
this.attributes = {};
|
23
|
+
if (attributes != null) {
|
24
|
+
this.attribute(attributes);
|
25
|
+
}
|
26
|
+
if (parent.isDocument) {
|
27
|
+
this.isRoot = true;
|
28
|
+
this.documentObject = parent;
|
29
|
+
parent.rootObject = this;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
XMLElement.prototype.clone = function() {
|
34
|
+
var att, attName, clonedSelf, ref1;
|
35
|
+
clonedSelf = Object.create(this);
|
36
|
+
if (clonedSelf.isRoot) {
|
37
|
+
clonedSelf.documentObject = null;
|
38
|
+
}
|
39
|
+
clonedSelf.attributes = {};
|
40
|
+
ref1 = this.attributes;
|
41
|
+
for (attName in ref1) {
|
42
|
+
if (!hasProp.call(ref1, attName)) continue;
|
43
|
+
att = ref1[attName];
|
44
|
+
clonedSelf.attributes[attName] = att.clone();
|
45
|
+
}
|
46
|
+
clonedSelf.children = [];
|
47
|
+
this.children.forEach(function(child) {
|
48
|
+
var clonedChild;
|
49
|
+
clonedChild = child.clone();
|
50
|
+
clonedChild.parent = clonedSelf;
|
51
|
+
return clonedSelf.children.push(clonedChild);
|
52
|
+
});
|
53
|
+
return clonedSelf;
|
54
|
+
};
|
55
|
+
|
56
|
+
XMLElement.prototype.attribute = function(name, value) {
|
57
|
+
var attName, attValue;
|
58
|
+
if (name != null) {
|
59
|
+
name = name.valueOf();
|
60
|
+
}
|
61
|
+
if (isObject(name)) {
|
62
|
+
for (attName in name) {
|
63
|
+
if (!hasProp.call(name, attName)) continue;
|
64
|
+
attValue = name[attName];
|
65
|
+
this.attribute(attName, attValue);
|
66
|
+
}
|
67
|
+
} else {
|
68
|
+
if (isFunction(value)) {
|
69
|
+
value = value.apply();
|
70
|
+
}
|
71
|
+
if (!this.options.skipNullAttributes || (value != null)) {
|
72
|
+
this.attributes[name] = new XMLAttribute(this, name, value);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
return this;
|
76
|
+
};
|
77
|
+
|
78
|
+
XMLElement.prototype.removeAttribute = function(name) {
|
79
|
+
var attName, i, len;
|
80
|
+
if (name == null) {
|
81
|
+
throw new Error("Missing attribute name");
|
82
|
+
}
|
83
|
+
name = name.valueOf();
|
84
|
+
if (Array.isArray(name)) {
|
85
|
+
for (i = 0, len = name.length; i < len; i++) {
|
86
|
+
attName = name[i];
|
87
|
+
delete this.attributes[attName];
|
88
|
+
}
|
89
|
+
} else {
|
90
|
+
delete this.attributes[name];
|
91
|
+
}
|
92
|
+
return this;
|
93
|
+
};
|
94
|
+
|
95
|
+
XMLElement.prototype.toString = function(options) {
|
96
|
+
return this.options.writer.set(options).element(this);
|
97
|
+
};
|
98
|
+
|
99
|
+
XMLElement.prototype.att = function(name, value) {
|
100
|
+
return this.attribute(name, value);
|
101
|
+
};
|
102
|
+
|
103
|
+
XMLElement.prototype.a = function(name, value) {
|
104
|
+
return this.attribute(name, value);
|
105
|
+
};
|
106
|
+
|
107
|
+
return XMLElement;
|
108
|
+
|
109
|
+
})(XMLNode);
|
110
|
+
|
111
|
+
}).call(this);
|
@@ -0,0 +1,432 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
|
4
|
+
hasProp = {}.hasOwnProperty;
|
5
|
+
|
6
|
+
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
|
7
|
+
|
8
|
+
XMLElement = null;
|
9
|
+
|
10
|
+
XMLCData = null;
|
11
|
+
|
12
|
+
XMLComment = null;
|
13
|
+
|
14
|
+
XMLDeclaration = null;
|
15
|
+
|
16
|
+
XMLDocType = null;
|
17
|
+
|
18
|
+
XMLRaw = null;
|
19
|
+
|
20
|
+
XMLText = null;
|
21
|
+
|
22
|
+
XMLProcessingInstruction = null;
|
23
|
+
|
24
|
+
module.exports = XMLNode = (function() {
|
25
|
+
function XMLNode(parent) {
|
26
|
+
this.parent = parent;
|
27
|
+
if (this.parent) {
|
28
|
+
this.options = this.parent.options;
|
29
|
+
this.stringify = this.parent.stringify;
|
30
|
+
}
|
31
|
+
this.children = [];
|
32
|
+
if (!XMLElement) {
|
33
|
+
XMLElement = require('./XMLElement');
|
34
|
+
XMLCData = require('./XMLCData');
|
35
|
+
XMLComment = require('./XMLComment');
|
36
|
+
XMLDeclaration = require('./XMLDeclaration');
|
37
|
+
XMLDocType = require('./XMLDocType');
|
38
|
+
XMLRaw = require('./XMLRaw');
|
39
|
+
XMLText = require('./XMLText');
|
40
|
+
XMLProcessingInstruction = require('./XMLProcessingInstruction');
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
XMLNode.prototype.element = function(name, attributes, text) {
|
45
|
+
var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
|
46
|
+
lastChild = null;
|
47
|
+
if (attributes == null) {
|
48
|
+
attributes = {};
|
49
|
+
}
|
50
|
+
attributes = attributes.valueOf();
|
51
|
+
if (!isObject(attributes)) {
|
52
|
+
ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
|
53
|
+
}
|
54
|
+
if (name != null) {
|
55
|
+
name = name.valueOf();
|
56
|
+
}
|
57
|
+
if (Array.isArray(name)) {
|
58
|
+
for (j = 0, len = name.length; j < len; j++) {
|
59
|
+
item = name[j];
|
60
|
+
lastChild = this.element(item);
|
61
|
+
}
|
62
|
+
} else if (isFunction(name)) {
|
63
|
+
lastChild = this.element(name.apply());
|
64
|
+
} else if (isObject(name)) {
|
65
|
+
for (key in name) {
|
66
|
+
if (!hasProp.call(name, key)) continue;
|
67
|
+
val = name[key];
|
68
|
+
if (isFunction(val)) {
|
69
|
+
val = val.apply();
|
70
|
+
}
|
71
|
+
if ((isObject(val)) && (isEmpty(val))) {
|
72
|
+
val = null;
|
73
|
+
}
|
74
|
+
if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
|
75
|
+
lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
|
76
|
+
} else if (!this.options.separateArrayItems && Array.isArray(val)) {
|
77
|
+
for (k = 0, len1 = val.length; k < len1; k++) {
|
78
|
+
item = val[k];
|
79
|
+
childNode = {};
|
80
|
+
childNode[key] = item;
|
81
|
+
lastChild = this.element(childNode);
|
82
|
+
}
|
83
|
+
} else if (isObject(val)) {
|
84
|
+
lastChild = this.element(key);
|
85
|
+
lastChild.element(val);
|
86
|
+
} else {
|
87
|
+
lastChild = this.element(key, val);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
|
92
|
+
lastChild = this.text(text);
|
93
|
+
} else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
|
94
|
+
lastChild = this.cdata(text);
|
95
|
+
} else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
|
96
|
+
lastChild = this.comment(text);
|
97
|
+
} else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
|
98
|
+
lastChild = this.raw(text);
|
99
|
+
} else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
|
100
|
+
lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
|
101
|
+
} else {
|
102
|
+
lastChild = this.node(name, attributes, text);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
if (lastChild == null) {
|
106
|
+
throw new Error("Could not create any elements with: " + name);
|
107
|
+
}
|
108
|
+
return lastChild;
|
109
|
+
};
|
110
|
+
|
111
|
+
XMLNode.prototype.insertBefore = function(name, attributes, text) {
|
112
|
+
var child, i, removed;
|
113
|
+
if (this.isRoot) {
|
114
|
+
throw new Error("Cannot insert elements at root level");
|
115
|
+
}
|
116
|
+
i = this.parent.children.indexOf(this);
|
117
|
+
removed = this.parent.children.splice(i);
|
118
|
+
child = this.parent.element(name, attributes, text);
|
119
|
+
Array.prototype.push.apply(this.parent.children, removed);
|
120
|
+
return child;
|
121
|
+
};
|
122
|
+
|
123
|
+
XMLNode.prototype.insertAfter = function(name, attributes, text) {
|
124
|
+
var child, i, removed;
|
125
|
+
if (this.isRoot) {
|
126
|
+
throw new Error("Cannot insert elements at root level");
|
127
|
+
}
|
128
|
+
i = this.parent.children.indexOf(this);
|
129
|
+
removed = this.parent.children.splice(i + 1);
|
130
|
+
child = this.parent.element(name, attributes, text);
|
131
|
+
Array.prototype.push.apply(this.parent.children, removed);
|
132
|
+
return child;
|
133
|
+
};
|
134
|
+
|
135
|
+
XMLNode.prototype.remove = function() {
|
136
|
+
var i, ref1;
|
137
|
+
if (this.isRoot) {
|
138
|
+
throw new Error("Cannot remove the root element");
|
139
|
+
}
|
140
|
+
i = this.parent.children.indexOf(this);
|
141
|
+
[].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
|
142
|
+
return this.parent;
|
143
|
+
};
|
144
|
+
|
145
|
+
XMLNode.prototype.node = function(name, attributes, text) {
|
146
|
+
var child, ref1;
|
147
|
+
if (name != null) {
|
148
|
+
name = name.valueOf();
|
149
|
+
}
|
150
|
+
attributes || (attributes = {});
|
151
|
+
attributes = attributes.valueOf();
|
152
|
+
if (!isObject(attributes)) {
|
153
|
+
ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
|
154
|
+
}
|
155
|
+
child = new XMLElement(this, name, attributes);
|
156
|
+
if (text != null) {
|
157
|
+
child.text(text);
|
158
|
+
}
|
159
|
+
this.children.push(child);
|
160
|
+
return child;
|
161
|
+
};
|
162
|
+
|
163
|
+
XMLNode.prototype.text = function(value) {
|
164
|
+
var child;
|
165
|
+
child = new XMLText(this, value);
|
166
|
+
this.children.push(child);
|
167
|
+
return this;
|
168
|
+
};
|
169
|
+
|
170
|
+
XMLNode.prototype.cdata = function(value) {
|
171
|
+
var child;
|
172
|
+
child = new XMLCData(this, value);
|
173
|
+
this.children.push(child);
|
174
|
+
return this;
|
175
|
+
};
|
176
|
+
|
177
|
+
XMLNode.prototype.comment = function(value) {
|
178
|
+
var child;
|
179
|
+
child = new XMLComment(this, value);
|
180
|
+
this.children.push(child);
|
181
|
+
return this;
|
182
|
+
};
|
183
|
+
|
184
|
+
XMLNode.prototype.commentBefore = function(value) {
|
185
|
+
var child, i, removed;
|
186
|
+
i = this.parent.children.indexOf(this);
|
187
|
+
removed = this.parent.children.splice(i);
|
188
|
+
child = this.parent.comment(value);
|
189
|
+
Array.prototype.push.apply(this.parent.children, removed);
|
190
|
+
return this;
|
191
|
+
};
|
192
|
+
|
193
|
+
XMLNode.prototype.commentAfter = function(value) {
|
194
|
+
var child, i, removed;
|
195
|
+
i = this.parent.children.indexOf(this);
|
196
|
+
removed = this.parent.children.splice(i + 1);
|
197
|
+
child = this.parent.comment(value);
|
198
|
+
Array.prototype.push.apply(this.parent.children, removed);
|
199
|
+
return this;
|
200
|
+
};
|
201
|
+
|
202
|
+
XMLNode.prototype.raw = function(value) {
|
203
|
+
var child;
|
204
|
+
child = new XMLRaw(this, value);
|
205
|
+
this.children.push(child);
|
206
|
+
return this;
|
207
|
+
};
|
208
|
+
|
209
|
+
XMLNode.prototype.instruction = function(target, value) {
|
210
|
+
var insTarget, insValue, instruction, j, len;
|
211
|
+
if (target != null) {
|
212
|
+
target = target.valueOf();
|
213
|
+
}
|
214
|
+
if (value != null) {
|
215
|
+
value = value.valueOf();
|
216
|
+
}
|
217
|
+
if (Array.isArray(target)) {
|
218
|
+
for (j = 0, len = target.length; j < len; j++) {
|
219
|
+
insTarget = target[j];
|
220
|
+
this.instruction(insTarget);
|
221
|
+
}
|
222
|
+
} else if (isObject(target)) {
|
223
|
+
for (insTarget in target) {
|
224
|
+
if (!hasProp.call(target, insTarget)) continue;
|
225
|
+
insValue = target[insTarget];
|
226
|
+
this.instruction(insTarget, insValue);
|
227
|
+
}
|
228
|
+
} else {
|
229
|
+
if (isFunction(value)) {
|
230
|
+
value = value.apply();
|
231
|
+
}
|
232
|
+
instruction = new XMLProcessingInstruction(this, target, value);
|
233
|
+
this.children.push(instruction);
|
234
|
+
}
|
235
|
+
return this;
|
236
|
+
};
|
237
|
+
|
238
|
+
XMLNode.prototype.instructionBefore = function(target, value) {
|
239
|
+
var child, i, removed;
|
240
|
+
i = this.parent.children.indexOf(this);
|
241
|
+
removed = this.parent.children.splice(i);
|
242
|
+
child = this.parent.instruction(target, value);
|
243
|
+
Array.prototype.push.apply(this.parent.children, removed);
|
244
|
+
return this;
|
245
|
+
};
|
246
|
+
|
247
|
+
XMLNode.prototype.instructionAfter = function(target, value) {
|
248
|
+
var child, i, removed;
|
249
|
+
i = this.parent.children.indexOf(this);
|
250
|
+
removed = this.parent.children.splice(i + 1);
|
251
|
+
child = this.parent.instruction(target, value);
|
252
|
+
Array.prototype.push.apply(this.parent.children, removed);
|
253
|
+
return this;
|
254
|
+
};
|
255
|
+
|
256
|
+
XMLNode.prototype.declaration = function(version, encoding, standalone) {
|
257
|
+
var doc, xmldec;
|
258
|
+
doc = this.document();
|
259
|
+
xmldec = new XMLDeclaration(doc, version, encoding, standalone);
|
260
|
+
if (doc.children[0] instanceof XMLDeclaration) {
|
261
|
+
doc.children[0] = xmldec;
|
262
|
+
} else {
|
263
|
+
doc.children.unshift(xmldec);
|
264
|
+
}
|
265
|
+
return doc.root() || doc;
|
266
|
+
};
|
267
|
+
|
268
|
+
XMLNode.prototype.doctype = function(pubID, sysID) {
|
269
|
+
var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
|
270
|
+
doc = this.document();
|
271
|
+
doctype = new XMLDocType(doc, pubID, sysID);
|
272
|
+
ref1 = doc.children;
|
273
|
+
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
|
274
|
+
child = ref1[i];
|
275
|
+
if (child instanceof XMLDocType) {
|
276
|
+
doc.children[i] = doctype;
|
277
|
+
return doctype;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
ref2 = doc.children;
|
281
|
+
for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
|
282
|
+
child = ref2[i];
|
283
|
+
if (child.isRoot) {
|
284
|
+
doc.children.splice(i, 0, doctype);
|
285
|
+
return doctype;
|
286
|
+
}
|
287
|
+
}
|
288
|
+
doc.children.push(doctype);
|
289
|
+
return doctype;
|
290
|
+
};
|
291
|
+
|
292
|
+
XMLNode.prototype.up = function() {
|
293
|
+
if (this.isRoot) {
|
294
|
+
throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
|
295
|
+
}
|
296
|
+
return this.parent;
|
297
|
+
};
|
298
|
+
|
299
|
+
XMLNode.prototype.root = function() {
|
300
|
+
var node;
|
301
|
+
node = this;
|
302
|
+
while (node) {
|
303
|
+
if (node.isDocument) {
|
304
|
+
return node.rootObject;
|
305
|
+
} else if (node.isRoot) {
|
306
|
+
return node;
|
307
|
+
} else {
|
308
|
+
node = node.parent;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
};
|
312
|
+
|
313
|
+
XMLNode.prototype.document = function() {
|
314
|
+
var node;
|
315
|
+
node = this;
|
316
|
+
while (node) {
|
317
|
+
if (node.isDocument) {
|
318
|
+
return node;
|
319
|
+
} else {
|
320
|
+
node = node.parent;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
};
|
324
|
+
|
325
|
+
XMLNode.prototype.end = function(options) {
|
326
|
+
return this.document().end(options);
|
327
|
+
};
|
328
|
+
|
329
|
+
XMLNode.prototype.prev = function() {
|
330
|
+
var i;
|
331
|
+
i = this.parent.children.indexOf(this);
|
332
|
+
if (i < 1) {
|
333
|
+
throw new Error("Already at the first node");
|
334
|
+
}
|
335
|
+
return this.parent.children[i - 1];
|
336
|
+
};
|
337
|
+
|
338
|
+
XMLNode.prototype.next = function() {
|
339
|
+
var i;
|
340
|
+
i = this.parent.children.indexOf(this);
|
341
|
+
if (i === -1 || i === this.parent.children.length - 1) {
|
342
|
+
throw new Error("Already at the last node");
|
343
|
+
}
|
344
|
+
return this.parent.children[i + 1];
|
345
|
+
};
|
346
|
+
|
347
|
+
XMLNode.prototype.importDocument = function(doc) {
|
348
|
+
var clonedRoot;
|
349
|
+
clonedRoot = doc.root().clone();
|
350
|
+
clonedRoot.parent = this;
|
351
|
+
clonedRoot.isRoot = false;
|
352
|
+
this.children.push(clonedRoot);
|
353
|
+
return this;
|
354
|
+
};
|
355
|
+
|
356
|
+
XMLNode.prototype.ele = function(name, attributes, text) {
|
357
|
+
return this.element(name, attributes, text);
|
358
|
+
};
|
359
|
+
|
360
|
+
XMLNode.prototype.nod = function(name, attributes, text) {
|
361
|
+
return this.node(name, attributes, text);
|
362
|
+
};
|
363
|
+
|
364
|
+
XMLNode.prototype.txt = function(value) {
|
365
|
+
return this.text(value);
|
366
|
+
};
|
367
|
+
|
368
|
+
XMLNode.prototype.dat = function(value) {
|
369
|
+
return this.cdata(value);
|
370
|
+
};
|
371
|
+
|
372
|
+
XMLNode.prototype.com = function(value) {
|
373
|
+
return this.comment(value);
|
374
|
+
};
|
375
|
+
|
376
|
+
XMLNode.prototype.ins = function(target, value) {
|
377
|
+
return this.instruction(target, value);
|
378
|
+
};
|
379
|
+
|
380
|
+
XMLNode.prototype.doc = function() {
|
381
|
+
return this.document();
|
382
|
+
};
|
383
|
+
|
384
|
+
XMLNode.prototype.dec = function(version, encoding, standalone) {
|
385
|
+
return this.declaration(version, encoding, standalone);
|
386
|
+
};
|
387
|
+
|
388
|
+
XMLNode.prototype.dtd = function(pubID, sysID) {
|
389
|
+
return this.doctype(pubID, sysID);
|
390
|
+
};
|
391
|
+
|
392
|
+
XMLNode.prototype.e = function(name, attributes, text) {
|
393
|
+
return this.element(name, attributes, text);
|
394
|
+
};
|
395
|
+
|
396
|
+
XMLNode.prototype.n = function(name, attributes, text) {
|
397
|
+
return this.node(name, attributes, text);
|
398
|
+
};
|
399
|
+
|
400
|
+
XMLNode.prototype.t = function(value) {
|
401
|
+
return this.text(value);
|
402
|
+
};
|
403
|
+
|
404
|
+
XMLNode.prototype.d = function(value) {
|
405
|
+
return this.cdata(value);
|
406
|
+
};
|
407
|
+
|
408
|
+
XMLNode.prototype.c = function(value) {
|
409
|
+
return this.comment(value);
|
410
|
+
};
|
411
|
+
|
412
|
+
XMLNode.prototype.r = function(value) {
|
413
|
+
return this.raw(value);
|
414
|
+
};
|
415
|
+
|
416
|
+
XMLNode.prototype.i = function(target, value) {
|
417
|
+
return this.instruction(target, value);
|
418
|
+
};
|
419
|
+
|
420
|
+
XMLNode.prototype.u = function() {
|
421
|
+
return this.up();
|
422
|
+
};
|
423
|
+
|
424
|
+
XMLNode.prototype.importXMLBuilder = function(doc) {
|
425
|
+
return this.importDocument(doc);
|
426
|
+
};
|
427
|
+
|
428
|
+
return XMLNode;
|
429
|
+
|
430
|
+
})();
|
431
|
+
|
432
|
+
}).call(this);
|