rhack 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/CURB-LICENSE +51 -0
- data/Gemfile +4 -0
- data/History.txt +4 -0
- data/LICENSE +51 -0
- data/License.txt +17 -0
- data/Manifest.txt +61 -0
- data/README.txt +12 -0
- data/Rakefile +34 -0
- data/ext/curb-original/curb.c +977 -0
- data/ext/curb-original/curb.h +52 -0
- data/ext/curb-original/curb_config.h +235 -0
- data/ext/curb-original/curb_easy.c +3455 -0
- data/ext/curb-original/curb_easy.h +90 -0
- data/ext/curb-original/curb_errors.c +647 -0
- data/ext/curb-original/curb_errors.h +129 -0
- data/ext/curb-original/curb_macros.h +159 -0
- data/ext/curb-original/curb_multi.c +704 -0
- data/ext/curb-original/curb_multi.h +26 -0
- data/ext/curb-original/curb_postfield.c +523 -0
- data/ext/curb-original/curb_postfield.h +40 -0
- data/ext/curb-original/curb_upload.c +80 -0
- data/ext/curb-original/curb_upload.h +30 -0
- data/ext/curb/Makefile +157 -0
- data/ext/curb/curb.c +977 -0
- data/ext/curb/curb.h +52 -0
- data/ext/curb/curb_config.h +235 -0
- data/ext/curb/curb_easy.c +3430 -0
- data/ext/curb/curb_easy.h +94 -0
- data/ext/curb/curb_errors.c +647 -0
- data/ext/curb/curb_errors.h +129 -0
- data/ext/curb/curb_macros.h +159 -0
- data/ext/curb/curb_multi.c +710 -0
- data/ext/curb/curb_multi.h +26 -0
- data/ext/curb/curb_postfield.c +523 -0
- data/ext/curb/curb_postfield.h +40 -0
- data/ext/curb/curb_upload.c +80 -0
- data/ext/curb/curb_upload.h +30 -0
- data/ext/curb/extconf.rb +399 -0
- data/lib/cache.rb +44 -0
- data/lib/curl-global.rb +151 -0
- data/lib/extensions/browser/env.js +697 -0
- data/lib/extensions/browser/jquery.js +7180 -0
- data/lib/extensions/browser/xmlsax.js +1564 -0
- data/lib/extensions/browser/xmlw3cdom_1.js +1444 -0
- data/lib/extensions/browser/xmlw3cdom_2.js +2744 -0
- data/lib/extensions/curb.rb +125 -0
- data/lib/extensions/declarative.rb +153 -0
- data/lib/extensions/johnson.rb +63 -0
- data/lib/frame.rb +766 -0
- data/lib/init.rb +36 -0
- data/lib/rhack.rb +16 -0
- data/lib/rhack.yml.template +19 -0
- data/lib/rhack/proxy/checker.rb +226 -0
- data/lib/rhack/proxy/list.rb +196 -0
- data/lib/rhack/services.rb +445 -0
- data/lib/rhack_in.rb +2 -0
- data/lib/scout.rb +591 -0
- data/lib/words.rb +37 -0
- data/test/test_frame.rb +107 -0
- data/test/test_rhack.rb +5 -0
- data/test/test_scout.rb +53 -0
- metadata +195 -0
@@ -0,0 +1,2744 @@
|
|
1
|
+
/**
|
2
|
+
* @method W3CDOMNamespaceNodeMap.toString - Serialize this NamespaceNodeMap into an XML string
|
3
|
+
*
|
4
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
5
|
+
*
|
6
|
+
* @return : string
|
7
|
+
*/
|
8
|
+
W3CDOMNamespaceNodeMap.prototype.toString = function W3CDOMNamespaceNodeMap_toString() {
|
9
|
+
var ret = "";
|
10
|
+
|
11
|
+
// identify namespaces declared local to this Element (ie, not inherited)
|
12
|
+
for (var ind = 0; ind < this._nodes.length; ind++) {
|
13
|
+
// if namespace declaration does not exist in the containing node's, parentNode's namespaces
|
14
|
+
var ns = null;
|
15
|
+
try {
|
16
|
+
var ns = this.parentNode.parentNode._namespaces.getNamedItem(this._nodes[ind].localName);
|
17
|
+
}
|
18
|
+
catch (e) {
|
19
|
+
//breaking to prevent default namespace being inserted into return value
|
20
|
+
break;
|
21
|
+
}
|
22
|
+
if (!(ns && (""+ ns.nodeValue == ""+ this._nodes[ind].nodeValue))) {
|
23
|
+
// display the namespace declaration
|
24
|
+
ret += this._nodes[ind].toString() +" ";
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
return ret;
|
29
|
+
};
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @class W3CDOMNode - The Node interface is the primary datatype for the entire Document Object Model.
|
33
|
+
* It represents a single node in the document tree.
|
34
|
+
*
|
35
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
36
|
+
*
|
37
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
38
|
+
*/
|
39
|
+
W3CDOMNode = function(ownerDocument) {
|
40
|
+
this._class = addClass(this._class, "W3CDOMNode");
|
41
|
+
|
42
|
+
if (ownerDocument) {
|
43
|
+
this._id = ownerDocument._genId(); // generate unique internal id
|
44
|
+
}
|
45
|
+
|
46
|
+
this.namespaceURI = ""; // The namespace URI of this node (Level 2)
|
47
|
+
this.prefix = ""; // The namespace prefix of this node (Level 2)
|
48
|
+
this.localName = ""; // The localName of this node (Level 2)
|
49
|
+
|
50
|
+
this.nodeName = ""; // The name of this node
|
51
|
+
this.nodeValue = ""; // The value of this node
|
52
|
+
this.nodeType = 0; // A code representing the type of the underlying object
|
53
|
+
|
54
|
+
// The parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent.
|
55
|
+
// However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null
|
56
|
+
this.parentNode = null;
|
57
|
+
|
58
|
+
// A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.
|
59
|
+
// The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object
|
60
|
+
// that it was created from are immediately reflected in the nodes returned by the NodeList accessors;
|
61
|
+
// it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method.
|
62
|
+
this.childNodes = new W3CDOMNodeList(ownerDocument, this);
|
63
|
+
|
64
|
+
this.firstChild = null; // The first child of this node. If there is no such node, this is null
|
65
|
+
this.lastChild = null; // The last child of this node. If there is no such node, this is null.
|
66
|
+
this.previousSibling = null; // The node immediately preceding this node. If there is no such node, this is null.
|
67
|
+
this.nextSibling = null; // The node immediately following this node. If there is no such node, this is null.
|
68
|
+
|
69
|
+
this.attributes = new W3CDOMNamedNodeMap(ownerDocument, this); // A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
|
70
|
+
this.ownerDocument = ownerDocument; // The Document object associated with this node
|
71
|
+
this._namespaces = new W3CDOMNamespaceNodeMap(ownerDocument, this); // The namespaces in scope for this node
|
72
|
+
|
73
|
+
this._readonly = false;
|
74
|
+
};
|
75
|
+
|
76
|
+
// nodeType constants
|
77
|
+
W3CDOMNode.ELEMENT_NODE = 1;
|
78
|
+
W3CDOMNode.ATTRIBUTE_NODE = 2;
|
79
|
+
W3CDOMNode.TEXT_NODE = 3;
|
80
|
+
W3CDOMNode.CDATA_SECTION_NODE = 4;
|
81
|
+
W3CDOMNode.ENTITY_REFERENCE_NODE = 5;
|
82
|
+
W3CDOMNode.ENTITY_NODE = 6;
|
83
|
+
W3CDOMNode.PROCESSING_INSTRUCTION_NODE = 7;
|
84
|
+
W3CDOMNode.COMMENT_NODE = 8;
|
85
|
+
W3CDOMNode.DOCUMENT_NODE = 9;
|
86
|
+
W3CDOMNode.DOCUMENT_TYPE_NODE = 10;
|
87
|
+
W3CDOMNode.DOCUMENT_FRAGMENT_NODE = 11;
|
88
|
+
W3CDOMNode.NOTATION_NODE = 12;
|
89
|
+
W3CDOMNode.NAMESPACE_NODE = 13;
|
90
|
+
|
91
|
+
/**
|
92
|
+
* @method W3CDOMNode.hasAttributes
|
93
|
+
*
|
94
|
+
* @author Jon van Noort (jon@webarcana.com.au) & David Joham (djoham@yahoo.com)
|
95
|
+
*
|
96
|
+
* @return : boolean
|
97
|
+
*/
|
98
|
+
W3CDOMNode.prototype.hasAttributes = function W3CDOMNode_hasAttributes() {
|
99
|
+
if (this.attributes.length == 0) {
|
100
|
+
return false;
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
return true;
|
104
|
+
}
|
105
|
+
};
|
106
|
+
|
107
|
+
/**
|
108
|
+
* @method W3CDOMNode.getNodeName - Java style gettor for .nodeName
|
109
|
+
*
|
110
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
111
|
+
*
|
112
|
+
* @return : string
|
113
|
+
*/
|
114
|
+
W3CDOMNode.prototype.getNodeName = function W3CDOMNode_getNodeName() {
|
115
|
+
return this.nodeName;
|
116
|
+
};
|
117
|
+
|
118
|
+
/**
|
119
|
+
* @method W3CDOMNode.getNodeValue - Java style gettor for .NodeValue
|
120
|
+
*
|
121
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
122
|
+
*
|
123
|
+
* @return : string
|
124
|
+
*/
|
125
|
+
W3CDOMNode.prototype.getNodeValue = function W3CDOMNode_getNodeValue() {
|
126
|
+
return this.nodeValue;
|
127
|
+
};
|
128
|
+
|
129
|
+
/**
|
130
|
+
* @method W3CDOMNode.setNodeValue - Java style settor for .NodeValue
|
131
|
+
*
|
132
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
133
|
+
*
|
134
|
+
* @param nodeValue : string - unique internal id
|
135
|
+
*/
|
136
|
+
W3CDOMNode.prototype.setNodeValue = function W3CDOMNode_setNodeValue(nodeValue) {
|
137
|
+
// throw Exception if W3CDOMNode is readonly
|
138
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
139
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
140
|
+
}
|
141
|
+
|
142
|
+
this.nodeValue = nodeValue;
|
143
|
+
};
|
144
|
+
|
145
|
+
/**
|
146
|
+
* @method W3CDOMNode.getNodeType - Java style gettor for .nodeType
|
147
|
+
*
|
148
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
149
|
+
*
|
150
|
+
* @return : int
|
151
|
+
*/
|
152
|
+
W3CDOMNode.prototype.getNodeType = function W3CDOMNode_getNodeType() {
|
153
|
+
return this.nodeType;
|
154
|
+
};
|
155
|
+
|
156
|
+
/**
|
157
|
+
* @method W3CDOMNode.getParentNode - Java style gettor for .parentNode
|
158
|
+
*
|
159
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
160
|
+
*
|
161
|
+
* @return : W3CDOMNode
|
162
|
+
*/
|
163
|
+
W3CDOMNode.prototype.getParentNode = function W3CDOMNode_getParentNode() {
|
164
|
+
return this.parentNode;
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* @method W3CDOMNode.getChildNodes - Java style gettor for .childNodes
|
169
|
+
*
|
170
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
171
|
+
*
|
172
|
+
* @return : W3CDOMNodeList
|
173
|
+
*/
|
174
|
+
W3CDOMNode.prototype.getChildNodes = function W3CDOMNode_getChildNodes() {
|
175
|
+
return this.childNodes;
|
176
|
+
};
|
177
|
+
|
178
|
+
/**
|
179
|
+
* @method W3CDOMNode.getFirstChild - Java style gettor for .firstChild
|
180
|
+
*
|
181
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
182
|
+
*
|
183
|
+
* @return : W3CDOMNode
|
184
|
+
*/
|
185
|
+
W3CDOMNode.prototype.getFirstChild = function W3CDOMNode_getFirstChild() {
|
186
|
+
return this.firstChild;
|
187
|
+
};
|
188
|
+
|
189
|
+
/**
|
190
|
+
* @method W3CDOMNode.getLastChild - Java style gettor for .lastChild
|
191
|
+
*
|
192
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
193
|
+
*
|
194
|
+
* @return : W3CDOMNode
|
195
|
+
*/
|
196
|
+
W3CDOMNode.prototype.getLastChild = function W3CDOMNode_getLastChild() {
|
197
|
+
return this.lastChild;
|
198
|
+
};
|
199
|
+
|
200
|
+
/**
|
201
|
+
* @method W3CDOMNode.getPreviousSibling - Java style gettor for .previousSibling
|
202
|
+
*
|
203
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
204
|
+
*
|
205
|
+
* @return : W3CDOMNode
|
206
|
+
*/
|
207
|
+
W3CDOMNode.prototype.getPreviousSibling = function W3CDOMNode_getPreviousSibling() {
|
208
|
+
return this.previousSibling;
|
209
|
+
};
|
210
|
+
|
211
|
+
/**
|
212
|
+
* @method W3CDOMNode.getNextSibling - Java style gettor for .nextSibling
|
213
|
+
*
|
214
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
215
|
+
*
|
216
|
+
* @return : W3CDOMNode
|
217
|
+
*/
|
218
|
+
W3CDOMNode.prototype.getNextSibling = function W3CDOMNode_getNextSibling() {
|
219
|
+
return this.nextSibling;
|
220
|
+
};
|
221
|
+
|
222
|
+
/**
|
223
|
+
* @method W3CDOMNode.getAttributes - Java style gettor for .attributes
|
224
|
+
*
|
225
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
226
|
+
*
|
227
|
+
* @return : W3CDOMNamedNodeList
|
228
|
+
*/
|
229
|
+
W3CDOMNode.prototype.getAttributes = function W3CDOMNode_getAttributes() {
|
230
|
+
return this.attributes;
|
231
|
+
};
|
232
|
+
|
233
|
+
/**
|
234
|
+
* @method W3CDOMNode.getOwnerDocument - Java style gettor for .ownerDocument
|
235
|
+
*
|
236
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
237
|
+
*
|
238
|
+
* @return : W3CDOMDocument
|
239
|
+
*/
|
240
|
+
W3CDOMNode.prototype.getOwnerDocument = function W3CDOMNode_getOwnerDocument() {
|
241
|
+
return this.ownerDocument;
|
242
|
+
};
|
243
|
+
|
244
|
+
/**
|
245
|
+
* @method W3CDOMNode.getNamespaceURI - Java style gettor for .namespaceURI
|
246
|
+
*
|
247
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
248
|
+
*
|
249
|
+
* @return : String
|
250
|
+
*/
|
251
|
+
W3CDOMNode.prototype.getNamespaceURI = function W3CDOMNode_getNamespaceURI() {
|
252
|
+
return this.namespaceURI;
|
253
|
+
};
|
254
|
+
|
255
|
+
/**
|
256
|
+
* @method W3CDOMNode.getPrefix - Java style gettor for .prefix
|
257
|
+
*
|
258
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
259
|
+
*
|
260
|
+
* @return : String
|
261
|
+
*/
|
262
|
+
W3CDOMNode.prototype.getPrefix = function W3CDOMNode_getPrefix() {
|
263
|
+
return this.prefix;
|
264
|
+
};
|
265
|
+
|
266
|
+
/**
|
267
|
+
* @method W3CDOMNode.setPrefix - Java style settor for .prefix
|
268
|
+
*
|
269
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
270
|
+
*
|
271
|
+
* @param prefix : String
|
272
|
+
*
|
273
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly.
|
274
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
275
|
+
* @throws : W3CDOMException - NAMESPACE_ERR: Raised if the Namespace is invalid
|
276
|
+
*
|
277
|
+
*/
|
278
|
+
W3CDOMNode.prototype.setPrefix = function W3CDOMNode_setPrefix(prefix) {
|
279
|
+
// test for exceptions
|
280
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
281
|
+
// throw Exception if W3CDOMNode is readonly
|
282
|
+
if (this._readonly) {
|
283
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
284
|
+
}
|
285
|
+
|
286
|
+
// throw Exception if the prefix string contains an illegal character
|
287
|
+
if (!this.ownerDocument.implementation._isValidName(prefix)) {
|
288
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
289
|
+
}
|
290
|
+
|
291
|
+
// throw Exception if the Namespace is invalid;
|
292
|
+
// if the specified prefix is malformed,
|
293
|
+
// if the namespaceURI of this node is null,
|
294
|
+
// if the specified prefix is "xml" and the namespaceURI of this node is
|
295
|
+
// different from "http://www.w3.org/XML/1998/namespace",
|
296
|
+
if (!this.ownerDocument._isValidNamespace(this.namespaceURI, prefix +":"+ this.localName)) {
|
297
|
+
throw(new W3CDOMException(W3CDOMException.NAMESPACE_ERR));
|
298
|
+
}
|
299
|
+
|
300
|
+
// throw Exception if we are trying to make the attribute look like a namespace declaration;
|
301
|
+
// if this node is an attribute and the specified prefix is "xmlns"
|
302
|
+
// and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/",
|
303
|
+
if ((prefix == "xmlns") && (this.namespaceURI != "http://www.w3.org/2000/xmlns/")) {
|
304
|
+
throw(new W3CDOMException(W3CDOMException.NAMESPACE_ERR));
|
305
|
+
}
|
306
|
+
|
307
|
+
// throw Exception if we are trying to make the attribute look like a default namespace declaration;
|
308
|
+
// if this node is an attribute and the qualifiedName of this node is "xmlns" [Namespaces].
|
309
|
+
if ((prefix == "") && (this.localName == "xmlns")) {
|
310
|
+
throw(new W3CDOMException(W3CDOMException.NAMESPACE_ERR));
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
// update prefix
|
315
|
+
this.prefix = prefix;
|
316
|
+
|
317
|
+
// update nodeName (QName)
|
318
|
+
if (this.prefix != "") {
|
319
|
+
this.nodeName = this.prefix +":"+ this.localName;
|
320
|
+
}
|
321
|
+
else {
|
322
|
+
this.nodeName = this.localName; // no prefix, therefore nodeName is simply localName
|
323
|
+
}
|
324
|
+
};
|
325
|
+
|
326
|
+
/**
|
327
|
+
* @method W3CDOMNode.getLocalName - Java style gettor for .localName
|
328
|
+
*
|
329
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
330
|
+
*
|
331
|
+
* @return : String
|
332
|
+
*/
|
333
|
+
W3CDOMNode.prototype.getLocalName = function W3CDOMNode_getLocalName() {
|
334
|
+
return this.localName;
|
335
|
+
};
|
336
|
+
|
337
|
+
/**
|
338
|
+
* @method W3CDOMNode.insertBefore - Inserts the node newChild before the existing child node refChild.
|
339
|
+
* If refChild is null, insert newChild at the end of the list of children.
|
340
|
+
*
|
341
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
342
|
+
*
|
343
|
+
* @param newChild : W3CDOMNode - The node to insert.
|
344
|
+
* @param refChild : W3CDOMNode - The reference node, i.e., the node before which the new node must be inserted
|
345
|
+
*
|
346
|
+
* @throws : W3CDOMException - HIERARCHY_REQUEST_ERR: Raised if the node to insert is one of this node's ancestors
|
347
|
+
* @throws : W3CDOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
|
348
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly.
|
349
|
+
* @throws : W3CDOMException - NOT_FOUND_ERR: Raised if there is no node named name in this map.
|
350
|
+
*
|
351
|
+
* @return : W3CDOMNode - The node being inserted.
|
352
|
+
*/
|
353
|
+
W3CDOMNode.prototype.insertBefore = function W3CDOMNode_insertBefore(newChild, refChild) {
|
354
|
+
var prevNode;
|
355
|
+
|
356
|
+
// test for exceptions
|
357
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
358
|
+
// throw Exception if W3CDOMNode is readonly
|
359
|
+
if (this._readonly) {
|
360
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
361
|
+
}
|
362
|
+
|
363
|
+
// throw Exception if newChild was not created by this Document
|
364
|
+
if (this.ownerDocument != newChild.ownerDocument) {
|
365
|
+
throw(new W3CDOMException(W3CDOMException.WRONG_DOCUMENT_ERR));
|
366
|
+
}
|
367
|
+
|
368
|
+
// throw Exception if the node is an ancestor
|
369
|
+
if (this._isAncestor(newChild)) {
|
370
|
+
throw(new W3CDOMException(W3CDOMException.HIERARCHY_REQUEST_ERR));
|
371
|
+
}
|
372
|
+
}
|
373
|
+
|
374
|
+
if (refChild) { // if refChild is specified, insert before it
|
375
|
+
// find index of refChild
|
376
|
+
var itemIndex = this.childNodes._findItemIndex(refChild._id);
|
377
|
+
|
378
|
+
// throw Exception if there is no child node with this id
|
379
|
+
if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) {
|
380
|
+
throw(new W3CDOMException(W3CDOMException.NOT_FOUND_ERR));
|
381
|
+
}
|
382
|
+
|
383
|
+
// if the newChild is already in the tree,
|
384
|
+
var newChildParent = newChild.parentNode;
|
385
|
+
if (newChildParent) {
|
386
|
+
// remove it
|
387
|
+
newChildParent.removeChild(newChild);
|
388
|
+
}
|
389
|
+
|
390
|
+
// insert newChild into childNodes
|
391
|
+
this.childNodes._insertBefore(newChild, this.childNodes._findItemIndex(refChild._id));
|
392
|
+
|
393
|
+
// do node pointer surgery
|
394
|
+
prevNode = refChild.previousSibling;
|
395
|
+
|
396
|
+
// handle DocumentFragment
|
397
|
+
if (newChild.nodeType == W3CDOMNode.DOCUMENT_FRAGMENT_NODE) {
|
398
|
+
if (newChild.childNodes._nodes.length > 0) {
|
399
|
+
// set the parentNode of DocumentFragment's children
|
400
|
+
for (var ind = 0; ind < newChild.childNodes._nodes.length; ind++) {
|
401
|
+
newChild.childNodes._nodes[ind].parentNode = this;
|
402
|
+
}
|
403
|
+
|
404
|
+
// link refChild to last child of DocumentFragment
|
405
|
+
refChild.previousSibling = newChild.childNodes._nodes[newChild.childNodes._nodes.length-1];
|
406
|
+
}
|
407
|
+
}
|
408
|
+
else {
|
409
|
+
newChild.parentNode = this; // set the parentNode of the newChild
|
410
|
+
refChild.previousSibling = newChild; // link refChild to newChild
|
411
|
+
}
|
412
|
+
}
|
413
|
+
else { // otherwise, append to end
|
414
|
+
prevNode = this.lastChild;
|
415
|
+
this.appendChild(newChild);
|
416
|
+
}
|
417
|
+
|
418
|
+
if (newChild.nodeType == W3CDOMNode.DOCUMENT_FRAGMENT_NODE) {
|
419
|
+
// do node pointer surgery for DocumentFragment
|
420
|
+
if (newChild.childNodes._nodes.length > 0) {
|
421
|
+
if (prevNode) {
|
422
|
+
prevNode.nextSibling = newChild.childNodes._nodes[0];
|
423
|
+
}
|
424
|
+
else { // this is the first child in the list
|
425
|
+
this.firstChild = newChild.childNodes._nodes[0];
|
426
|
+
}
|
427
|
+
|
428
|
+
newChild.childNodes._nodes[0].previousSibling = prevNode;
|
429
|
+
newChild.childNodes._nodes[newChild.childNodes._nodes.length-1].nextSibling = refChild;
|
430
|
+
}
|
431
|
+
}
|
432
|
+
else {
|
433
|
+
// do node pointer surgery for newChild
|
434
|
+
if (prevNode) {
|
435
|
+
prevNode.nextSibling = newChild;
|
436
|
+
}
|
437
|
+
else { // this is the first child in the list
|
438
|
+
this.firstChild = newChild;
|
439
|
+
}
|
440
|
+
|
441
|
+
newChild.previousSibling = prevNode;
|
442
|
+
newChild.nextSibling = refChild;
|
443
|
+
}
|
444
|
+
|
445
|
+
return newChild;
|
446
|
+
};
|
447
|
+
|
448
|
+
/**
|
449
|
+
* @method W3CDOMNode.replaceChild - Replaces the child node oldChild with newChild in the list of children,
|
450
|
+
* and returns the oldChild node.
|
451
|
+
* If the newChild is already in the tree, it is first removed.
|
452
|
+
*
|
453
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
454
|
+
*
|
455
|
+
* @param newChild : W3CDOMNode - The node to insert.
|
456
|
+
* @param oldChild : W3CDOMNode - The node being replaced in the list.
|
457
|
+
*
|
458
|
+
* @throws : W3CDOMException - HIERARCHY_REQUEST_ERR: Raised if the node to insert is one of this node's ancestors
|
459
|
+
* @throws : W3CDOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
|
460
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly.
|
461
|
+
* @throws : W3CDOMException - NOT_FOUND_ERR: Raised if there is no node named name in this map.
|
462
|
+
*
|
463
|
+
* @return : W3CDOMNode - The node that was replaced
|
464
|
+
*/
|
465
|
+
W3CDOMNode.prototype.replaceChild = function W3CDOMNode_replaceChild(newChild, oldChild) {
|
466
|
+
var ret = null;
|
467
|
+
|
468
|
+
// test for exceptions
|
469
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
470
|
+
// throw Exception if W3CDOMNode is readonly
|
471
|
+
if (this._readonly) {
|
472
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
473
|
+
}
|
474
|
+
|
475
|
+
// throw Exception if newChild was not created by this Document
|
476
|
+
if (this.ownerDocument != newChild.ownerDocument) {
|
477
|
+
throw(new W3CDOMException(W3CDOMException.WRONG_DOCUMENT_ERR));
|
478
|
+
}
|
479
|
+
|
480
|
+
// throw Exception if the node is an ancestor
|
481
|
+
if (this._isAncestor(newChild)) {
|
482
|
+
throw(new W3CDOMException(W3CDOMException.HIERARCHY_REQUEST_ERR));
|
483
|
+
}
|
484
|
+
}
|
485
|
+
|
486
|
+
// get index of oldChild
|
487
|
+
var index = this.childNodes._findItemIndex(oldChild._id);
|
488
|
+
|
489
|
+
// throw Exception if there is no child node with this id
|
490
|
+
if (this.ownerDocument.implementation.errorChecking && (index < 0)) {
|
491
|
+
throw(new W3CDOMException(W3CDOMException.NOT_FOUND_ERR));
|
492
|
+
}
|
493
|
+
|
494
|
+
// if the newChild is already in the tree,
|
495
|
+
var newChildParent = newChild.parentNode;
|
496
|
+
if (newChildParent) {
|
497
|
+
// remove it
|
498
|
+
newChildParent.removeChild(newChild);
|
499
|
+
}
|
500
|
+
|
501
|
+
// add newChild to childNodes
|
502
|
+
ret = this.childNodes._replaceChild(newChild, index);
|
503
|
+
|
504
|
+
|
505
|
+
if (newChild.nodeType == W3CDOMNode.DOCUMENT_FRAGMENT_NODE) {
|
506
|
+
// do node pointer surgery for Document Fragment
|
507
|
+
if (newChild.childNodes._nodes.length > 0) {
|
508
|
+
for (var ind = 0; ind < newChild.childNodes._nodes.length; ind++) {
|
509
|
+
newChild.childNodes._nodes[ind].parentNode = this;
|
510
|
+
}
|
511
|
+
|
512
|
+
if (oldChild.previousSibling) {
|
513
|
+
oldChild.previousSibling.nextSibling = newChild.childNodes._nodes[0];
|
514
|
+
}
|
515
|
+
else {
|
516
|
+
this.firstChild = newChild.childNodes._nodes[0];
|
517
|
+
}
|
518
|
+
|
519
|
+
if (oldChild.nextSibling) {
|
520
|
+
oldChild.nextSibling.previousSibling = newChild;
|
521
|
+
}
|
522
|
+
else {
|
523
|
+
this.lastChild = newChild.childNodes._nodes[newChild.childNodes._nodes.length-1];
|
524
|
+
}
|
525
|
+
|
526
|
+
newChild.childNodes._nodes[0].previousSibling = oldChild.previousSibling;
|
527
|
+
newChild.childNodes._nodes[newChild.childNodes._nodes.length-1].nextSibling = oldChild.nextSibling;
|
528
|
+
}
|
529
|
+
}
|
530
|
+
else {
|
531
|
+
// do node pointer surgery for newChild
|
532
|
+
newChild.parentNode = this;
|
533
|
+
|
534
|
+
if (oldChild.previousSibling) {
|
535
|
+
oldChild.previousSibling.nextSibling = newChild;
|
536
|
+
}
|
537
|
+
else {
|
538
|
+
this.firstChild = newChild;
|
539
|
+
}
|
540
|
+
if (oldChild.nextSibling) {
|
541
|
+
oldChild.nextSibling.previousSibling = newChild;
|
542
|
+
}
|
543
|
+
else {
|
544
|
+
this.lastChild = newChild;
|
545
|
+
}
|
546
|
+
newChild.previousSibling = oldChild.previousSibling;
|
547
|
+
newChild.nextSibling = oldChild.nextSibling;
|
548
|
+
}
|
549
|
+
return ret;
|
550
|
+
};
|
551
|
+
|
552
|
+
/**
|
553
|
+
* @method W3CDOMNode.removeChild - Removes the child node indicated by oldChild from the list of children, and returns it.
|
554
|
+
*
|
555
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
556
|
+
*
|
557
|
+
* @param oldChild : W3CDOMNode - The node being removed.
|
558
|
+
*
|
559
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly.
|
560
|
+
* @throws : W3CDOMException - NOT_FOUND_ERR: Raised if there is no node named name in this map.
|
561
|
+
*
|
562
|
+
* @return : W3CDOMNode - The node being removed.
|
563
|
+
*/
|
564
|
+
W3CDOMNode.prototype.removeChild = function W3CDOMNode_removeChild(oldChild) {
|
565
|
+
// throw Exception if W3CDOMNamedNodeMap is readonly
|
566
|
+
if (this.ownerDocument.implementation.errorChecking && (this._readonly || oldChild._readonly)) {
|
567
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
568
|
+
}
|
569
|
+
|
570
|
+
// get index of oldChild
|
571
|
+
var itemIndex = this.childNodes._findItemIndex(oldChild._id);
|
572
|
+
|
573
|
+
// throw Exception if there is no child node with this id
|
574
|
+
if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) {
|
575
|
+
throw(new W3CDOMException(W3CDOMException.NOT_FOUND_ERR));
|
576
|
+
}
|
577
|
+
|
578
|
+
// remove oldChild from childNodes
|
579
|
+
this.childNodes._removeChild(itemIndex);
|
580
|
+
|
581
|
+
// do node pointer surgery
|
582
|
+
oldChild.parentNode = null;
|
583
|
+
|
584
|
+
if (oldChild.previousSibling) {
|
585
|
+
oldChild.previousSibling.nextSibling = oldChild.nextSibling;
|
586
|
+
}
|
587
|
+
else {
|
588
|
+
this.firstChild = oldChild.nextSibling;
|
589
|
+
}
|
590
|
+
if (oldChild.nextSibling) {
|
591
|
+
oldChild.nextSibling.previousSibling = oldChild.previousSibling;
|
592
|
+
}
|
593
|
+
else {
|
594
|
+
this.lastChild = oldChild.previousSibling;
|
595
|
+
}
|
596
|
+
|
597
|
+
oldChild.previousSibling = null;
|
598
|
+
oldChild.nextSibling = null;
|
599
|
+
return oldChild;
|
600
|
+
};
|
601
|
+
|
602
|
+
/**
|
603
|
+
* @method W3CDOMNode.appendChild - Adds the node newChild to the end of the list of children of this node.
|
604
|
+
* If the newChild is already in the tree, it is first removed.
|
605
|
+
*
|
606
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
607
|
+
*
|
608
|
+
* @param newChild : W3CDOMNode - The node to add
|
609
|
+
*
|
610
|
+
* @throws : W3CDOMException - HIERARCHY_REQUEST_ERR: Raised if the node to insert is one of this node's ancestors
|
611
|
+
* @throws : W3CDOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
|
612
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly.
|
613
|
+
*
|
614
|
+
* @return : W3CDOMNode - The node added
|
615
|
+
*/
|
616
|
+
W3CDOMNode.prototype.appendChild = function W3CDOMNode_appendChild(newChild) {
|
617
|
+
// test for exceptions
|
618
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
619
|
+
// throw Exception if Node is readonly
|
620
|
+
if (this._readonly) {
|
621
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
622
|
+
}
|
623
|
+
|
624
|
+
// throw Exception if arg was not created by this Document
|
625
|
+
if (this.ownerDocument != newChild.ownerDocument) {
|
626
|
+
throw(new W3CDOMException(W3CDOMException.WRONG_DOCUMENT_ERR));
|
627
|
+
}
|
628
|
+
|
629
|
+
// throw Exception if the node is an ancestor
|
630
|
+
if (this._isAncestor(newChild)) {
|
631
|
+
throw(new W3CDOMException(W3CDOMException.HIERARCHY_REQUEST_ERR));
|
632
|
+
}
|
633
|
+
}
|
634
|
+
|
635
|
+
// if the newChild is already in the tree,
|
636
|
+
var newChildParent = newChild.parentNode;
|
637
|
+
if (newChildParent) {
|
638
|
+
// remove it
|
639
|
+
newChildParent.removeChild(newChild);
|
640
|
+
}
|
641
|
+
|
642
|
+
// add newChild to childNodes
|
643
|
+
this.childNodes._appendChild(newChild);
|
644
|
+
|
645
|
+
if (newChild.nodeType == W3CDOMNode.DOCUMENT_FRAGMENT_NODE) {
|
646
|
+
// do node pointer surgery for DocumentFragment
|
647
|
+
if (newChild.childNodes._nodes.length > 0) {
|
648
|
+
for (var ind = 0; ind < newChild.childNodes._nodes.length; ind++) {
|
649
|
+
newChild.childNodes._nodes[ind].parentNode = this;
|
650
|
+
}
|
651
|
+
|
652
|
+
if (this.lastChild) {
|
653
|
+
this.lastChild.nextSibling = newChild.childNodes._nodes[0];
|
654
|
+
newChild.childNodes._nodes[0].previousSibling = this.lastChild;
|
655
|
+
this.lastChild = newChild.childNodes._nodes[newChild.childNodes._nodes.length-1];
|
656
|
+
}
|
657
|
+
else {
|
658
|
+
this.lastChild = newChild.childNodes._nodes[newChild.childNodes._nodes.length-1];
|
659
|
+
this.firstChild = newChild.childNodes._nodes[0];
|
660
|
+
}
|
661
|
+
}
|
662
|
+
}
|
663
|
+
else {
|
664
|
+
// do node pointer surgery for newChild
|
665
|
+
newChild.parentNode = this;
|
666
|
+
if (this.lastChild) {
|
667
|
+
this.lastChild.nextSibling = newChild;
|
668
|
+
newChild.previousSibling = this.lastChild;
|
669
|
+
this.lastChild = newChild;
|
670
|
+
}
|
671
|
+
else {
|
672
|
+
this.lastChild = newChild;
|
673
|
+
this.firstChild = newChild;
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
return newChild;
|
678
|
+
};
|
679
|
+
|
680
|
+
/**
|
681
|
+
* @method W3CDOMNode.hasChildNodes - This is a convenience method to allow easy determination of whether a node has any children.
|
682
|
+
*
|
683
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
684
|
+
*
|
685
|
+
* @return : boolean - true if the node has any children, false if the node has no children
|
686
|
+
*/
|
687
|
+
W3CDOMNode.prototype.hasChildNodes = function W3CDOMNode_hasChildNodes() {
|
688
|
+
return (this.childNodes.length > 0);
|
689
|
+
};
|
690
|
+
|
691
|
+
/**
|
692
|
+
* @method W3CDOMNode.cloneNode - Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
|
693
|
+
* The duplicate node has no parent (parentNode returns null.).
|
694
|
+
*
|
695
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
696
|
+
*
|
697
|
+
* @param deep : boolean - If true, recursively clone the subtree under the specified node;
|
698
|
+
* if false, clone only the node itself (and its attributes, if it is an Element).
|
699
|
+
*
|
700
|
+
* @return : W3CDOMNode
|
701
|
+
*/
|
702
|
+
W3CDOMNode.prototype.cloneNode = function W3CDOMNode_cloneNode(deep) {
|
703
|
+
// use importNode to clone this Node
|
704
|
+
//do not throw any exceptions
|
705
|
+
try {
|
706
|
+
return this.ownerDocument.importNode(this, deep);
|
707
|
+
}
|
708
|
+
catch (e) {
|
709
|
+
//there shouldn't be any exceptions, but if there are, return null
|
710
|
+
return null;
|
711
|
+
}
|
712
|
+
};
|
713
|
+
|
714
|
+
/**
|
715
|
+
* @method W3CDOMNode.normalize - Puts all Text nodes in the full depth of the sub-tree underneath this Element into a "normal" form
|
716
|
+
* where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes,
|
717
|
+
* i.e., there are no adjacent Text nodes.
|
718
|
+
*
|
719
|
+
* @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
|
720
|
+
*/
|
721
|
+
W3CDOMNode.prototype.normalize = function W3CDOMNode_normalize() {
|
722
|
+
var inode;
|
723
|
+
var nodesToRemove = new W3CDOMNodeList();
|
724
|
+
|
725
|
+
if (this.nodeType == W3CDOMNode.ELEMENT_NODE || this.nodeType == W3CDOMNode.DOCUMENT_NODE) {
|
726
|
+
var adjacentTextNode = null;
|
727
|
+
|
728
|
+
// loop through all childNodes
|
729
|
+
for(var i = 0; i < this.childNodes.length; i++) {
|
730
|
+
inode = this.childNodes.item(i);
|
731
|
+
|
732
|
+
if (inode.nodeType == W3CDOMNode.TEXT_NODE) { // this node is a text node
|
733
|
+
if (inode.length < 1) { // this text node is empty
|
734
|
+
nodesToRemove._appendChild(inode); // add this node to the list of nodes to be remove
|
735
|
+
}
|
736
|
+
else {
|
737
|
+
if (adjacentTextNode) { // if previous node was also text
|
738
|
+
adjacentTextNode.appendData(inode.data); // merge the data in adjacent text nodes
|
739
|
+
nodesToRemove._appendChild(inode); // add this node to the list of nodes to be removed
|
740
|
+
}
|
741
|
+
else {
|
742
|
+
adjacentTextNode = inode; // remember this node for next cycle
|
743
|
+
}
|
744
|
+
}
|
745
|
+
}
|
746
|
+
else {
|
747
|
+
adjacentTextNode = null; // (soon to be) previous node is not a text node
|
748
|
+
inode.normalize(); // normalise non Text childNodes
|
749
|
+
}
|
750
|
+
}
|
751
|
+
|
752
|
+
// remove redundant Text Nodes
|
753
|
+
for(var i = 0; i < nodesToRemove.length; i++) {
|
754
|
+
inode = nodesToRemove.item(i);
|
755
|
+
inode.parentNode.removeChild(inode);
|
756
|
+
}
|
757
|
+
}
|
758
|
+
};
|
759
|
+
|
760
|
+
/**
|
761
|
+
* @method W3CDOMNode.isSupported - Test if the W3CDOM implementation implements a specific feature
|
762
|
+
*
|
763
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
764
|
+
*
|
765
|
+
* @param feature : string - The package name of the feature to test. the legal only values are "XML" and "CORE" (case-insensitive).
|
766
|
+
* @param version : string - This is the version number of the package name to test. In Level 1, this is the string "1.0".
|
767
|
+
*
|
768
|
+
* @return : boolean
|
769
|
+
*/
|
770
|
+
W3CDOMNode.prototype.isSupported = function W3CDOMNode_isSupported(feature, version) {
|
771
|
+
// use Implementation.hasFeature to determin if this feature is supported
|
772
|
+
return this.ownerDocument.implementation.hasFeature(feature, version);
|
773
|
+
}
|
774
|
+
|
775
|
+
/**
|
776
|
+
* @method W3CDOMNode.getElementsByTagName - Returns a NodeList of all the Elements with a given tag name
|
777
|
+
* in the order in which they would be encountered in a preorder traversal of the Document tree.
|
778
|
+
*
|
779
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
780
|
+
*
|
781
|
+
* @param tagname : string - The name of the tag to match on. The special value "*" matches all tags
|
782
|
+
*
|
783
|
+
* @return : W3CDOMNodeList
|
784
|
+
*/
|
785
|
+
W3CDOMNode.prototype.getElementsByTagName = function W3CDOMNode_getElementsByTagName(tagname) {
|
786
|
+
// delegate to _getElementsByTagNameRecursive
|
787
|
+
return this._getElementsByTagNameRecursive(tagname, new W3CDOMNodeList(this.ownerDocument));
|
788
|
+
};
|
789
|
+
|
790
|
+
/**
|
791
|
+
* @method W3CDOMNode._getElementsByTagNameRecursive - implements getElementsByTagName()
|
792
|
+
*
|
793
|
+
* @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
|
794
|
+
*
|
795
|
+
* @param tagname : string - The name of the tag to match on. The special value "*" matches all tags
|
796
|
+
* @param nodeList : W3CDOMNodeList - The accumulating list of matching nodes
|
797
|
+
*
|
798
|
+
* @return : W3CDOMNodeList
|
799
|
+
*/
|
800
|
+
W3CDOMNode.prototype._getElementsByTagNameRecursive = function W3CDOMNode__getElementsByTagNameRecursive(tagname, nodeList) {
|
801
|
+
if (this.nodeType == W3CDOMNode.ELEMENT_NODE || this.nodeType == W3CDOMNode.DOCUMENT_NODE) {
|
802
|
+
|
803
|
+
if((this.nodeName == tagname) || (tagname == "*")) {
|
804
|
+
nodeList._appendChild(this); // add matching node to nodeList
|
805
|
+
}
|
806
|
+
|
807
|
+
// recurse childNodes
|
808
|
+
for(var i = 0; i < this.childNodes.length; i++) {
|
809
|
+
nodeList = this.childNodes.item(i)._getElementsByTagNameRecursive(tagname, nodeList);
|
810
|
+
}
|
811
|
+
}
|
812
|
+
|
813
|
+
return nodeList;
|
814
|
+
};
|
815
|
+
|
816
|
+
/**
|
817
|
+
* @method W3CDOMNode.getXML - Returns the String XML of the node and all of its children
|
818
|
+
*
|
819
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
820
|
+
*
|
821
|
+
* @return : string - XML String of the XML of the node and all of its children
|
822
|
+
*/
|
823
|
+
W3CDOMNode.prototype.getXML = function W3CDOMNode_getXML() {
|
824
|
+
return this.toString();
|
825
|
+
}
|
826
|
+
|
827
|
+
|
828
|
+
/**
|
829
|
+
* @method W3CDOMNode.getElementsByTagNameNS - Returns a NodeList of all the Elements with a given namespaceURI and localName
|
830
|
+
* in the order in which they would be encountered in a preorder traversal of the Document tree.
|
831
|
+
*
|
832
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
833
|
+
*
|
834
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
835
|
+
* @param localName : string - the local name of the required node
|
836
|
+
*
|
837
|
+
* @return : W3CDOMNodeList
|
838
|
+
*/
|
839
|
+
W3CDOMNode.prototype.getElementsByTagNameNS = function W3CDOMNode_getElementsByTagNameNS(namespaceURI, localName) {
|
840
|
+
// delegate to _getElementsByTagNameNSRecursive
|
841
|
+
return this._getElementsByTagNameNSRecursive(namespaceURI, localName, new W3CDOMNodeList(this.ownerDocument));
|
842
|
+
};
|
843
|
+
|
844
|
+
/**
|
845
|
+
* @method W3CDOMNode._getElementsByTagNameNSRecursive - implements getElementsByTagName()
|
846
|
+
*
|
847
|
+
* @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
|
848
|
+
*
|
849
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
850
|
+
* @param localName : string - the local name of the required node
|
851
|
+
* @param nodeList : W3CDOMNodeList - The accumulating list of matching nodes
|
852
|
+
*
|
853
|
+
* @return : W3CDOMNodeList
|
854
|
+
*/
|
855
|
+
W3CDOMNode.prototype._getElementsByTagNameNSRecursive = function W3CDOMNode__getElementsByTagNameNSRecursive(namespaceURI, localName, nodeList) {
|
856
|
+
if (this.nodeType == W3CDOMNode.ELEMENT_NODE || this.nodeType == W3CDOMNode.DOCUMENT_NODE) {
|
857
|
+
|
858
|
+
if (((this.namespaceURI == namespaceURI) || (namespaceURI == "*")) && ((this.localName == localName) || (localName == "*"))) {
|
859
|
+
nodeList._appendChild(this); // add matching node to nodeList
|
860
|
+
}
|
861
|
+
|
862
|
+
// recurse childNodes
|
863
|
+
for(var i = 0; i < this.childNodes.length; i++) {
|
864
|
+
nodeList = this.childNodes.item(i)._getElementsByTagNameNSRecursive(namespaceURI, localName, nodeList);
|
865
|
+
}
|
866
|
+
}
|
867
|
+
|
868
|
+
return nodeList;
|
869
|
+
};
|
870
|
+
|
871
|
+
/**
|
872
|
+
* @method W3CDOMNode._isAncestor - returns true if node is ancestor of this
|
873
|
+
*
|
874
|
+
* @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
|
875
|
+
*
|
876
|
+
* @param node : W3CDOMNode - The candidate ancestor node
|
877
|
+
*
|
878
|
+
* @return : boolean
|
879
|
+
*/
|
880
|
+
W3CDOMNode.prototype._isAncestor = function W3CDOMNode__isAncestor(node) {
|
881
|
+
// if this node matches, return true,
|
882
|
+
// otherwise recurse up (if there is a parentNode)
|
883
|
+
return ((this == node) || ((this.parentNode) && (this.parentNode._isAncestor(node))));
|
884
|
+
}
|
885
|
+
|
886
|
+
/**
|
887
|
+
* @method W3CDOMNode.importNode - Imports a node from another document to this document.
|
888
|
+
* The returned node has no parent; (parentNode is null).
|
889
|
+
*
|
890
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
891
|
+
*
|
892
|
+
* @param importedNode : Node - The Node to be imported
|
893
|
+
* @param deep : boolean - If true, recursively clone the subtree under the specified node;
|
894
|
+
* if false, clone only the node itself (and its attributes, if it is an Element).
|
895
|
+
*
|
896
|
+
* @return : W3CDOMNode
|
897
|
+
*/
|
898
|
+
W3CDOMNode.prototype.importNode = function W3CDOMNode_importNode(importedNode, deep) {
|
899
|
+
var importNode;
|
900
|
+
|
901
|
+
//there is no need to perform namespace checks since everything has already gone through them
|
902
|
+
//in order to have gotten into the W3CDOM in the first place. The following line
|
903
|
+
//turns namespace checking off in ._isValidNamespace
|
904
|
+
this.getOwnerDocument()._performingImportNodeOperation = true;
|
905
|
+
|
906
|
+
try {
|
907
|
+
if (importedNode.nodeType == W3CDOMNode.ELEMENT_NODE) {
|
908
|
+
if (!this.ownerDocument.implementation.namespaceAware) {
|
909
|
+
// create a local Element (with the name of the importedNode)
|
910
|
+
importNode = this.ownerDocument.createElement(importedNode.tagName);
|
911
|
+
|
912
|
+
// create attributes matching those of the importedNode
|
913
|
+
for(var i = 0; i < importedNode.attributes.length; i++) {
|
914
|
+
importNode.setAttribute(importedNode.attributes.item(i).name, importedNode.attributes.item(i).value);
|
915
|
+
}
|
916
|
+
}
|
917
|
+
else {
|
918
|
+
// create a local Element (with the name & namespaceURI of the importedNode)
|
919
|
+
importNode = this.ownerDocument.createElementNS(importedNode.namespaceURI, importedNode.nodeName);
|
920
|
+
|
921
|
+
// create attributes matching those of the importedNode
|
922
|
+
for(var i = 0; i < importedNode.attributes.length; i++) {
|
923
|
+
importNode.setAttributeNS(importedNode.attributes.item(i).namespaceURI, importedNode.attributes.item(i).name, importedNode.attributes.item(i).value);
|
924
|
+
}
|
925
|
+
|
926
|
+
// create namespace definitions matching those of the importedNode
|
927
|
+
for(var i = 0; i < importedNode._namespaces.length; i++) {
|
928
|
+
importNode._namespaces._nodes[i] = this.ownerDocument.createNamespace(importedNode._namespaces.item(i).localName);
|
929
|
+
importNode._namespaces._nodes[i].setValue(importedNode._namespaces.item(i).value);
|
930
|
+
}
|
931
|
+
}
|
932
|
+
}
|
933
|
+
else if (importedNode.nodeType == W3CDOMNode.ATTRIBUTE_NODE) {
|
934
|
+
if (!this.ownerDocument.implementation.namespaceAware) {
|
935
|
+
// create a local Attribute (with the name of the importedAttribute)
|
936
|
+
importNode = this.ownerDocument.createAttribute(importedNode.name);
|
937
|
+
}
|
938
|
+
else {
|
939
|
+
// create a local Attribute (with the name & namespaceURI of the importedAttribute)
|
940
|
+
importNode = this.ownerDocument.createAttributeNS(importedNode.namespaceURI, importedNode.nodeName);
|
941
|
+
|
942
|
+
// create namespace definitions matching those of the importedAttribute
|
943
|
+
for(var i = 0; i < importedNode._namespaces.length; i++) {
|
944
|
+
importNode._namespaces._nodes[i] = this.ownerDocument.createNamespace(importedNode._namespaces.item(i).localName);
|
945
|
+
importNode._namespaces._nodes[i].setValue(importedNode._namespaces.item(i).value);
|
946
|
+
}
|
947
|
+
}
|
948
|
+
|
949
|
+
// set the value of the local Attribute to match that of the importedAttribute
|
950
|
+
importNode.setValue(importedNode.value);
|
951
|
+
}
|
952
|
+
else if (importedNode.nodeType == W3CDOMNode.DOCUMENT_FRAGMENT) {
|
953
|
+
// create a local DocumentFragment
|
954
|
+
importNode = this.ownerDocument.createDocumentFragment();
|
955
|
+
}
|
956
|
+
else if (importedNode.nodeType == W3CDOMNode.NAMESPACE_NODE) {
|
957
|
+
// create a local NamespaceNode (with the same name & value as the importedNode)
|
958
|
+
importNode = this.ownerDocument.createNamespace(importedNode.nodeName);
|
959
|
+
importNode.setValue(importedNode.value);
|
960
|
+
}
|
961
|
+
else if (importedNode.nodeType == W3CDOMNode.TEXT_NODE) {
|
962
|
+
// create a local TextNode (with the same data as the importedNode)
|
963
|
+
importNode = this.ownerDocument.createTextNode(importedNode.data);
|
964
|
+
}
|
965
|
+
else if (importedNode.nodeType == W3CDOMNode.CDATA_SECTION_NODE) {
|
966
|
+
// create a local CDATANode (with the same data as the importedNode)
|
967
|
+
importNode = this.ownerDocument.createCDATASection(importedNode.data);
|
968
|
+
}
|
969
|
+
else if (importedNode.nodeType == W3CDOMNode.PROCESSING_INSTRUCTION_NODE) {
|
970
|
+
// create a local ProcessingInstruction (with the same target & data as the importedNode)
|
971
|
+
importNode = this.ownerDocument.createProcessingInstruction(importedNode.target, importedNode.data);
|
972
|
+
}
|
973
|
+
else if (importedNode.nodeType == W3CDOMNode.COMMENT_NODE) {
|
974
|
+
// create a local Comment (with the same data as the importedNode)
|
975
|
+
importNode = this.ownerDocument.createComment(importedNode.data);
|
976
|
+
}
|
977
|
+
else { // throw Exception if nodeType is not supported
|
978
|
+
throw(new W3CDOMException(W3CDOMException.NOT_SUPPORTED_ERR));
|
979
|
+
}
|
980
|
+
|
981
|
+
if (deep) { // recurse childNodes
|
982
|
+
for(var i = 0; i < importedNode.childNodes.length; i++) {
|
983
|
+
importNode.appendChild(this.ownerDocument.importNode(importedNode.childNodes.item(i), true));
|
984
|
+
}
|
985
|
+
}
|
986
|
+
|
987
|
+
//reset _performingImportNodeOperation
|
988
|
+
this.getOwnerDocument()._performingImportNodeOperation = false;
|
989
|
+
return importNode;
|
990
|
+
}
|
991
|
+
catch (eAny) {
|
992
|
+
//reset _performingImportNodeOperation
|
993
|
+
this.getOwnerDocument()._performingImportNodeOperation = false;
|
994
|
+
|
995
|
+
//re-throw the exception
|
996
|
+
throw eAny;
|
997
|
+
}//djotemp
|
998
|
+
};
|
999
|
+
|
1000
|
+
/**
|
1001
|
+
* @method W3CDOMNode.escapeString - escape special characters
|
1002
|
+
*
|
1003
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1004
|
+
*
|
1005
|
+
* @param str : string - The string to be escaped
|
1006
|
+
*
|
1007
|
+
* @return : string - The escaped string
|
1008
|
+
*/
|
1009
|
+
W3CDOMNode.prototype.__escapeString = function W3CDOMNode__escapeString(str) {
|
1010
|
+
|
1011
|
+
//the sax processor already has this function. Just wrap it
|
1012
|
+
return __escapeString(str);
|
1013
|
+
};
|
1014
|
+
|
1015
|
+
/**
|
1016
|
+
* @method W3CDOMNode.unescapeString - unescape special characters
|
1017
|
+
*
|
1018
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1019
|
+
*
|
1020
|
+
* @param str : string - The string to be unescaped
|
1021
|
+
*
|
1022
|
+
* @return : string - The unescaped string
|
1023
|
+
*/
|
1024
|
+
W3CDOMNode.prototype.__unescapeString = function W3CDOMNode__unescapeString(str) {
|
1025
|
+
|
1026
|
+
//the sax processor already has this function. Just wrap it
|
1027
|
+
return __unescapeString(str);
|
1028
|
+
};
|
1029
|
+
|
1030
|
+
|
1031
|
+
|
1032
|
+
/**
|
1033
|
+
* @class W3CDOMDocument - The Document interface represents the entire HTML or XML document.
|
1034
|
+
* Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
|
1035
|
+
*
|
1036
|
+
* @extends W3CDOMNode
|
1037
|
+
*
|
1038
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1039
|
+
*
|
1040
|
+
* @param implementation : W3CDOMImplementation - the creator Implementation
|
1041
|
+
*/
|
1042
|
+
W3CDOMDocument = function(implementation) {
|
1043
|
+
this._class = addClass(this._class, "W3CDOMDocument");
|
1044
|
+
this.W3CDOMNode = W3CDOMNode;
|
1045
|
+
this.W3CDOMNode(this);
|
1046
|
+
|
1047
|
+
this.doctype = null; // The Document Type Declaration (see DocumentType) associated with this document
|
1048
|
+
this.implementation = implementation; // The W3CDOMImplementation object that handles this document.
|
1049
|
+
this.documentElement = null; // This is a convenience attribute that allows direct access to the child node that is the root element of the document
|
1050
|
+
this.all = new Array(); // The list of all Elements
|
1051
|
+
|
1052
|
+
this.nodeName = "#document";
|
1053
|
+
this.nodeType = W3CDOMNode.DOCUMENT_NODE;
|
1054
|
+
this._id = 0;
|
1055
|
+
this._lastId = 0;
|
1056
|
+
this._parseComplete = false; // initially false, set to true by parser
|
1057
|
+
|
1058
|
+
this.ownerDocument = this;
|
1059
|
+
|
1060
|
+
this._performingImportNodeOperation = false;
|
1061
|
+
};
|
1062
|
+
W3CDOMDocument.prototype = new W3CDOMNode;
|
1063
|
+
|
1064
|
+
/**
|
1065
|
+
* @method W3CDOMDocument.getDoctype - Java style gettor for .doctype
|
1066
|
+
*
|
1067
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1068
|
+
*
|
1069
|
+
* @return : W3CDOMDocument
|
1070
|
+
*/
|
1071
|
+
W3CDOMDocument.prototype.getDoctype = function W3CDOMDocument_getDoctype() {
|
1072
|
+
return this.doctype;
|
1073
|
+
};
|
1074
|
+
|
1075
|
+
/**
|
1076
|
+
* @method W3CDOMDocument.getImplementation - Java style gettor for .implementation
|
1077
|
+
*
|
1078
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1079
|
+
*
|
1080
|
+
* @return : W3CDOMImplementation
|
1081
|
+
*/
|
1082
|
+
W3CDOMDocument.prototype.getImplementation = function W3CDOMDocument_implementation() {
|
1083
|
+
return this.implementation;
|
1084
|
+
};
|
1085
|
+
|
1086
|
+
/**
|
1087
|
+
* @method W3CDOMDocument.getDocumentElement - Java style gettor for .documentElement
|
1088
|
+
*
|
1089
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1090
|
+
*
|
1091
|
+
* @return : W3CDOMDocumentElement
|
1092
|
+
*/
|
1093
|
+
W3CDOMDocument.prototype.getDocumentElement = function W3CDOMDocument_getDocumentElement() {
|
1094
|
+
return this.documentElement;
|
1095
|
+
};
|
1096
|
+
|
1097
|
+
/**
|
1098
|
+
* @method W3CDOMDocument.createElement - Creates an element of the type specified.
|
1099
|
+
* Note that the instance returned implements the Element interface,
|
1100
|
+
* so attributes can be specified directly on the returned object.
|
1101
|
+
*
|
1102
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1103
|
+
*
|
1104
|
+
* @param tagName : string - The name of the element type to instantiate.
|
1105
|
+
*
|
1106
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1107
|
+
*
|
1108
|
+
* @return : W3CDOMElement - The new Element object.
|
1109
|
+
*/
|
1110
|
+
W3CDOMDocument.prototype.createElement = function W3CDOMDocument_createElement(tagName) {
|
1111
|
+
// throw Exception if the tagName string contains an illegal character
|
1112
|
+
if (this.ownerDocument.implementation.errorChecking && (!this.ownerDocument.implementation._isValidName(tagName))) {
|
1113
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
// create W3CDOMElement specifying 'this' as ownerDocument
|
1117
|
+
var node = new W3CDOMElement(this);
|
1118
|
+
|
1119
|
+
// assign values to properties (and aliases)
|
1120
|
+
node.tagName = tagName;
|
1121
|
+
node.nodeName = tagName;
|
1122
|
+
|
1123
|
+
// add Element to 'all' collection
|
1124
|
+
this.all[this.all.length] = node;
|
1125
|
+
|
1126
|
+
return node;
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
/**
|
1130
|
+
* @method W3CDOMDocument.createDocumentFragment - CCreates an empty DocumentFragment object.
|
1131
|
+
*
|
1132
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1133
|
+
*
|
1134
|
+
* @return : W3CDOMDocumentFragment - The new DocumentFragment object
|
1135
|
+
*/
|
1136
|
+
W3CDOMDocument.prototype.createDocumentFragment = function W3CDOMDocument_createDocumentFragment() {
|
1137
|
+
// create W3CDOMDocumentFragment specifying 'this' as ownerDocument
|
1138
|
+
var node = new W3CDOMDocumentFragment(this);
|
1139
|
+
|
1140
|
+
return node;
|
1141
|
+
};
|
1142
|
+
|
1143
|
+
/**
|
1144
|
+
* @method W3CDOMDocument.createTextNode - Creates a Text node given the specified string.
|
1145
|
+
*
|
1146
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1147
|
+
*
|
1148
|
+
* @param data : string - The data for the node.
|
1149
|
+
*
|
1150
|
+
* @return : W3CDOMText - The new Text object.
|
1151
|
+
*/
|
1152
|
+
W3CDOMDocument.prototype.createTextNode = function W3CDOMDocument_createTextNode(data) {
|
1153
|
+
// create W3CDOMText specifying 'this' as ownerDocument
|
1154
|
+
var node = new W3CDOMText(this);
|
1155
|
+
|
1156
|
+
// assign values to properties (and aliases)
|
1157
|
+
node.data = data;
|
1158
|
+
node.nodeValue = data;
|
1159
|
+
|
1160
|
+
// set initial length
|
1161
|
+
node.length = data.length;
|
1162
|
+
|
1163
|
+
return node;
|
1164
|
+
};
|
1165
|
+
|
1166
|
+
/**
|
1167
|
+
* @method W3CDOMDocument.createComment - Creates a Text node given the specified string.
|
1168
|
+
*
|
1169
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1170
|
+
*
|
1171
|
+
* @param data : string - The data for the node.
|
1172
|
+
*
|
1173
|
+
* @return : W3CDOMComment - The new Comment object.
|
1174
|
+
*/
|
1175
|
+
W3CDOMDocument.prototype.createComment = function W3CDOMDocument_createComment(data) {
|
1176
|
+
// create W3CDOMComment specifying 'this' as ownerDocument
|
1177
|
+
var node = new W3CDOMComment(this);
|
1178
|
+
|
1179
|
+
// assign values to properties (and aliases)
|
1180
|
+
node.data = data;
|
1181
|
+
node.nodeValue = data;
|
1182
|
+
|
1183
|
+
// set initial length
|
1184
|
+
node.length = data.length;
|
1185
|
+
|
1186
|
+
return node;
|
1187
|
+
};
|
1188
|
+
|
1189
|
+
/**
|
1190
|
+
* @method W3CDOMDocument.createCDATASection - Creates a CDATASection node whose value is the specified string.
|
1191
|
+
*
|
1192
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1193
|
+
*
|
1194
|
+
* @param data : string - The data for the node.
|
1195
|
+
*
|
1196
|
+
* @return : W3CDOMCDATASection - The new CDATASection object.
|
1197
|
+
*/
|
1198
|
+
W3CDOMDocument.prototype.createCDATASection = function W3CDOMDocument_createCDATASection(data) {
|
1199
|
+
// create W3CDOMCDATASection specifying 'this' as ownerDocument
|
1200
|
+
var node = new W3CDOMCDATASection(this);
|
1201
|
+
|
1202
|
+
// assign values to properties (and aliases)
|
1203
|
+
node.data = data;
|
1204
|
+
node.nodeValue = data;
|
1205
|
+
|
1206
|
+
// set initial length
|
1207
|
+
node.length = data.length;
|
1208
|
+
|
1209
|
+
return node;
|
1210
|
+
};
|
1211
|
+
|
1212
|
+
/**
|
1213
|
+
* @method W3CDOMDocument.createProcessingInstruction - Creates a ProcessingInstruction node given the specified target and data strings.
|
1214
|
+
*
|
1215
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1216
|
+
*
|
1217
|
+
* @param target : string - The target part of the processing instruction.
|
1218
|
+
* @param data : string - The data for the node.
|
1219
|
+
*
|
1220
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1221
|
+
*
|
1222
|
+
* @return : W3CDOMProcessingInstruction - The new ProcessingInstruction object.
|
1223
|
+
*/
|
1224
|
+
W3CDOMDocument.prototype.createProcessingInstruction = function W3CDOMDocument_createProcessingInstruction(target, data) {
|
1225
|
+
// throw Exception if the target string contains an illegal character
|
1226
|
+
if (this.ownerDocument.implementation.errorChecking && (!this.implementation._isValidName(target))) {
|
1227
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1228
|
+
}
|
1229
|
+
|
1230
|
+
// create W3CDOMProcessingInstruction specifying 'this' as ownerDocument
|
1231
|
+
var node = new W3CDOMProcessingInstruction(this);
|
1232
|
+
|
1233
|
+
// assign values to properties (and aliases)
|
1234
|
+
node.target = target;
|
1235
|
+
node.nodeName = target;
|
1236
|
+
node.data = data;
|
1237
|
+
node.nodeValue = data;
|
1238
|
+
|
1239
|
+
// set initial length
|
1240
|
+
node.length = data.length;
|
1241
|
+
|
1242
|
+
return node;
|
1243
|
+
};
|
1244
|
+
|
1245
|
+
/**
|
1246
|
+
* @method W3CDOMDocument.createAttribute - Creates an Attr of the given name
|
1247
|
+
*
|
1248
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1249
|
+
*
|
1250
|
+
* @param name : string - The name of the attribute.
|
1251
|
+
*
|
1252
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1253
|
+
*
|
1254
|
+
* @return : W3CDOMAttr - The new Attr object.
|
1255
|
+
*/
|
1256
|
+
W3CDOMDocument.prototype.createAttribute = function W3CDOMDocument_createAttribute(name) {
|
1257
|
+
// throw Exception if the name string contains an illegal character
|
1258
|
+
if (this.ownerDocument.implementation.errorChecking && (!this.ownerDocument.implementation._isValidName(name))) {
|
1259
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
// create W3CDOMAttr specifying 'this' as ownerDocument
|
1263
|
+
var node = new W3CDOMAttr(this);
|
1264
|
+
|
1265
|
+
// assign values to properties (and aliases)
|
1266
|
+
node.name = name;
|
1267
|
+
node.nodeName = name;
|
1268
|
+
|
1269
|
+
return node;
|
1270
|
+
};
|
1271
|
+
|
1272
|
+
/**
|
1273
|
+
* @method W3CDOMDocument.createElementNS - Creates an element of the type specified,
|
1274
|
+
* within the specified namespace.
|
1275
|
+
* Note that the instance returned implements the Element interface,
|
1276
|
+
* so attributes can be specified directly on the returned object.
|
1277
|
+
*
|
1278
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1279
|
+
*
|
1280
|
+
* @param namespaceURI : string - The namespace URI of the element.
|
1281
|
+
* @param qualifiedName : string - The qualified name of the element type to instantiate.
|
1282
|
+
*
|
1283
|
+
* @throws : W3CDOMException - NAMESPACE_ERR: Raised if the Namespace is invalid
|
1284
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1285
|
+
*
|
1286
|
+
* @return : W3CDOMElement - The new Element object.
|
1287
|
+
*/
|
1288
|
+
W3CDOMDocument.prototype.createElementNS = function W3CDOMDocument_createElementNS(namespaceURI, qualifiedName) {
|
1289
|
+
// test for exceptions
|
1290
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
1291
|
+
// throw Exception if the Namespace is invalid
|
1292
|
+
if (!this.ownerDocument._isValidNamespace(namespaceURI, qualifiedName)) {
|
1293
|
+
throw(new W3CDOMException(W3CDOMException.NAMESPACE_ERR));
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
// throw Exception if the qualifiedName string contains an illegal character
|
1297
|
+
if (!this.ownerDocument.implementation._isValidName(qualifiedName)) {
|
1298
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1299
|
+
}
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
// create W3CDOMElement specifying 'this' as ownerDocument
|
1303
|
+
var node = new W3CDOMElement(this);
|
1304
|
+
var qname = this.implementation._parseQName(qualifiedName);
|
1305
|
+
|
1306
|
+
// assign values to properties (and aliases)
|
1307
|
+
node.nodeName = qualifiedName;
|
1308
|
+
node.namespaceURI = namespaceURI;
|
1309
|
+
node.prefix = qname.prefix;
|
1310
|
+
node.localName = qname.localName;
|
1311
|
+
node.tagName = qualifiedName;
|
1312
|
+
|
1313
|
+
// add Element to 'all' collection
|
1314
|
+
this.all[this.all.length] = node;
|
1315
|
+
|
1316
|
+
return node;
|
1317
|
+
};
|
1318
|
+
|
1319
|
+
/**
|
1320
|
+
* @method W3CDOMDocument.createAttributeNS - Creates an Attr of the given name
|
1321
|
+
* within the specified namespace.
|
1322
|
+
*
|
1323
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1324
|
+
*
|
1325
|
+
* @param namespaceURI : string - The namespace URI of the attribute.
|
1326
|
+
* @param qualifiedName : string - The qualified name of the attribute.
|
1327
|
+
*
|
1328
|
+
* @throws : W3CDOMException - NAMESPACE_ERR: Raised if the Namespace is invalid
|
1329
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1330
|
+
*
|
1331
|
+
* @return : W3CDOMAttr - The new Attr object.
|
1332
|
+
*/
|
1333
|
+
W3CDOMDocument.prototype.createAttributeNS = function W3CDOMDocument_createAttributeNS(namespaceURI, qualifiedName) {
|
1334
|
+
// test for exceptions
|
1335
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
1336
|
+
// throw Exception if the Namespace is invalid
|
1337
|
+
if (!this.ownerDocument._isValidNamespace(namespaceURI, qualifiedName, true)) {
|
1338
|
+
throw(new W3CDOMException(W3CDOMException.NAMESPACE_ERR));
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
// throw Exception if the qualifiedName string contains an illegal character
|
1342
|
+
if (!this.ownerDocument.implementation._isValidName(qualifiedName)) {
|
1343
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
// create W3CDOMAttr specifying 'this' as ownerDocument
|
1348
|
+
var node = new W3CDOMAttr(this);
|
1349
|
+
var qname = this.implementation._parseQName(qualifiedName);
|
1350
|
+
|
1351
|
+
// assign values to properties (and aliases)
|
1352
|
+
node.nodeName = qualifiedName
|
1353
|
+
node.namespaceURI = namespaceURI
|
1354
|
+
node.prefix = qname.prefix;
|
1355
|
+
node.localName = qname.localName;
|
1356
|
+
node.name = qualifiedName
|
1357
|
+
node.nodeValue = "";
|
1358
|
+
|
1359
|
+
return node;
|
1360
|
+
};
|
1361
|
+
|
1362
|
+
/**
|
1363
|
+
* @method W3CDOMDocument.createNamespace - Creates an Namespace of the given name
|
1364
|
+
*
|
1365
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1366
|
+
*
|
1367
|
+
* @param qualifiedName : string - The qualified name of the attribute.
|
1368
|
+
*
|
1369
|
+
* @return : W3CDOMNamespace - The new Namespace object.
|
1370
|
+
*/
|
1371
|
+
W3CDOMDocument.prototype.createNamespace = function W3CDOMDocument_createNamespace(qualifiedName) {
|
1372
|
+
// create W3CDOMNamespace specifying 'this' as ownerDocument
|
1373
|
+
var node = new W3CDOMNamespace(this);
|
1374
|
+
var qname = this.implementation._parseQName(qualifiedName);
|
1375
|
+
|
1376
|
+
// assign values to properties (and aliases)
|
1377
|
+
node.nodeName = qualifiedName
|
1378
|
+
node.prefix = qname.prefix;
|
1379
|
+
node.localName = qname.localName;
|
1380
|
+
node.name = qualifiedName
|
1381
|
+
node.nodeValue = "";
|
1382
|
+
|
1383
|
+
return node;
|
1384
|
+
};
|
1385
|
+
|
1386
|
+
/**
|
1387
|
+
* @method W3CDOMDocument.getElementById - Return the Element whose ID is given by elementId
|
1388
|
+
*
|
1389
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1390
|
+
*
|
1391
|
+
* @param elementId : string - The unique ID of the Element
|
1392
|
+
*
|
1393
|
+
* @return : W3CDOMElement - The requested W3CDOMElement
|
1394
|
+
*/
|
1395
|
+
W3CDOMDocument.prototype.getElementById = function W3CDOMDocument_getElementById(elementId) {
|
1396
|
+
// return this._ids[elementId];
|
1397
|
+
retNode = null;
|
1398
|
+
|
1399
|
+
// loop through all Elements in the 'all' collection
|
1400
|
+
for (var i=0; i < this.all.length; i++) {
|
1401
|
+
var node = this.all[i];
|
1402
|
+
|
1403
|
+
// if id matches & node is alive (ie, connected (in)directly to the documentElement)
|
1404
|
+
if ((node.id == elementId) && (node._isAncestor(node.ownerDocument.documentElement))) {
|
1405
|
+
retNode = node;
|
1406
|
+
break;
|
1407
|
+
}
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
return retNode;
|
1411
|
+
};
|
1412
|
+
|
1413
|
+
|
1414
|
+
|
1415
|
+
/**
|
1416
|
+
* @method W3CDOMDocument._genId - generate a unique internal id
|
1417
|
+
*
|
1418
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1419
|
+
*
|
1420
|
+
* @return : string - The unique (serial) id
|
1421
|
+
*/
|
1422
|
+
W3CDOMDocument.prototype._genId = function W3CDOMDocument__genId() {
|
1423
|
+
this._lastId += 1; // increment lastId (to generate unique id)
|
1424
|
+
|
1425
|
+
return this._lastId;
|
1426
|
+
};
|
1427
|
+
|
1428
|
+
|
1429
|
+
/**
|
1430
|
+
* @method W3CDOMDocument._isValidNamespace - test if Namespace is valid
|
1431
|
+
* ie, not valid if;
|
1432
|
+
* the qualifiedName is malformed, or
|
1433
|
+
* the qualifiedName has a prefix and the namespaceURI is null, or
|
1434
|
+
* the qualifiedName has a prefix that is "xml" and the namespaceURI is
|
1435
|
+
* different from "http://www.w3.org/XML/1998/namespace" [Namespaces].
|
1436
|
+
*
|
1437
|
+
* @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
|
1438
|
+
*
|
1439
|
+
* @param namespaceURI : string - the namespace URI
|
1440
|
+
* @param qualifiedName : string - the QName
|
1441
|
+
* @Param isAttribute : boolean - true, if the requesting node is an Attr
|
1442
|
+
*
|
1443
|
+
* @return : boolean
|
1444
|
+
*/
|
1445
|
+
W3CDOMDocument.prototype._isValidNamespace = function W3CDOMDocument__isValidNamespace(namespaceURI, qualifiedName, isAttribute) {
|
1446
|
+
|
1447
|
+
if (this._performingImportNodeOperation == true) {
|
1448
|
+
//we're doing an importNode operation (or a cloneNode) - in both cases, there
|
1449
|
+
//is no need to perform any namespace checking since the nodes have to have been valid
|
1450
|
+
//to have gotten into the W3CDOM in the first place
|
1451
|
+
return true;
|
1452
|
+
}
|
1453
|
+
|
1454
|
+
var valid = true;
|
1455
|
+
// parse QName
|
1456
|
+
var qName = this.implementation._parseQName(qualifiedName);
|
1457
|
+
|
1458
|
+
|
1459
|
+
//only check for namespaces if we're finished parsing
|
1460
|
+
if (this._parseComplete == true) {
|
1461
|
+
|
1462
|
+
// if the qualifiedName is malformed
|
1463
|
+
if (qName.localName.indexOf(":") > -1 ){
|
1464
|
+
valid = false;
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
if ((valid) && (!isAttribute)) {
|
1468
|
+
// if the namespaceURI is not null
|
1469
|
+
if (!namespaceURI) {
|
1470
|
+
valid = false;
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
|
1474
|
+
// if the qualifiedName has a prefix
|
1475
|
+
if ((valid) && (qName.prefix == "")) {
|
1476
|
+
valid = false;
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
// if the qualifiedName has a prefix that is "xml" and the namespaceURI is
|
1482
|
+
// different from "http://www.w3.org/XML/1998/namespace" [Namespaces].
|
1483
|
+
if ((valid) && (qName.prefix == "xml") && (namespaceURI != "http://www.w3.org/XML/1998/namespace")) {
|
1484
|
+
valid = false;
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
return valid;
|
1488
|
+
}
|
1489
|
+
|
1490
|
+
/**
|
1491
|
+
* @method W3CDOMDocument.toString - Serialize the document into an XML string
|
1492
|
+
*
|
1493
|
+
* @author David Joham (djoham@yahoo.com)
|
1494
|
+
*
|
1495
|
+
* @return : string
|
1496
|
+
*/
|
1497
|
+
W3CDOMDocument.prototype.toString = function W3CDOMDocument_toString() {
|
1498
|
+
return "" + this.childNodes;
|
1499
|
+
} // end function getXML
|
1500
|
+
|
1501
|
+
|
1502
|
+
/**
|
1503
|
+
* @class W3CDOMElement - By far the vast majority of objects (apart from text) that authors encounter
|
1504
|
+
* when traversing a document are Element nodes.
|
1505
|
+
*
|
1506
|
+
* @extends W3CDOMNode
|
1507
|
+
*
|
1508
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1509
|
+
*
|
1510
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
1511
|
+
*/
|
1512
|
+
W3CDOMElement = function(ownerDocument) {
|
1513
|
+
this._class = addClass(this._class, "W3CDOMElement");
|
1514
|
+
this.W3CDOMNode = W3CDOMNode;
|
1515
|
+
this.W3CDOMNode(ownerDocument);
|
1516
|
+
|
1517
|
+
this.tagName = ""; // The name of the element.
|
1518
|
+
this.id = ""; // the ID of the element
|
1519
|
+
|
1520
|
+
this.nodeType = W3CDOMNode.ELEMENT_NODE;
|
1521
|
+
};
|
1522
|
+
W3CDOMElement.prototype = new W3CDOMNode;
|
1523
|
+
|
1524
|
+
/**
|
1525
|
+
* @method W3CDOMElement.getTagName - Java style gettor for .TagName
|
1526
|
+
*
|
1527
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1528
|
+
*
|
1529
|
+
* @return : string
|
1530
|
+
*/
|
1531
|
+
W3CDOMElement.prototype.getTagName = function W3CDOMElement_getTagName() {
|
1532
|
+
return this.tagName;
|
1533
|
+
};
|
1534
|
+
|
1535
|
+
/**
|
1536
|
+
* @method W3CDOMElement.getAttribute - Retrieves an attribute value by name
|
1537
|
+
*
|
1538
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1539
|
+
*
|
1540
|
+
* @param name : string - The name of the attribute to retrieve
|
1541
|
+
*
|
1542
|
+
* @return : string - The Attr value as a string, or the empty string if that attribute does not have a specified value.
|
1543
|
+
*/
|
1544
|
+
W3CDOMElement.prototype.getAttribute = function W3CDOMElement_getAttribute(name) {
|
1545
|
+
var ret = "";
|
1546
|
+
|
1547
|
+
// if attribute exists, use it
|
1548
|
+
var attr = this.attributes.getNamedItem(name);
|
1549
|
+
|
1550
|
+
if (attr) {
|
1551
|
+
ret = attr.value;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
return ret; // if Attribute exists, return its value, otherwise, return ""
|
1555
|
+
};
|
1556
|
+
|
1557
|
+
/**
|
1558
|
+
* @method W3CDOMElement.setAttribute - Retrieves an attribute value by name
|
1559
|
+
*
|
1560
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1561
|
+
*
|
1562
|
+
* @param name : string - The name of the attribute to create or alter
|
1563
|
+
* @param value : string - Value to set in string form
|
1564
|
+
*
|
1565
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1566
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if the Attribute is readonly.
|
1567
|
+
*/
|
1568
|
+
W3CDOMElement.prototype.setAttribute = function W3CDOMElement_setAttribute(name, value) {
|
1569
|
+
// if attribute exists, use it
|
1570
|
+
var attr = this.attributes.getNamedItem(name);
|
1571
|
+
|
1572
|
+
if (!attr) {
|
1573
|
+
attr = this.ownerDocument.createAttribute(name); // otherwise create it
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
var value = new String(value);
|
1577
|
+
|
1578
|
+
// test for exceptions
|
1579
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
1580
|
+
// throw Exception if Attribute is readonly
|
1581
|
+
if (attr._readonly) {
|
1582
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
// throw Exception if the value string contains an illegal character
|
1586
|
+
if (!this.ownerDocument.implementation._isValidString(value)) {
|
1587
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1588
|
+
}
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
if (this.ownerDocument.implementation._isIdDeclaration(name)) {
|
1592
|
+
this.id = value; // cache ID for getElementById()
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
// assign values to properties (and aliases)
|
1596
|
+
attr.value = value;
|
1597
|
+
attr.nodeValue = value;
|
1598
|
+
|
1599
|
+
// update .specified
|
1600
|
+
if (value.length > 0) {
|
1601
|
+
attr.specified = true;
|
1602
|
+
}
|
1603
|
+
else {
|
1604
|
+
attr.specified = false;
|
1605
|
+
}
|
1606
|
+
|
1607
|
+
// add/replace Attribute in NamedNodeMap
|
1608
|
+
this.attributes.setNamedItem(attr);
|
1609
|
+
};
|
1610
|
+
|
1611
|
+
/**
|
1612
|
+
* @method W3CDOMElement.removeAttribute - Removes an attribute by name
|
1613
|
+
*
|
1614
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1615
|
+
*
|
1616
|
+
* @param name : string - The name of the attribute to remove
|
1617
|
+
*
|
1618
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if the Attrbute is readonly.
|
1619
|
+
*/
|
1620
|
+
W3CDOMElement.prototype.removeAttribute = function W3CDOMElement_removeAttribute(name) {
|
1621
|
+
// delegate to W3CDOMNamedNodeMap.removeNamedItem
|
1622
|
+
return this.attributes.removeNamedItem(name);
|
1623
|
+
};
|
1624
|
+
|
1625
|
+
/**
|
1626
|
+
* @method W3CDOMElement.getAttributeNode - Retrieves an Attr node by name
|
1627
|
+
*
|
1628
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1629
|
+
*
|
1630
|
+
* @param name : string - The name of the attribute to remove
|
1631
|
+
*
|
1632
|
+
* @return : W3CDOMAttr - The Attr node with the specified attribute name or null if there is no such attribute.
|
1633
|
+
*/
|
1634
|
+
W3CDOMElement.prototype.getAttributeNode = function W3CDOMElement_getAttributeNode(name) {
|
1635
|
+
// delegate to W3CDOMNamedNodeMap.getNamedItem
|
1636
|
+
return this.attributes.getNamedItem(name);
|
1637
|
+
};
|
1638
|
+
|
1639
|
+
/**
|
1640
|
+
* @method W3CDOMElement.setAttributeNode - Adds a new attribute
|
1641
|
+
* If an attribute with that name is already present in the element, it is replaced by the new one
|
1642
|
+
*
|
1643
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1644
|
+
*
|
1645
|
+
* @param newAttr : W3CDOMAttr - The attribute node to be attached
|
1646
|
+
*
|
1647
|
+
* @throws : W3CDOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
|
1648
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Element is readonly.
|
1649
|
+
* @throws : W3CDOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object.
|
1650
|
+
*
|
1651
|
+
* @return : W3CDOMAttr - If the newAttr attribute replaces an existing attribute with the same name,
|
1652
|
+
* the previously existing Attr node is returned, otherwise null is returned.
|
1653
|
+
*/
|
1654
|
+
W3CDOMElement.prototype.setAttributeNode = function W3CDOMElement_setAttributeNode(newAttr) {
|
1655
|
+
// if this Attribute is an ID
|
1656
|
+
if (this.ownerDocument.implementation._isIdDeclaration(newAttr.name)) {
|
1657
|
+
this.id = newAttr.value; // cache ID for getElementById()
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
// delegate to W3CDOMNamedNodeMap.setNamedItem
|
1661
|
+
return this.attributes.setNamedItem(newAttr);
|
1662
|
+
};
|
1663
|
+
|
1664
|
+
/**
|
1665
|
+
* @method W3CDOMElement.removeAttributeNode - Removes the specified attribute
|
1666
|
+
*
|
1667
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1668
|
+
*
|
1669
|
+
* @param oldAttr : W3CDOMAttr - The Attr node to remove from the attribute list
|
1670
|
+
*
|
1671
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Element is readonly.
|
1672
|
+
* @throws : W3CDOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object.
|
1673
|
+
*
|
1674
|
+
* @return : W3CDOMAttr - The Attr node that was removed.
|
1675
|
+
*/
|
1676
|
+
W3CDOMElement.prototype.removeAttributeNode = function W3CDOMElement_removeAttributeNode(oldAttr) {
|
1677
|
+
// throw Exception if Attribute is readonly
|
1678
|
+
if (this.ownerDocument.implementation.errorChecking && oldAttr._readonly) {
|
1679
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
1680
|
+
}
|
1681
|
+
|
1682
|
+
// get item index
|
1683
|
+
var itemIndex = this.attributes._findItemIndex(oldAttr._id);
|
1684
|
+
|
1685
|
+
// throw Exception if node does not exist in this map
|
1686
|
+
if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) {
|
1687
|
+
throw(new W3CDOMException(W3CDOMException.NOT_FOUND_ERR));
|
1688
|
+
}
|
1689
|
+
|
1690
|
+
return this.attributes._removeChild(itemIndex);
|
1691
|
+
};
|
1692
|
+
|
1693
|
+
/**
|
1694
|
+
* @method W3CDOMElement.getAttributeNS - Retrieves an attribute value by namespaceURI and localName
|
1695
|
+
*
|
1696
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1697
|
+
*
|
1698
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
1699
|
+
* @param localName : string - the local name of the required node
|
1700
|
+
*
|
1701
|
+
* @return : string - The Attr value as a string, or the empty string if that attribute does not have a specified value.
|
1702
|
+
*/
|
1703
|
+
W3CDOMElement.prototype.getAttributeNS = function W3CDOMElement_getAttributeNS(namespaceURI, localName) {
|
1704
|
+
var ret = "";
|
1705
|
+
|
1706
|
+
// delegate to W3CDOMNAmedNodeMap.getNamedItemNS
|
1707
|
+
var attr = this.attributes.getNamedItemNS(namespaceURI, localName);
|
1708
|
+
|
1709
|
+
|
1710
|
+
if (attr) {
|
1711
|
+
ret = attr.value;
|
1712
|
+
}
|
1713
|
+
|
1714
|
+
return ret; // if Attribute exists, return its value, otherwise return ""
|
1715
|
+
};
|
1716
|
+
|
1717
|
+
/**
|
1718
|
+
* @method W3CDOMElement.setAttributeNS - Sets an attribute value by namespaceURI and localName
|
1719
|
+
*
|
1720
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1721
|
+
*
|
1722
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
1723
|
+
* @param qualifiedName : string - the qualified name of the required node
|
1724
|
+
* @param value : string - Value to set in string form
|
1725
|
+
*
|
1726
|
+
* @throws : W3CDOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character
|
1727
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if the Attrbute is readonly.
|
1728
|
+
* @throws : W3CDOMException - NAMESPACE_ERR: Raised if the Namespace is invalid
|
1729
|
+
*/
|
1730
|
+
W3CDOMElement.prototype.setAttributeNS = function W3CDOMElement_setAttributeNS(namespaceURI, qualifiedName, value) {
|
1731
|
+
// call W3CDOMNamedNodeMap.getNamedItem
|
1732
|
+
var attr = this.attributes.getNamedItem(namespaceURI, qualifiedName);
|
1733
|
+
|
1734
|
+
if (!attr) { // if Attribute exists, use it
|
1735
|
+
// otherwise create it
|
1736
|
+
attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
1737
|
+
}
|
1738
|
+
|
1739
|
+
var value = new String(value);
|
1740
|
+
|
1741
|
+
// test for exceptions
|
1742
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
1743
|
+
// throw Exception if Attribute is readonly
|
1744
|
+
if (attr._readonly) {
|
1745
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
1746
|
+
}
|
1747
|
+
|
1748
|
+
// throw Exception if the Namespace is invalid
|
1749
|
+
if (!this.ownerDocument._isValidNamespace(namespaceURI, qualifiedName)) {
|
1750
|
+
throw(new W3CDOMException(W3CDOMException.NAMESPACE_ERR));
|
1751
|
+
}
|
1752
|
+
|
1753
|
+
// throw Exception if the value string contains an illegal character
|
1754
|
+
if (!this.ownerDocument.implementation._isValidString(value)) {
|
1755
|
+
throw(new W3CDOMException(W3CDOMException.INVALID_CHARACTER_ERR));
|
1756
|
+
}
|
1757
|
+
}
|
1758
|
+
|
1759
|
+
// if this Attribute is an ID
|
1760
|
+
if (this.ownerDocument.implementation._isIdDeclaration(name)) {
|
1761
|
+
this.id = value; // cache ID for getElementById()
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
// assign values to properties (and aliases)
|
1765
|
+
attr.value = value;
|
1766
|
+
attr.nodeValue = value;
|
1767
|
+
|
1768
|
+
// update .specified
|
1769
|
+
if (value.length > 0) {
|
1770
|
+
attr.specified = true;
|
1771
|
+
}
|
1772
|
+
else {
|
1773
|
+
attr.specified = false;
|
1774
|
+
}
|
1775
|
+
|
1776
|
+
// delegate to W3CDOMNamedNodeMap.setNamedItem
|
1777
|
+
this.attributes.setNamedItemNS(attr);
|
1778
|
+
};
|
1779
|
+
|
1780
|
+
/**
|
1781
|
+
* @method W3CDOMElement.removeAttributeNS - Removes an attribute by namespaceURI and localName
|
1782
|
+
*
|
1783
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1784
|
+
*
|
1785
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
1786
|
+
* @param localName : string - the local name of the required node
|
1787
|
+
*
|
1788
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if the Attrbute is readonly.
|
1789
|
+
*
|
1790
|
+
* @return : W3CDOMAttr
|
1791
|
+
*/
|
1792
|
+
W3CDOMElement.prototype.removeAttributeNS = function W3CDOMElement_removeAttributeNS(namespaceURI, localName) {
|
1793
|
+
// delegate to W3CDOMNamedNodeMap.removeNamedItemNS
|
1794
|
+
return this.attributes.removeNamedItemNS(namespaceURI, localName);
|
1795
|
+
};
|
1796
|
+
|
1797
|
+
/**
|
1798
|
+
* @method W3CDOMElement.getAttributeNodeNS - Retrieves an Attr node by namespaceURI and localName
|
1799
|
+
*
|
1800
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1801
|
+
*
|
1802
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
1803
|
+
* @param localName : string - the local name of the required node
|
1804
|
+
*
|
1805
|
+
* @return : W3CDOMAttr - The Attr node with the specified attribute name or null if there is no such attribute.
|
1806
|
+
*/
|
1807
|
+
W3CDOMElement.prototype.getAttributeNodeNS = function W3CDOMElement_getAttributeNodeNS(namespaceURI, localName) {
|
1808
|
+
// delegate to W3CDOMNamedNodeMap.getNamedItemNS
|
1809
|
+
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
1810
|
+
};
|
1811
|
+
|
1812
|
+
/**
|
1813
|
+
* @method W3CDOMElement.setAttributeNodeNS - Adds a new attribute
|
1814
|
+
* If an attribute with that name is already present in the element, it is replaced by the new one
|
1815
|
+
*
|
1816
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1817
|
+
*
|
1818
|
+
* @param newAttr : W3CDOMAttr - the attribute node to be attached
|
1819
|
+
*
|
1820
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if the Attrbute is readonly.
|
1821
|
+
* @throws : W3CDOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
|
1822
|
+
* @throws : W3CDOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object.
|
1823
|
+
* The W3CDOM user must explicitly clone Attr nodes to re-use them in other elements.
|
1824
|
+
*
|
1825
|
+
* @return : W3CDOMAttr - If the newAttr attribute replaces an existing attribute with the same name,
|
1826
|
+
* the previously existing Attr node is returned, otherwise null is returned.
|
1827
|
+
*/
|
1828
|
+
W3CDOMElement.prototype.setAttributeNodeNS = function W3CDOMElement_setAttributeNodeNS(newAttr) {
|
1829
|
+
// if this Attribute is an ID
|
1830
|
+
if ((newAttr.prefix == "") && this.ownerDocument.implementation._isIdDeclaration(newAttr.name)) {
|
1831
|
+
this.id = newAttr.value; // cache ID for getElementById()
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
// delegate to W3CDOMNamedNodeMap.setNamedItemNS
|
1835
|
+
return this.attributes.setNamedItemNS(newAttr);
|
1836
|
+
};
|
1837
|
+
|
1838
|
+
/**
|
1839
|
+
* @method W3CDOMElement.hasAttribute - Returns true if specified node exists
|
1840
|
+
*
|
1841
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1842
|
+
*
|
1843
|
+
* @param name : string - the name of the required node
|
1844
|
+
*
|
1845
|
+
* @return : boolean
|
1846
|
+
*/
|
1847
|
+
W3CDOMElement.prototype.hasAttribute = function W3CDOMElement_hasAttribute(name) {
|
1848
|
+
// delegate to W3CDOMNamedNodeMap._hasAttribute
|
1849
|
+
return this.attributes._hasAttribute(name);
|
1850
|
+
}
|
1851
|
+
|
1852
|
+
/**
|
1853
|
+
* @method W3CDOMElement.hasAttributeNS - Returns true if specified node exists
|
1854
|
+
*
|
1855
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1856
|
+
*
|
1857
|
+
* @param namespaceURI : string - the namespace URI of the required node
|
1858
|
+
* @param localName : string - the local name of the required node
|
1859
|
+
*
|
1860
|
+
* @return : boolean
|
1861
|
+
*/
|
1862
|
+
W3CDOMElement.prototype.hasAttributeNS = function W3CDOMElement_hasAttributeNS(namespaceURI, localName) {
|
1863
|
+
// delegate to W3CDOMNamedNodeMap._hasAttributeNS
|
1864
|
+
return this.attributes._hasAttributeNS(namespaceURI, localName);
|
1865
|
+
}
|
1866
|
+
|
1867
|
+
/**
|
1868
|
+
* @method W3CDOMElement.toString - Serialize this Element and its children into an XML string
|
1869
|
+
*
|
1870
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
1871
|
+
*
|
1872
|
+
* @return : string
|
1873
|
+
*/
|
1874
|
+
W3CDOMElement.prototype.toString = function W3CDOMElement_toString() {
|
1875
|
+
var ret = "";
|
1876
|
+
|
1877
|
+
// serialize namespace declarations
|
1878
|
+
var ns = this._namespaces.toString();
|
1879
|
+
if (ns.length > 0) ns = " "+ ns;
|
1880
|
+
|
1881
|
+
// serialize Attribute declarations
|
1882
|
+
var attrs = this.attributes.toString();
|
1883
|
+
if (attrs.length > 0) attrs = " "+ attrs;
|
1884
|
+
|
1885
|
+
// serialize this Element
|
1886
|
+
ret += "<" + this.nodeName + ns + attrs +">";
|
1887
|
+
ret += this.childNodes.toString();;
|
1888
|
+
ret += "</" + this.nodeName+">";
|
1889
|
+
|
1890
|
+
return ret;
|
1891
|
+
}
|
1892
|
+
|
1893
|
+
/**
|
1894
|
+
* @class W3CDOMAttr - The Attr interface represents an attribute in an Element object
|
1895
|
+
*
|
1896
|
+
* @extends W3CDOMNode
|
1897
|
+
*
|
1898
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1899
|
+
*
|
1900
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
1901
|
+
*/
|
1902
|
+
W3CDOMAttr = function(ownerDocument) {
|
1903
|
+
this._class = addClass(this._class, "W3CDOMAttr");
|
1904
|
+
this.W3CDOMNode = W3CDOMNode;
|
1905
|
+
this.W3CDOMNode(ownerDocument);
|
1906
|
+
|
1907
|
+
this.name = ""; // the name of this attribute
|
1908
|
+
|
1909
|
+
// If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false.
|
1910
|
+
// Note that the implementation is in charge of this attribute, not the user.
|
1911
|
+
// If the user changes the value of the attribute (even if it ends up having the same value as the default value)
|
1912
|
+
// then the specified flag is automatically flipped to true
|
1913
|
+
// (I wish! You will need to use setValue to 'automatically' update specified)
|
1914
|
+
this.specified = false;
|
1915
|
+
|
1916
|
+
this.value = ""; // the value of the attribute is returned as a string
|
1917
|
+
|
1918
|
+
this.nodeType = W3CDOMNode.ATTRIBUTE_NODE;
|
1919
|
+
|
1920
|
+
this.ownerElement = null; // set when Attr is added to NamedNodeMap
|
1921
|
+
|
1922
|
+
// disable childNodes
|
1923
|
+
this.childNodes = null;
|
1924
|
+
this.attributes = null;
|
1925
|
+
};
|
1926
|
+
W3CDOMAttr.prototype = new W3CDOMNode;
|
1927
|
+
|
1928
|
+
/**
|
1929
|
+
* @method W3CDOMAttr.getName - Java style gettor for .name
|
1930
|
+
*
|
1931
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1932
|
+
*
|
1933
|
+
* @return : string
|
1934
|
+
*/
|
1935
|
+
W3CDOMAttr.prototype.getName = function W3CDOMAttr_getName() {
|
1936
|
+
return this.nodeName;
|
1937
|
+
};
|
1938
|
+
|
1939
|
+
/**
|
1940
|
+
* @method W3CDOMAttr.getSpecified - Java style gettor for .specified
|
1941
|
+
*
|
1942
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1943
|
+
*
|
1944
|
+
* @return : boolean
|
1945
|
+
*/
|
1946
|
+
W3CDOMAttr.prototype.getSpecified = function W3CDOMAttr_getSpecified() {
|
1947
|
+
return this.specified;
|
1948
|
+
};
|
1949
|
+
|
1950
|
+
/**
|
1951
|
+
* @method W3CDOMAttr.getValue - Java style gettor for .value
|
1952
|
+
*
|
1953
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1954
|
+
*
|
1955
|
+
* @return : string
|
1956
|
+
*/
|
1957
|
+
W3CDOMAttr.prototype.getValue = function W3CDOMAttr_getValue() {
|
1958
|
+
return this.nodeValue;
|
1959
|
+
};
|
1960
|
+
|
1961
|
+
/**
|
1962
|
+
* @method W3CDOMAttr.setValue - Java style settor for .value
|
1963
|
+
* alias for W3CDOMAttr.setNodeValue
|
1964
|
+
*
|
1965
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1966
|
+
*
|
1967
|
+
* @param value : string - the new attribute value
|
1968
|
+
*
|
1969
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Attribute is readonly.
|
1970
|
+
*/
|
1971
|
+
W3CDOMAttr.prototype.setValue = function W3CDOMAttr_setValue(value) {
|
1972
|
+
// throw Exception if Attribute is readonly
|
1973
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
1974
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
1975
|
+
}
|
1976
|
+
|
1977
|
+
// delegate to setNodeValue
|
1978
|
+
this.setNodeValue(value);
|
1979
|
+
};
|
1980
|
+
|
1981
|
+
/**
|
1982
|
+
* @method W3CDOMAttr.setNodeValue - Java style settor for .nodeValue
|
1983
|
+
*
|
1984
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
1985
|
+
*
|
1986
|
+
* @param value : string - the new attribute value
|
1987
|
+
*/
|
1988
|
+
W3CDOMAttr.prototype.setNodeValue = function W3CDOMAttr_setNodeValue(value) {
|
1989
|
+
this.nodeValue = new String(value);
|
1990
|
+
this.value = this.nodeValue;
|
1991
|
+
this.specified = (this.value.length > 0);
|
1992
|
+
};
|
1993
|
+
|
1994
|
+
/**
|
1995
|
+
* @method W3CDOMAttr.toString - Serialize this Attr into an XML string
|
1996
|
+
*
|
1997
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
1998
|
+
*
|
1999
|
+
* @return : string
|
2000
|
+
*/
|
2001
|
+
W3CDOMAttr.prototype.toString = function W3CDOMAttr_toString() {
|
2002
|
+
var ret = "";
|
2003
|
+
|
2004
|
+
// serialize Attribute
|
2005
|
+
ret += this.nodeName +"=\""+ this.__escapeString(this.nodeValue) +"\"";
|
2006
|
+
|
2007
|
+
return ret;
|
2008
|
+
}
|
2009
|
+
|
2010
|
+
W3CDOMAttr.prototype.getOwnerElement = function() {
|
2011
|
+
|
2012
|
+
return this.ownerElement;
|
2013
|
+
|
2014
|
+
}
|
2015
|
+
|
2016
|
+
/**
|
2017
|
+
* @class W3CDOMNamespace - The Namespace interface represents an namespace in an Element object
|
2018
|
+
*
|
2019
|
+
* @extends W3CDOMNode
|
2020
|
+
*
|
2021
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2022
|
+
*
|
2023
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2024
|
+
*/
|
2025
|
+
W3CDOMNamespace = function(ownerDocument) {
|
2026
|
+
this._class = addClass(this._class, "W3CDOMNamespace");
|
2027
|
+
this.W3CDOMNode = W3CDOMNode;
|
2028
|
+
this.W3CDOMNode(ownerDocument);
|
2029
|
+
|
2030
|
+
this.name = ""; // the name of this attribute
|
2031
|
+
|
2032
|
+
// If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false.
|
2033
|
+
// Note that the implementation is in charge of this attribute, not the user.
|
2034
|
+
// If the user changes the value of the attribute (even if it ends up having the same value as the default value)
|
2035
|
+
// then the specified flag is automatically flipped to true
|
2036
|
+
// (I wish! You will need to use _setValue to 'automatically' update specified)
|
2037
|
+
this.specified = false;
|
2038
|
+
|
2039
|
+
this.value = ""; // the value of the attribute is returned as a string
|
2040
|
+
|
2041
|
+
this.nodeType = W3CDOMNode.NAMESPACE_NODE;
|
2042
|
+
};
|
2043
|
+
W3CDOMNamespace.prototype = new W3CDOMNode;
|
2044
|
+
|
2045
|
+
/**
|
2046
|
+
* @method W3CDOMNamespace.getValue - Java style gettor for .value
|
2047
|
+
*
|
2048
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2049
|
+
*
|
2050
|
+
* @return : string
|
2051
|
+
*/
|
2052
|
+
W3CDOMNamespace.prototype.getValue = function W3CDOMNamespace_getValue() {
|
2053
|
+
return this.nodeValue;
|
2054
|
+
};
|
2055
|
+
|
2056
|
+
/**
|
2057
|
+
* @method W3CDOMNamespace.setValue - utility function to set value (rather than direct assignment to .value)
|
2058
|
+
*
|
2059
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2060
|
+
*
|
2061
|
+
* @param value : string - the new namespace value
|
2062
|
+
*/
|
2063
|
+
W3CDOMNamespace.prototype.setValue = function W3CDOMNamespace_setValue(value) {
|
2064
|
+
// assign values to properties (and aliases)
|
2065
|
+
this.nodeValue = new String(value);
|
2066
|
+
this.value = this.nodeValue;
|
2067
|
+
};
|
2068
|
+
|
2069
|
+
/**
|
2070
|
+
* @method W3CDOMNamespace.toString - Serialize this Attr into an XML string
|
2071
|
+
*
|
2072
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2073
|
+
*
|
2074
|
+
* @return : string
|
2075
|
+
*/
|
2076
|
+
W3CDOMNamespace.prototype.toString = function W3CDOMNamespace_toString() {
|
2077
|
+
var ret = "";
|
2078
|
+
|
2079
|
+
// serialize Namespace Declaration
|
2080
|
+
if (this.nodeName != "") {
|
2081
|
+
ret += this.nodeName +"=\""+ this.__escapeString(this.nodeValue) +"\"";
|
2082
|
+
}
|
2083
|
+
else { // handle default namespace
|
2084
|
+
ret += "xmlns=\""+ this.__escapeString(this.nodeValue) +"\"";
|
2085
|
+
}
|
2086
|
+
|
2087
|
+
return ret;
|
2088
|
+
}
|
2089
|
+
|
2090
|
+
/**
|
2091
|
+
* @class W3CDOMCharacterData - parent abstract class for W3CDOMText and W3CDOMComment
|
2092
|
+
*
|
2093
|
+
* @extends W3CDOMNode
|
2094
|
+
*
|
2095
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2096
|
+
*
|
2097
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2098
|
+
*/
|
2099
|
+
W3CDOMCharacterData = function(ownerDocument) {
|
2100
|
+
this._class = addClass(this._class, "W3CDOMCharacterData");
|
2101
|
+
this.W3CDOMNode = W3CDOMNode;
|
2102
|
+
this.W3CDOMNode(ownerDocument);
|
2103
|
+
|
2104
|
+
this.data = "";
|
2105
|
+
this.length = 0;
|
2106
|
+
};
|
2107
|
+
W3CDOMCharacterData.prototype = new W3CDOMNode;
|
2108
|
+
|
2109
|
+
/**
|
2110
|
+
* @method W3CDOMCharacterData.getData - Java style gettor for .data
|
2111
|
+
*
|
2112
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2113
|
+
*
|
2114
|
+
* @return : string
|
2115
|
+
*/
|
2116
|
+
W3CDOMCharacterData.prototype.getData = function W3CDOMCharacterData_getData() {
|
2117
|
+
return this.nodeValue;
|
2118
|
+
};
|
2119
|
+
|
2120
|
+
/**
|
2121
|
+
* @method W3CDOMCharacterData.setData - Java style settor for .data
|
2122
|
+
* alias for W3CDOMCharacterData.setNodeValue
|
2123
|
+
*
|
2124
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2125
|
+
*
|
2126
|
+
* @param data : string - the character data
|
2127
|
+
*
|
2128
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Attribute is readonly.
|
2129
|
+
*/
|
2130
|
+
W3CDOMCharacterData.prototype.setData = function W3CDOMCharacterData_setData(data) {
|
2131
|
+
// delegate to setNodeValue
|
2132
|
+
this.setNodeValue(data);
|
2133
|
+
};
|
2134
|
+
|
2135
|
+
/**
|
2136
|
+
* @method W3CDOMCharacterData.setNodeValue - Java style settor for .nodeValue
|
2137
|
+
*
|
2138
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2139
|
+
*
|
2140
|
+
* @param data : string - the node value
|
2141
|
+
*
|
2142
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Attribute is readonly.
|
2143
|
+
*/
|
2144
|
+
W3CDOMCharacterData.prototype.setNodeValue = function W3CDOMCharacterData_setNodeValue(data) {
|
2145
|
+
// throw Exception if Attribute is readonly
|
2146
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
2147
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2148
|
+
}
|
2149
|
+
|
2150
|
+
// assign values to properties (and aliases)
|
2151
|
+
this.nodeValue = new String(data);
|
2152
|
+
this.data = this.nodeValue;
|
2153
|
+
|
2154
|
+
// update length
|
2155
|
+
this.length = this.nodeValue.length;
|
2156
|
+
};
|
2157
|
+
|
2158
|
+
/**
|
2159
|
+
* @method W3CDOMCharacterData.getLength - Java style gettor for .length
|
2160
|
+
*
|
2161
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2162
|
+
*
|
2163
|
+
* @return : string
|
2164
|
+
*/
|
2165
|
+
W3CDOMCharacterData.prototype.getLength = function W3CDOMCharacterData_getLength() {
|
2166
|
+
return this.nodeValue.length;
|
2167
|
+
};
|
2168
|
+
|
2169
|
+
/**
|
2170
|
+
* @method W3CDOMCharacterData.substringData - Extracts a range of data from the node
|
2171
|
+
*
|
2172
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2173
|
+
*
|
2174
|
+
* @param offset : int - Start offset of substring to extract
|
2175
|
+
* @param count : int - The number of characters to extract
|
2176
|
+
*
|
2177
|
+
* @throws : W3CDOMException - INDEX_SIZE_ERR: Raised if specified offset is negative or greater than the number of 16-bit units in data,
|
2178
|
+
*
|
2179
|
+
* @return : string - The specified substring.
|
2180
|
+
* If the sum of offset and count exceeds the length, then all characters to the end of the data are returned.
|
2181
|
+
*/
|
2182
|
+
W3CDOMCharacterData.prototype.substringData = function W3CDOMCharacterData_substringData(offset, count) {
|
2183
|
+
var ret = null;
|
2184
|
+
|
2185
|
+
if (this.data) {
|
2186
|
+
// throw Exception if offset is negative or greater than the data length,
|
2187
|
+
// or the count is negative
|
2188
|
+
if (this.ownerDocument.implementation.errorChecking && ((offset < 0) || (offset > this.data.length) || (count < 0))) {
|
2189
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2190
|
+
}
|
2191
|
+
|
2192
|
+
// if count is not specified
|
2193
|
+
if (!count) {
|
2194
|
+
ret = this.data.substring(offset); // default to 'end of string'
|
2195
|
+
}
|
2196
|
+
else {
|
2197
|
+
ret = this.data.substring(offset, offset + count);
|
2198
|
+
}
|
2199
|
+
}
|
2200
|
+
|
2201
|
+
return ret;
|
2202
|
+
};
|
2203
|
+
|
2204
|
+
/**
|
2205
|
+
* @method W3CDOMCharacterData.appendData - Append the string to the end of the character data of the node.
|
2206
|
+
* Upon success, data provides access to the concatenation of data and the W3CDOMString specified.
|
2207
|
+
*
|
2208
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2209
|
+
*
|
2210
|
+
* @param arg : string - The string to append
|
2211
|
+
*
|
2212
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this CharacterData is readonly.
|
2213
|
+
*/
|
2214
|
+
W3CDOMCharacterData.prototype.appendData = function W3CDOMCharacterData_appendData(arg) {
|
2215
|
+
// throw Exception if W3CDOMCharacterData is readonly
|
2216
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
2217
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2218
|
+
}
|
2219
|
+
|
2220
|
+
// append data
|
2221
|
+
this.setData(""+ this.data + arg);
|
2222
|
+
};
|
2223
|
+
|
2224
|
+
/**
|
2225
|
+
* @method W3CDOMCharacterData.insertData - Insert a string at the specified character offset.
|
2226
|
+
*
|
2227
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2228
|
+
*
|
2229
|
+
* @param offset : int - The character offset at which to insert
|
2230
|
+
* @param arg : string - The string to insert
|
2231
|
+
*
|
2232
|
+
* @throws : W3CDOMException - INDEX_SIZE_ERR: Raised if specified offset is negative or greater than the number of 16-bit units in data,
|
2233
|
+
* or if the specified count is negative.
|
2234
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this CharacterData is readonly.
|
2235
|
+
*/
|
2236
|
+
W3CDOMCharacterData.prototype.insertData = function W3CDOMCharacterData_insertData(offset, arg) {
|
2237
|
+
// throw Exception if W3CDOMCharacterData is readonly
|
2238
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
2239
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2240
|
+
}
|
2241
|
+
|
2242
|
+
if (this.data) {
|
2243
|
+
// throw Exception if offset is negative or greater than the data length,
|
2244
|
+
if (this.ownerDocument.implementation.errorChecking && ((offset < 0) || (offset > this.data.length))) {
|
2245
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2246
|
+
}
|
2247
|
+
|
2248
|
+
// insert data
|
2249
|
+
this.setData(this.data.substring(0, offset).concat(arg, this.data.substring(offset)));
|
2250
|
+
}
|
2251
|
+
else {
|
2252
|
+
// throw Exception if offset is negative or greater than the data length,
|
2253
|
+
if (this.ownerDocument.implementation.errorChecking && (offset != 0)) {
|
2254
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2255
|
+
}
|
2256
|
+
|
2257
|
+
// set data
|
2258
|
+
this.setData(arg);
|
2259
|
+
}
|
2260
|
+
};
|
2261
|
+
|
2262
|
+
/**
|
2263
|
+
* @method W3CDOMCharacterData.deleteData - Remove a range of characters from the node.
|
2264
|
+
* Upon success, data and length reflect the change
|
2265
|
+
*
|
2266
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2267
|
+
*
|
2268
|
+
* @param offset : int - The offset from which to remove characters
|
2269
|
+
* @param count : int - The number of characters to delete.
|
2270
|
+
* If the sum of offset and count exceeds length then all characters from offset to the end of the data are deleted
|
2271
|
+
*
|
2272
|
+
* @throws : W3CDOMException - INDEX_SIZE_ERR: Raised if specified offset is negative or greater than the number of 16-bit units in data,
|
2273
|
+
* or if the specified count is negative.
|
2274
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this CharacterData is readonly.
|
2275
|
+
*/
|
2276
|
+
W3CDOMCharacterData.prototype.deleteData = function W3CDOMCharacterData_deleteData(offset, count) {
|
2277
|
+
// throw Exception if W3CDOMCharacterData is readonly
|
2278
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
2279
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2280
|
+
}
|
2281
|
+
|
2282
|
+
if (this.data) {
|
2283
|
+
// throw Exception if offset is negative or greater than the data length,
|
2284
|
+
if (this.ownerDocument.implementation.errorChecking && ((offset < 0) || (offset > this.data.length) || (count < 0))) {
|
2285
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2286
|
+
}
|
2287
|
+
|
2288
|
+
// delete data
|
2289
|
+
if(!count || (offset + count) > this.data.length) {
|
2290
|
+
this.setData(this.data.substring(0, offset));
|
2291
|
+
}
|
2292
|
+
else {
|
2293
|
+
this.setData(this.data.substring(0, offset).concat(this.data.substring(offset + count)));
|
2294
|
+
}
|
2295
|
+
}
|
2296
|
+
};
|
2297
|
+
|
2298
|
+
/**
|
2299
|
+
* @method W3CDOMCharacterData.replaceData - Replace the characters starting at the specified character offset with the specified string
|
2300
|
+
*
|
2301
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2302
|
+
*
|
2303
|
+
* @param offset : int - The offset from which to start replacing
|
2304
|
+
* @param count : int - The number of characters to replace.
|
2305
|
+
* If the sum of offset and count exceeds length, then all characters to the end of the data are replaced
|
2306
|
+
* @param arg : string - The string with which the range must be replaced
|
2307
|
+
*
|
2308
|
+
* @throws : W3CDOMException - INDEX_SIZE_ERR: Raised if specified offset is negative or greater than the number of 16-bit units in data,
|
2309
|
+
* or if the specified count is negative.
|
2310
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this CharacterData is readonly.
|
2311
|
+
*/
|
2312
|
+
W3CDOMCharacterData.prototype.replaceData = function W3CDOMCharacterData_replaceData(offset, count, arg) {
|
2313
|
+
// throw Exception if W3CDOMCharacterData is readonly
|
2314
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
2315
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2316
|
+
}
|
2317
|
+
|
2318
|
+
if (this.data) {
|
2319
|
+
// throw Exception if offset is negative or greater than the data length,
|
2320
|
+
if (this.ownerDocument.implementation.errorChecking && ((offset < 0) || (offset > this.data.length) || (count < 0))) {
|
2321
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2322
|
+
}
|
2323
|
+
|
2324
|
+
// replace data
|
2325
|
+
this.setData(this.data.substring(0, offset).concat(arg, this.data.substring(offset + count)));
|
2326
|
+
}
|
2327
|
+
else {
|
2328
|
+
// set data
|
2329
|
+
this.setData(arg);
|
2330
|
+
}
|
2331
|
+
};
|
2332
|
+
|
2333
|
+
/**
|
2334
|
+
* @class W3CDOMText - The Text interface represents the textual content (termed character data in XML) of an Element or Attr.
|
2335
|
+
* If there is no markup inside an element's content, the text is contained in a single object implementing the Text interface
|
2336
|
+
* that is the only child of the element. If there is markup, it is parsed into a list of elements and Text nodes that form the
|
2337
|
+
* list of children of the element.
|
2338
|
+
*
|
2339
|
+
* @extends W3CDOMCharacterData
|
2340
|
+
*
|
2341
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2342
|
+
*
|
2343
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2344
|
+
*/
|
2345
|
+
W3CDOMText = function(ownerDocument) {
|
2346
|
+
this._class = addClass(this._class, "W3CDOMText");
|
2347
|
+
this.W3CDOMCharacterData = W3CDOMCharacterData;
|
2348
|
+
this.W3CDOMCharacterData(ownerDocument);
|
2349
|
+
|
2350
|
+
this.nodeName = "#text";
|
2351
|
+
this.nodeType = W3CDOMNode.TEXT_NODE;
|
2352
|
+
};
|
2353
|
+
W3CDOMText.prototype = new W3CDOMCharacterData;
|
2354
|
+
|
2355
|
+
/**
|
2356
|
+
* @method W3CDOMText.splitText - Breaks this Text node into two Text nodes at the specified offset,
|
2357
|
+
* keeping both in the tree as siblings. This node then only contains all the content up to the offset point.
|
2358
|
+
* And a new Text node, which is inserted as the next sibling of this node, contains all the content at and after the offset point.
|
2359
|
+
*
|
2360
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2361
|
+
*
|
2362
|
+
* @param offset : int - The offset at which to split, starting from 0.
|
2363
|
+
*
|
2364
|
+
* @throws : W3CDOMException - INDEX_SIZE_ERR: Raised if specified offset is negative or greater than the number of 16-bit units in data,
|
2365
|
+
* @throws : W3CDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Text is readonly.
|
2366
|
+
*
|
2367
|
+
* @return : W3CDOMText - The new Text node
|
2368
|
+
*/
|
2369
|
+
W3CDOMText.prototype.splitText = function W3CDOMText_splitText(offset) {
|
2370
|
+
var data, inode;
|
2371
|
+
|
2372
|
+
// test for exceptions
|
2373
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
2374
|
+
// throw Exception if Node is readonly
|
2375
|
+
if (this._readonly) {
|
2376
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2377
|
+
}
|
2378
|
+
|
2379
|
+
// throw Exception if offset is negative or greater than the data length,
|
2380
|
+
if ((offset < 0) || (offset > this.data.length)) {
|
2381
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2382
|
+
}
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
if (this.parentNode) {
|
2386
|
+
// get remaining string (after offset)
|
2387
|
+
data = this.substringData(offset);
|
2388
|
+
|
2389
|
+
// create new TextNode with remaining string
|
2390
|
+
inode = this.ownerDocument.createTextNode(data);
|
2391
|
+
|
2392
|
+
// attach new TextNode
|
2393
|
+
if (this.nextSibling) {
|
2394
|
+
this.parentNode.insertBefore(inode, this.nextSibling);
|
2395
|
+
}
|
2396
|
+
else {
|
2397
|
+
this.parentNode.appendChild(inode);
|
2398
|
+
}
|
2399
|
+
|
2400
|
+
// remove remaining string from original TextNode
|
2401
|
+
this.deleteData(offset);
|
2402
|
+
}
|
2403
|
+
|
2404
|
+
return inode;
|
2405
|
+
};
|
2406
|
+
|
2407
|
+
/**
|
2408
|
+
* @method W3CDOMText.toString - Serialize this Text into an XML string
|
2409
|
+
*
|
2410
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
2411
|
+
*
|
2412
|
+
* @return : string
|
2413
|
+
*/
|
2414
|
+
W3CDOMText.prototype.toString = function W3CDOMText_toString() {
|
2415
|
+
return this.__escapeString(""+ this.nodeValue);
|
2416
|
+
}
|
2417
|
+
|
2418
|
+
/**
|
2419
|
+
* @class W3CDOMCDATASection - CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup.
|
2420
|
+
* The only delimiter that is recognized in a CDATA section is the "\]\]\>" string that ends the CDATA section
|
2421
|
+
*
|
2422
|
+
* @extends W3CDOMCharacterData
|
2423
|
+
*
|
2424
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2425
|
+
*
|
2426
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2427
|
+
*/
|
2428
|
+
W3CDOMCDATASection = function(ownerDocument) {
|
2429
|
+
this._class = addClass(this._class, "W3CDOMCDATASection");
|
2430
|
+
this.W3CDOMCharacterData = W3CDOMCharacterData;
|
2431
|
+
this.W3CDOMCharacterData(ownerDocument);
|
2432
|
+
|
2433
|
+
this.nodeName = "#cdata-section";
|
2434
|
+
this.nodeType = W3CDOMNode.CDATA_SECTION_NODE;
|
2435
|
+
};
|
2436
|
+
W3CDOMCDATASection.prototype = new W3CDOMCharacterData;
|
2437
|
+
|
2438
|
+
/**
|
2439
|
+
* @method W3CDOMCDATASection.splitText - Breaks this CDATASection node into two CDATASection nodes at the specified offset,
|
2440
|
+
* keeping both in the tree as siblings. This node then only contains all the content up to the offset point.
|
2441
|
+
* And a new CDATASection node, which is inserted as the next sibling of this node, contains all the content at and after the offset point.
|
2442
|
+
*
|
2443
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2444
|
+
*
|
2445
|
+
* @param offset : int - The offset at which to split, starting from 0.
|
2446
|
+
*
|
2447
|
+
* @return : W3CDOMCDATASection - The new CDATASection node
|
2448
|
+
*/
|
2449
|
+
W3CDOMCDATASection.prototype.splitText = function W3CDOMCDATASection_splitText(offset) {
|
2450
|
+
var data, inode;
|
2451
|
+
|
2452
|
+
// test for exceptions
|
2453
|
+
if (this.ownerDocument.implementation.errorChecking) {
|
2454
|
+
// throw Exception if Node is readonly
|
2455
|
+
if (this._readonly) {
|
2456
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2457
|
+
}
|
2458
|
+
|
2459
|
+
// throw Exception if offset is negative or greater than the data length,
|
2460
|
+
if ((offset < 0) || (offset > this.data.length)) {
|
2461
|
+
throw(new W3CDOMException(W3CDOMException.INDEX_SIZE_ERR));
|
2462
|
+
}
|
2463
|
+
}
|
2464
|
+
|
2465
|
+
if(this.parentNode) {
|
2466
|
+
// get remaining string (after offset)
|
2467
|
+
data = this.substringData(offset);
|
2468
|
+
|
2469
|
+
// create new CDATANode with remaining string
|
2470
|
+
inode = this.ownerDocument.createCDATASection(data);
|
2471
|
+
|
2472
|
+
// attach new CDATANode
|
2473
|
+
if (this.nextSibling) {
|
2474
|
+
this.parentNode.insertBefore(inode, this.nextSibling);
|
2475
|
+
}
|
2476
|
+
else {
|
2477
|
+
this.parentNode.appendChild(inode);
|
2478
|
+
}
|
2479
|
+
|
2480
|
+
// remove remaining string from original CDATANode
|
2481
|
+
this.deleteData(offset);
|
2482
|
+
}
|
2483
|
+
|
2484
|
+
return inode;
|
2485
|
+
};
|
2486
|
+
|
2487
|
+
/**
|
2488
|
+
* @method W3CDOMCDATASection.toString - Serialize this CDATASection into an XML string
|
2489
|
+
*
|
2490
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
2491
|
+
*
|
2492
|
+
* @return : string
|
2493
|
+
*/
|
2494
|
+
W3CDOMCDATASection.prototype.toString = function W3CDOMCDATASection_toString() {
|
2495
|
+
var ret = "";
|
2496
|
+
//do NOT unescape the nodeValue string in CDATA sections!
|
2497
|
+
ret += "<![CDATA[" + this.nodeValue + "\]\]\>";
|
2498
|
+
|
2499
|
+
return ret;
|
2500
|
+
}
|
2501
|
+
|
2502
|
+
/**
|
2503
|
+
* @class W3CDOMComment - This represents the content of a comment, i.e., all the characters between the starting '<!--' and ending '-->'
|
2504
|
+
*
|
2505
|
+
* @extends W3CDOMCharacterData
|
2506
|
+
*
|
2507
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2508
|
+
*
|
2509
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2510
|
+
*/
|
2511
|
+
W3CDOMComment = function(ownerDocument) {
|
2512
|
+
this._class = addClass(this._class, "W3CDOMComment");
|
2513
|
+
this.W3CDOMCharacterData = W3CDOMCharacterData;
|
2514
|
+
this.W3CDOMCharacterData(ownerDocument);
|
2515
|
+
|
2516
|
+
this.nodeName = "#comment";
|
2517
|
+
this.nodeType = W3CDOMNode.COMMENT_NODE;
|
2518
|
+
};
|
2519
|
+
W3CDOMComment.prototype = new W3CDOMCharacterData;
|
2520
|
+
|
2521
|
+
/**
|
2522
|
+
* @method W3CDOMComment.toString - Serialize this Comment into an XML string
|
2523
|
+
*
|
2524
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
2525
|
+
*
|
2526
|
+
* @return : string
|
2527
|
+
*/
|
2528
|
+
W3CDOMComment.prototype.toString = function W3CDOMComment_toString() {
|
2529
|
+
var ret = "";
|
2530
|
+
|
2531
|
+
ret += "<!--" + this.nodeValue + "-->";
|
2532
|
+
|
2533
|
+
return ret;
|
2534
|
+
}
|
2535
|
+
|
2536
|
+
/**
|
2537
|
+
* @class W3CDOMProcessingInstruction - The ProcessingInstruction interface represents a "processing instruction",
|
2538
|
+
* used in XML as a way to keep processor-specific information in the text of the document
|
2539
|
+
*
|
2540
|
+
* @extends W3CDOMNode
|
2541
|
+
*
|
2542
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2543
|
+
*
|
2544
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2545
|
+
*/
|
2546
|
+
W3CDOMProcessingInstruction = function(ownerDocument) {
|
2547
|
+
this._class = addClass(this._class, "W3CDOMProcessingInstruction");
|
2548
|
+
this.W3CDOMNode = W3CDOMNode;
|
2549
|
+
this.W3CDOMNode(ownerDocument);
|
2550
|
+
|
2551
|
+
// The target of this processing instruction.
|
2552
|
+
// XML defines this as being the first token following the markup that begins the processing instruction.
|
2553
|
+
this.target = "";
|
2554
|
+
|
2555
|
+
// The content of this processing instruction.
|
2556
|
+
// This is from the first non white space character after the target to the character immediately preceding the ?>
|
2557
|
+
this.data = "";
|
2558
|
+
|
2559
|
+
this.nodeType = W3CDOMNode.PROCESSING_INSTRUCTION_NODE;
|
2560
|
+
};
|
2561
|
+
W3CDOMProcessingInstruction.prototype = new W3CDOMNode;
|
2562
|
+
|
2563
|
+
/**
|
2564
|
+
* @method W3CDOMProcessingInstruction.getTarget - Java style gettor for .target
|
2565
|
+
*
|
2566
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2567
|
+
*
|
2568
|
+
* @return : string
|
2569
|
+
*/
|
2570
|
+
W3CDOMProcessingInstruction.prototype.getTarget = function W3CDOMProcessingInstruction_getTarget() {
|
2571
|
+
return this.nodeName;
|
2572
|
+
};
|
2573
|
+
|
2574
|
+
/**
|
2575
|
+
* @method W3CDOMProcessingInstruction.getData - Java style gettor for .data
|
2576
|
+
*
|
2577
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2578
|
+
*
|
2579
|
+
* @return : string
|
2580
|
+
*/
|
2581
|
+
W3CDOMProcessingInstruction.prototype.getData = function W3CDOMProcessingInstruction_getData() {
|
2582
|
+
return this.nodeValue;
|
2583
|
+
};
|
2584
|
+
|
2585
|
+
/**
|
2586
|
+
* @method W3CDOMProcessingInstruction.setData - Java style settor for .data
|
2587
|
+
* alias for W3CDOMProcessingInstruction.setNodeValue
|
2588
|
+
*
|
2589
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2590
|
+
*
|
2591
|
+
* @param data : string - The new data of this processing instruction.
|
2592
|
+
*/
|
2593
|
+
W3CDOMProcessingInstruction.prototype.setData = function W3CDOMProcessingInstruction_setData(data) {
|
2594
|
+
// delegate to setNodeValue
|
2595
|
+
this.setNodeValue(data);
|
2596
|
+
};
|
2597
|
+
|
2598
|
+
/**
|
2599
|
+
* @method W3CDOMProcessingInstruction.setNodeValue - Java style settor for .nodeValue
|
2600
|
+
*
|
2601
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2602
|
+
*
|
2603
|
+
* @param data : string - The new data of this processing instruction.
|
2604
|
+
*/
|
2605
|
+
W3CDOMProcessingInstruction.prototype.setNodeValue = function W3CDOMProcessingInstruction_setNodeValue(data) {
|
2606
|
+
// throw Exception if W3CDOMNode is readonly
|
2607
|
+
if (this.ownerDocument.implementation.errorChecking && this._readonly) {
|
2608
|
+
throw(new W3CDOMException(W3CDOMException.NO_MODIFICATION_ALLOWED_ERR));
|
2609
|
+
}
|
2610
|
+
|
2611
|
+
// assign values to properties (and aliases)
|
2612
|
+
this.nodeValue = new String(data);
|
2613
|
+
this.data = this.nodeValue;
|
2614
|
+
};
|
2615
|
+
|
2616
|
+
/**
|
2617
|
+
* @method W3CDOMProcessingInstruction.toString - Serialize this ProcessingInstruction into an XML string
|
2618
|
+
*
|
2619
|
+
* @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
|
2620
|
+
*
|
2621
|
+
* @return : string
|
2622
|
+
*/
|
2623
|
+
W3CDOMProcessingInstruction.prototype.toString = function W3CDOMProcessingInstruction_toString() {
|
2624
|
+
var ret = "";
|
2625
|
+
|
2626
|
+
ret += "<?" + this.nodeName +" "+ this.nodeValue + " ?>";
|
2627
|
+
|
2628
|
+
return ret;
|
2629
|
+
}
|
2630
|
+
|
2631
|
+
/**
|
2632
|
+
* @class W3CDOMDocumentFragment - DocumentFragment is a "lightweight" or "minimal" Document object.
|
2633
|
+
*
|
2634
|
+
* @extends W3CDOMNode
|
2635
|
+
*
|
2636
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
2637
|
+
*
|
2638
|
+
* @param ownerDocument : W3CDOMDocument - The Document object associated with this node.
|
2639
|
+
*/
|
2640
|
+
W3CDOMDocumentFragment = function(ownerDocument) {
|
2641
|
+
this._class = addClass(this._class, "W3CDOMDocumentFragment");
|
2642
|
+
this.W3CDOMNode = W3CDOMNode;
|
2643
|
+
this.W3CDOMNode(ownerDocument);
|
2644
|
+
|
2645
|
+
this.nodeName = "#document-fragment";
|
2646
|
+
this.nodeType = W3CDOMNode.DOCUMENT_FRAGMENT_NODE;
|
2647
|
+
};
|
2648
|
+
W3CDOMDocumentFragment.prototype = new W3CDOMNode;
|
2649
|
+
|
2650
|
+
/**
|
2651
|
+
* @method W3CDOMDocumentFragment.toString - Serialize this DocumentFragment into an XML string
|
2652
|
+
*
|
2653
|
+
* @author David Joham (djoham@yahoo.com)
|
2654
|
+
*
|
2655
|
+
* @return : string
|
2656
|
+
*/
|
2657
|
+
W3CDOMDocumentFragment.prototype.toString = function W3CDOMDocumentFragment_toString() {
|
2658
|
+
var xml = "";
|
2659
|
+
var intCount = this.getChildNodes().getLength();
|
2660
|
+
|
2661
|
+
// create string concatenating the serialized ChildNodes
|
2662
|
+
for (intLoop = 0; intLoop < intCount; intLoop++) {
|
2663
|
+
xml += this.getChildNodes().item(intLoop).toString();
|
2664
|
+
}
|
2665
|
+
|
2666
|
+
return xml;
|
2667
|
+
}
|
2668
|
+
|
2669
|
+
///////////////////////
|
2670
|
+
// NOT IMPLEMENTED //
|
2671
|
+
///////////////////////
|
2672
|
+
W3CDOMDocumentType = function() { alert("W3CDOMDocumentType.constructor(): Not Implemented" ); };
|
2673
|
+
W3CDOMEntity = function() { alert("W3CDOMEntity.constructor(): Not Implemented" ); };
|
2674
|
+
W3CDOMEntityReference = function() { alert("W3CDOMEntityReference.constructor(): Not Implemented"); };
|
2675
|
+
W3CDOMNotation = function() { alert("W3CDOMNotation.constructor(): Not Implemented" ); };
|
2676
|
+
|
2677
|
+
|
2678
|
+
Strings = new Object()
|
2679
|
+
Strings.WHITESPACE = " \t\n\r";
|
2680
|
+
Strings.QUOTES = "\"'";
|
2681
|
+
|
2682
|
+
Strings.isEmpty = function Strings_isEmpty(strD) {
|
2683
|
+
return (strD == null) || (strD.length == 0);
|
2684
|
+
};
|
2685
|
+
Strings.indexOfNonWhitespace = function Strings_indexOfNonWhitespace(strD, iB, iE) {
|
2686
|
+
if(Strings.isEmpty(strD)) return -1;
|
2687
|
+
iB = iB || 0;
|
2688
|
+
iE = iE || strD.length;
|
2689
|
+
|
2690
|
+
for(var i = iB; i < iE; i++)
|
2691
|
+
if(Strings.WHITESPACE.indexOf(strD.charAt(i)) == -1) {
|
2692
|
+
return i;
|
2693
|
+
}
|
2694
|
+
return -1;
|
2695
|
+
};
|
2696
|
+
Strings.lastIndexOfNonWhitespace = function Strings_lastIndexOfNonWhitespace(strD, iB, iE) {
|
2697
|
+
if(Strings.isEmpty(strD)) return -1;
|
2698
|
+
iB = iB || 0;
|
2699
|
+
iE = iE || strD.length;
|
2700
|
+
|
2701
|
+
for(var i = iE - 1; i >= iB; i--)
|
2702
|
+
if(Strings.WHITESPACE.indexOf(strD.charAt(i)) == -1)
|
2703
|
+
return i;
|
2704
|
+
return -1;
|
2705
|
+
};
|
2706
|
+
Strings.indexOfWhitespace = function Strings_indexOfWhitespace(strD, iB, iE) {
|
2707
|
+
if(Strings.isEmpty(strD)) return -1;
|
2708
|
+
iB = iB || 0;
|
2709
|
+
iE = iE || strD.length;
|
2710
|
+
|
2711
|
+
for(var i = iB; i < iE; i++)
|
2712
|
+
if(Strings.WHITESPACE.indexOf(strD.charAt(i)) != -1)
|
2713
|
+
return i;
|
2714
|
+
return -1;
|
2715
|
+
};
|
2716
|
+
Strings.replace = function Strings_replace(strD, iB, iE, strF, strR) {
|
2717
|
+
if(Strings.isEmpty(strD)) return "";
|
2718
|
+
iB = iB || 0;
|
2719
|
+
iE = iE || strD.length;
|
2720
|
+
|
2721
|
+
return strD.substring(iB, iE).split(strF).join(strR);
|
2722
|
+
};
|
2723
|
+
Strings.getLineNumber = function Strings_getLineNumber(strD, iP) {
|
2724
|
+
if(Strings.isEmpty(strD)) return -1;
|
2725
|
+
iP = iP || strD.length;
|
2726
|
+
|
2727
|
+
return strD.substring(0, iP).split("\n").length
|
2728
|
+
};
|
2729
|
+
Strings.getColumnNumber = function Strings_getColumnNumber(strD, iP) {
|
2730
|
+
if(Strings.isEmpty(strD)) return -1;
|
2731
|
+
iP = iP || strD.length;
|
2732
|
+
|
2733
|
+
var arrD = strD.substring(0, iP).split("\n");
|
2734
|
+
var strLine = arrD[arrD.length - 1];
|
2735
|
+
arrD.length--;
|
2736
|
+
var iLinePos = arrD.join("\n").length;
|
2737
|
+
|
2738
|
+
return iP - iLinePos;
|
2739
|
+
};
|
2740
|
+
|
2741
|
+
|
2742
|
+
StringBuffer = function() {this._a=new Array();};
|
2743
|
+
StringBuffer.prototype.append = function StringBuffer_append(d){this._a[this._a.length]=d;};
|
2744
|
+
StringBuffer.prototype.toString = function StringBuffer_toString(){return this._a.join("");};
|