Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/worker-xml.js

raw symbols SCIP
1 "no use strict";
2 !(function(window) {
3 if (typeof window.window != "undefined" && window.document)
4 return;
5 if (window.require && window.define)
6 return;
7
8 if (!window.console) {
9 window.console = function() {
10 var msgs = Array.prototype.slice.call(arguments, 0);
11 postMessage({type: "log", data: msgs});
12 };
13 window.console.error =
14 window.console.warn =
15 window.console.log =
16 window.console.trace = window.console;
17 }
18 window.window = window;
19 window.ace = window;
20
21 window.onerror = function(message, file, line, col, err) {
22 postMessage({type: "error", data: {
23 message: message,
24 data: err && err.data,
25 file: file,
26 line: line,
27 col: col,
28 stack: err && err.stack
29 }});
30 };
31
32 window.normalizeModule = function(parentId, moduleName) {
33 // normalize plugin requires
34 if (moduleName.indexOf("!") !== -1) {
35 var chunks = moduleName.split("!");
36 return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
37 }
38 // normalize relative requires
39 if (moduleName.charAt(0) == ".") {
40 var base = parentId.split("/").slice(0, -1).join("/");
41 moduleName = (base ? base + "/" : "") + moduleName;
42
43 while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
44 var previous = moduleName;
45 moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
46 }
47 }
48
49 return moduleName;
50 };
51
52 window.require = function require(parentId, id) {
53 if (!id) {
54 id = parentId;
55 parentId = null;
56 }
57 if (!id.charAt)
58 throw new Error("worker.js require() accepts only (parentId, id) as arguments");
59
60 id = window.normalizeModule(parentId, id);
61
62 var module = window.require.modules[id];
63 if (module) {
64 if (!module.initialized) {
65 module.initialized = true;
66 module.exports = module.factory().exports;
67 }
68 return module.exports;
69 }
70
71 if (!window.require.tlns)
72 return console.log("unable to load " + id);
73
74 var path = resolveModuleId(id, window.require.tlns);
75 if (path.slice(-3) != ".js") path += ".js";
76
77 window.require.id = id;
78 window.require.modules[id] = {}; // prevent infinite loop on broken modules
79 importScripts(path);
80 return window.require(parentId, id);
81 };
82 function resolveModuleId(id, paths) {
83 var testPath = id, tail = "";
84 while (testPath) {
85 var alias = paths[testPath];
86 if (typeof alias == "string") {
87 return alias + tail;
88 } else if (alias) {
89 return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
90 } else if (alias === false) {
91 return "";
92 }
93 var i = testPath.lastIndexOf("/");
94 if (i === -1) break;
95 tail = testPath.substr(i) + tail;
96 testPath = testPath.slice(0, i);
97 }
98 return id;
99 }
100 window.require.modules = {};
101 window.require.tlns = {};
102
103 window.define = function(id, deps, factory) {
104 if (arguments.length == 2) {
105 factory = deps;
106 if (typeof id != "string") {
107 deps = id;
108 id = window.require.id;
109 }
110 } else if (arguments.length == 1) {
111 factory = id;
112 deps = [];
113 id = window.require.id;
114 }
115
116 if (typeof factory != "function") {
117 window.require.modules[id] = {
118 exports: factory,
119 initialized: true
120 };
121 return;
122 }
123
124 if (!deps.length)
125 // If there is no dependencies, we inject "require", "exports" and
126 // "module" as dependencies, to provide CommonJS compatibility.
127 deps = ["require", "exports", "module"];
128
129 var req = function(childId) {
130 return window.require(id, childId);
131 };
132
133 window.require.modules[id] = {
134 exports: {},
135 factory: function() {
136 var module = this;
137 var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
138 switch (dep) {
139 // Because "require", "exports" and "module" aren't actual
140 // dependencies, we must handle them seperately.
141 case "require": return req;
142 case "exports": return module.exports;
143 case "module": return module;
144 // But for all other dependencies, we can just go ahead and
145 // require them.
146 default: return req(dep);
147 }
148 }));
149 if (returnExports)
150 module.exports = returnExports;
151 return module;
152 }
153 };
154 };
155 window.define.amd = {};
156 window.require.tlns = {};
157 window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
158 for (var i in topLevelNamespaces)
159 this.require.tlns[i] = topLevelNamespaces[i];
160 };
161
162 window.initSender = function initSender() {
163
164 var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
165 var oop = window.require("ace/lib/oop");
166
167 var Sender = function() {};
168
169 (function() {
170
171 oop.implement(this, EventEmitter);
172
173 this.callback = function(data, callbackId) {
174 postMessage({
175 type: "call",
176 id: callbackId,
177 data: data
178 });
179 };
180
181 this.emit = function(name, data) {
182 postMessage({
183 type: "event",
184 name: name,
185 data: data
186 });
187 };
188
189 }).call(Sender.prototype);
190
191 return new Sender();
192 };
193
194 var main = window.main = null;
195 var sender = window.sender = null;
196
197 window.onmessage = function(e) {
198 var msg = e.data;
199 if (msg.event && sender) {
200 sender._signal(msg.event, msg.data);
201 }
202 else if (msg.command) {
203 if (main[msg.command])
204 main[msg.command].apply(main, msg.args);
205 else if (window[msg.command])
206 window[msg.command].apply(window, msg.args);
207 else
208 throw new Error("Unknown command:" + msg.command);
209 }
210 else if (msg.init) {
211 window.initBaseUrls(msg.tlns);
212 sender = window.sender = window.initSender();
213 var clazz = this.require(msg.module)[msg.classname];
214 main = window.main = new clazz(sender);
215 }
216 };
217 })(this);
218
219 ace.define("ace/lib/oop",[], function(require, exports, module){"use strict";
220 exports.inherits = function (ctor, superCtor) {
221 ctor.super_ = superCtor;
222 ctor.prototype = Object.create(superCtor.prototype, {
223 constructor: {
224 value: ctor,
225 enumerable: false,
226 writable: true,
227 configurable: true
228 }
229 });
230 };
231 exports.mixin = function (obj, mixin) {
232 for (var key in mixin) {
233 obj[key] = mixin[key];
234 }
235 return obj;
236 };
237 exports.implement = function (proto, mixin) {
238 exports.mixin(proto, mixin);
239 };
240
241 });
242
243 ace.define("ace/lib/deep_copy",[], function(require, exports, module){exports.deepCopy = function deepCopy(obj) {
244 if (typeof obj !== "object" || !obj)
245 return obj;
246 var copy;
247 if (Array.isArray(obj)) {
248 copy = [];
249 for (var key = 0; key < obj.length; key++) {
250 copy[key] = deepCopy(obj[key]);
251 }
252 return copy;
253 }
254 if (Object.prototype.toString.call(obj) !== "[object Object]")
255 return obj;
256 copy = {};
257 for (var key in obj)
258 copy[key] = deepCopy(obj[key]);
259 return copy;
260 };
261
262 });
263
264 ace.define("ace/lib/lang",[], function(require, exports, module){"use strict";
265 exports.last = function (a) {
266 return a[a.length - 1];
267 };
268 exports.stringReverse = function (string) {
269 return string.split("").reverse().join("");
270 };
271 exports.stringRepeat = function (string, count) {
272 var result = '';
273 while (count > 0) {
274 if (count & 1)
275 result += string;
276 if (count >>= 1)
277 string += string;
278 }
279 return result;
280 };
281 var trimBeginRegexp = /^\s\s*/;
282 var trimEndRegexp = /\s\s*$/;
283 exports.stringTrimLeft = function (string) {
284 return string.replace(trimBeginRegexp, '');
285 };
286 exports.stringTrimRight = function (string) {
287 return string.replace(trimEndRegexp, '');
288 };
289 exports.copyObject = function (obj) {
290 var copy = {};
291 for (var key in obj) {
292 copy[key] = obj[key];
293 }
294 return copy;
295 };
296 exports.copyArray = function (array) {
297 var copy = [];
298 for (var i = 0, l = array.length; i < l; i++) {
299 if (array[i] && typeof array[i] == "object")
300 copy[i] = this.copyObject(array[i]);
301 else
302 copy[i] = array[i];
303 }
304 return copy;
305 };
306 exports.deepCopy = require("./deep_copy").deepCopy;
307 exports.arrayToMap = function (arr) {
308 var map = {};
309 for (var i = 0; i < arr.length; i++) {
310 map[arr[i]] = 1;
311 }
312 return map;
313 };
314 exports.createMap = function (props) {
315 var map = Object.create(null);
316 for (var i in props) {
317 map[i] = props[i];
318 }
319 return map;
320 };
321 exports.arrayRemove = function (array, value) {
322 for (var i = 0; i <= array.length; i++) {
323 if (value === array[i]) {
324 array.splice(i, 1);
325 }
326 }
327 };
328 exports.escapeRegExp = function (str) {
329 return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
330 };
331 exports.escapeHTML = function (str) {
332 return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
333 };
334 exports.getMatchOffsets = function (string, regExp) {
335 var matches = [];
336 string.replace(regExp, function (str) {
337 matches.push({
338 offset: arguments[arguments.length - 2],
339 length: str.length
340 });
341 });
342 return matches;
343 };
344 exports.deferredCall = function (fcn) {
345 var timer = null;
346 var callback = function () {
347 timer = null;
348 fcn();
349 };
350 var deferred = function (timeout) {
351 deferred.cancel();
352 timer = setTimeout(callback, timeout || 0);
353 return deferred;
354 };
355 deferred.schedule = deferred;
356 deferred.call = function () {
357 this.cancel();
358 fcn();
359 return deferred;
360 };
361 deferred.cancel = function () {
362 clearTimeout(timer);
363 timer = null;
364 return deferred;
365 };
366 deferred.isPending = function () {
367 return timer;
368 };
369 return deferred;
370 };
371 exports.delayedCall = function (fcn, defaultTimeout) {
372 var timer = null;
373 var callback = function () {
374 timer = null;
375 fcn();
376 };
377 var _self = function (timeout) {
378 if (timer == null)
379 timer = setTimeout(callback, timeout || defaultTimeout);
380 };
381 _self.delay = function (timeout) {
382 timer && clearTimeout(timer);
383 timer = setTimeout(callback, timeout || defaultTimeout);
384 };
385 _self.schedule = _self;
386 _self.call = function () {
387 this.cancel();
388 fcn();
389 };
390 _self.cancel = function () {
391 timer && clearTimeout(timer);
392 timer = null;
393 };
394 _self.isPending = function () {
395 return timer;
396 };
397 return _self;
398 };
399 exports.supportsLookbehind = function () {
400 try {
401 new RegExp('(?<=.)');
402 }
403 catch (e) {
404 return false;
405 }
406 return true;
407 };
408 exports.skipEmptyMatch = function (line, last, supportsUnicodeFlag) {
409 return supportsUnicodeFlag && line.codePointAt(last) > 0xffff ? 2 : 1;
410 };
411
412 });
413
414 ace.define("ace/apply_delta",[], function(require, exports, module){"use strict";
415 function throwDeltaError(delta, errorText) {
416 console.log("Invalid Delta:", delta);
417 throw "Invalid Delta: " + errorText;
418 }
419 function positionInDocument(docLines, position) {
420 return position.row >= 0 && position.row < docLines.length &&
421 position.column >= 0 && position.column <= docLines[position.row].length;
422 }
423 function validateDelta(docLines, delta) {
424 if (delta.action != "insert" && delta.action != "remove")
425 throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
426 if (!(delta.lines instanceof Array))
427 throwDeltaError(delta, "delta.lines must be an Array");
428 if (!delta.start || !delta.end)
429 throwDeltaError(delta, "delta.start/end must be an present");
430 var start = delta.start;
431 if (!positionInDocument(docLines, delta.start))
432 throwDeltaError(delta, "delta.start must be contained in document");
433 var end = delta.end;
434 if (delta.action == "remove" && !positionInDocument(docLines, end))
435 throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
436 var numRangeRows = end.row - start.row;
437 var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
438 if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
439 throwDeltaError(delta, "delta.range must match delta lines");
440 }
441 exports.applyDelta = function (docLines, delta, doNotValidate) {
442 var row = delta.start.row;
443 var startColumn = delta.start.column;
444 var line = docLines[row] || "";
445 switch (delta.action) {
446 case "insert":
447 var lines = delta.lines;
448 if (lines.length === 1) {
449 docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
450 }
451 else {
452 var args = [row, 1].concat(delta.lines);
453 docLines.splice.apply(docLines, args);
454 docLines[row] = line.substring(0, startColumn) + docLines[row];
455 docLines[row + delta.lines.length - 1] += line.substring(startColumn);
456 }
457 break;
458 case "remove":
459 var endColumn = delta.end.column;
460 var endRow = delta.end.row;
461 if (row === endRow) {
462 docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
463 }
464 else {
465 docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn));
466 }
467 break;
468 }
469 };
470
471 });
472
473 ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict";
474 var EventEmitter = {};
475 var stopPropagation = function () { this.propagationStopped = true; };
476 var preventDefault = function () { this.defaultPrevented = true; };
477 EventEmitter._emit =
478 EventEmitter._dispatchEvent = function (eventName, e) {
479 this._eventRegistry || (this._eventRegistry = {});
480 this._defaultHandlers || (this._defaultHandlers = {});
481 var listeners = this._eventRegistry[eventName] || [];
482 var defaultHandler = this._defaultHandlers[eventName];
483 if (!listeners.length && !defaultHandler)
484 return;
485 if (typeof e != "object" || !e)
486 e = {};
487 if (!e.type)
488 e.type = eventName;
489 if (!e.stopPropagation)
490 e.stopPropagation = stopPropagation;
491 if (!e.preventDefault)
492 e.preventDefault = preventDefault;
493 listeners = listeners.slice();
494 for (var i = 0; i < listeners.length; i++) {
495 listeners[i](e, this);
496 if (e.propagationStopped)
497 break;
498 }
499 if (defaultHandler && !e.defaultPrevented)
500 return defaultHandler(e, this);
501 };
502 EventEmitter._signal = function (eventName, e) {
503 var listeners = (this._eventRegistry || {})[eventName];
504 if (!listeners)
505 return;
506 listeners = listeners.slice();
507 for (var i = 0; i < listeners.length; i++)
508 listeners[i](e, this);
509 };
510 EventEmitter.once = function (eventName, callback) {
511 var _self = this;
512 this.on(eventName, function newCallback() {
513 _self.off(eventName, newCallback);
514 callback.apply(null, arguments);
515 });
516 if (!callback) {
517 return new Promise(function (resolve) {
518 callback = resolve;
519 });
520 }
521 };
522 EventEmitter.setDefaultHandler = function (eventName, callback) {
523 var handlers = this._defaultHandlers;
524 if (!handlers)
525 handlers = this._defaultHandlers = { _disabled_: {} };
526 if (handlers[eventName]) {
527 var old = handlers[eventName];
528 var disabled = handlers._disabled_[eventName];
529 if (!disabled)
530 handlers._disabled_[eventName] = disabled = [];
531 disabled.push(old);
532 var i = disabled.indexOf(callback);
533 if (i != -1)
534 disabled.splice(i, 1);
535 }
536 handlers[eventName] = callback;
537 };
538 EventEmitter.removeDefaultHandler = function (eventName, callback) {
539 var handlers = this._defaultHandlers;
540 if (!handlers)
541 return;
542 var disabled = handlers._disabled_[eventName];
543 if (handlers[eventName] == callback) {
544 if (disabled)
545 this.setDefaultHandler(eventName, disabled.pop());
546 }
547 else if (disabled) {
548 var i = disabled.indexOf(callback);
549 if (i != -1)
550 disabled.splice(i, 1);
551 }
552 };
553 EventEmitter.on =
554 EventEmitter.addEventListener = function (eventName, callback, capturing) {
555 this._eventRegistry = this._eventRegistry || {};
556 var listeners = this._eventRegistry[eventName];
557 if (!listeners)
558 listeners = this._eventRegistry[eventName] = [];
559 if (listeners.indexOf(callback) == -1)
560 listeners[capturing ? "unshift" : "push"](callback);
561 return callback;
562 };
563 EventEmitter.off =
564 EventEmitter.removeListener =
565 EventEmitter.removeEventListener = function (eventName, callback) {
566 this._eventRegistry = this._eventRegistry || {};
567 var listeners = this._eventRegistry[eventName];
568 if (!listeners)
569 return;
570 var index = listeners.indexOf(callback);
571 if (index !== -1)
572 listeners.splice(index, 1);
573 };
574 EventEmitter.removeAllListeners = function (eventName) {
575 if (!eventName)
576 this._eventRegistry = this._defaultHandlers = undefined;
577 if (this._eventRegistry)
578 this._eventRegistry[eventName] = undefined;
579 if (this._defaultHandlers)
580 this._defaultHandlers[eventName] = undefined;
581 };
582 exports.EventEmitter = EventEmitter;
583
584 });
585
586 ace.define("ace/range",[], function(require, exports, module){"use strict";
587 var Range = /** @class */ (function () {
588 function Range(startRow, startColumn, endRow, endColumn) {
589 this.start = {
590 row: startRow,
591 column: startColumn
592 };
593 this.end = {
594 row: endRow,
595 column: endColumn
596 };
597 }
598 Range.prototype.isEqual = function (range) {
599 return this.start.row === range.start.row &&
600 this.end.row === range.end.row &&
601 this.start.column === range.start.column &&
602 this.end.column === range.end.column;
603 };
604 Range.prototype.toString = function () {
605 return ("Range: [" + this.start.row + "/" + this.start.column +
606 "] -> [" + this.end.row + "/" + this.end.column + "]");
607 };
608 Range.prototype.contains = function (row, column) {
609 return this.compare(row, column) == 0;
610 };
611 Range.prototype.compareRange = function (range) {
612 var cmp, end = range.end, start = range.start;
613 cmp = this.compare(end.row, end.column);
614 if (cmp == 1) {
615 cmp = this.compare(start.row, start.column);
616 if (cmp == 1) {
617 return 2;
618 }
619 else if (cmp == 0) {
620 return 1;
621 }
622 else {
623 return 0;
624 }
625 }
626 else if (cmp == -1) {
627 return -2;
628 }
629 else {
630 cmp = this.compare(start.row, start.column);
631 if (cmp == -1) {
632 return -1;
633 }
634 else if (cmp == 1) {
635 return 42;
636 }
637 else {
638 return 0;
639 }
640 }
641 };
642 Range.prototype.comparePoint = function (p) {
643 return this.compare(p.row, p.column);
644 };
645 Range.prototype.containsRange = function (range) {
646 return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
647 };
648 Range.prototype.intersects = function (range) {
649 var cmp = this.compareRange(range);
650 return (cmp == -1 || cmp == 0 || cmp == 1);
651 };
652 Range.prototype.isEnd = function (row, column) {
653 return this.end.row == row && this.end.column == column;
654 };
655 Range.prototype.isStart = function (row, column) {
656 return this.start.row == row && this.start.column == column;
657 };
658 Range.prototype.setStart = function (row, column) {
659 if (typeof row == "object") {
660 this.start.column = row.column;
661 this.start.row = row.row;
662 }
663 else {
664 this.start.row = row;
665 this.start.column = column;
666 }
667 };
668 Range.prototype.setEnd = function (row, column) {
669 if (typeof row == "object") {
670 this.end.column = row.column;
671 this.end.row = row.row;
672 }
673 else {
674 this.end.row = row;
675 this.end.column = column;
676 }
677 };
678 Range.prototype.inside = function (row, column) {
679 if (this.compare(row, column) == 0) {
680 if (this.isEnd(row, column) || this.isStart(row, column)) {
681 return false;
682 }
683 else {
684 return true;
685 }
686 }
687 return false;
688 };
689 Range.prototype.insideStart = function (row, column) {
690 if (this.compare(row, column) == 0) {
691 if (this.isEnd(row, column)) {
692 return false;
693 }
694 else {
695 return true;
696 }
697 }
698 return false;
699 };
700 Range.prototype.insideEnd = function (row, column) {
701 if (this.compare(row, column) == 0) {
702 if (this.isStart(row, column)) {
703 return false;
704 }
705 else {
706 return true;
707 }
708 }
709 return false;
710 };
711 Range.prototype.compare = function (row, column) {
712 if (!this.isMultiLine()) {
713 if (row === this.start.row) {
714 return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
715 }
716 }
717 if (row < this.start.row)
718 return -1;
719 if (row > this.end.row)
720 return 1;
721 if (this.start.row === row)
722 return column >= this.start.column ? 0 : -1;
723 if (this.end.row === row)
724 return column <= this.end.column ? 0 : 1;
725 return 0;
726 };
727 Range.prototype.compareStart = function (row, column) {
728 if (this.start.row == row && this.start.column == column) {
729 return -1;
730 }
731 else {
732 return this.compare(row, column);
733 }
734 };
735 Range.prototype.compareEnd = function (row, column) {
736 if (this.end.row == row && this.end.column == column) {
737 return 1;
738 }
739 else {
740 return this.compare(row, column);
741 }
742 };
743 Range.prototype.compareInside = function (row, column) {
744 if (this.end.row == row && this.end.column == column) {
745 return 1;
746 }
747 else if (this.start.row == row && this.start.column == column) {
748 return -1;
749 }
750 else {
751 return this.compare(row, column);
752 }
753 };
754 Range.prototype.clipRows = function (firstRow, lastRow) {
755 if (this.end.row > lastRow)
756 var end = { row: lastRow + 1, column: 0 };
757 else if (this.end.row < firstRow)
758 var end = { row: firstRow, column: 0 };
759 if (this.start.row > lastRow)
760 var start = { row: lastRow + 1, column: 0 };
761 else if (this.start.row < firstRow)
762 var start = { row: firstRow, column: 0 };
763 return Range.fromPoints(start || this.start, end || this.end);
764 };
765 Range.prototype.extend = function (row, column) {
766 var cmp = this.compare(row, column);
767 if (cmp == 0)
768 return this;
769 else if (cmp == -1)
770 var start = { row: row, column: column };
771 else
772 var end = { row: row, column: column };
773 return Range.fromPoints(start || this.start, end || this.end);
774 };
775 Range.prototype.isEmpty = function () {
776 return (this.start.row === this.end.row && this.start.column === this.end.column);
777 };
778 Range.prototype.isMultiLine = function () {
779 return (this.start.row !== this.end.row);
780 };
781 Range.prototype.clone = function () {
782 return Range.fromPoints(this.start, this.end);
783 };
784 Range.prototype.collapseRows = function () {
785 if (this.end.column == 0)
786 return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0);
787 else
788 return new Range(this.start.row, 0, this.end.row, 0);
789 };
790 Range.prototype.toScreenRange = function (session) {
791 var screenPosStart = session.documentToScreenPosition(this.start);
792 var screenPosEnd = session.documentToScreenPosition(this.end);
793 return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column);
794 };
795 Range.prototype.moveBy = function (row, column) {
796 this.start.row += row;
797 this.start.column += column;
798 this.end.row += row;
799 this.end.column += column;
800 };
801 return Range;
802 }());
803 Range.fromPoints = function (start, end) {
804 return new Range(start.row, start.column, end.row, end.column);
805 };
806 Range.comparePoints = function (p1, p2) {
807 return p1.row - p2.row || p1.column - p2.column;
808 };
809 exports.Range = Range;
810
811 });
812
813 ace.define("ace/anchor",[], function(require, exports, module){"use strict";
814 var oop = require("./lib/oop");
815 var EventEmitter = require("./lib/event_emitter").EventEmitter;
816 var Anchor = /** @class */ (function () {
817 function Anchor(doc, row, column) {
818 this.$onChange = this.onChange.bind(this);
819 this.attach(doc);
820 if (typeof row != "number")
821 this.setPosition(row.row, row.column);
822 else
823 this.setPosition(row, column);
824 }
825 Anchor.prototype.getPosition = function () {
826 return this.$clipPositionToDocument(this.row, this.column);
827 };
828 Anchor.prototype.getDocument = function () {
829 return this.document;
830 };
831 Anchor.prototype.onChange = function (delta) {
832 if (delta.start.row == delta.end.row && delta.start.row != this.row)
833 return;
834 if (delta.start.row > this.row)
835 return;
836 var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight);
837 this.setPosition(point.row, point.column, true);
838 };
839 Anchor.prototype.setPosition = function (row, column, noClip) {
840 var pos;
841 if (noClip) {
842 pos = {
843 row: row,
844 column: column
845 };
846 }
847 else {
848 pos = this.$clipPositionToDocument(row, column);
849 }
850 if (this.row == pos.row && this.column == pos.column)
851 return;
852 var old = {
853 row: this.row,
854 column: this.column
855 };
856 this.row = pos.row;
857 this.column = pos.column;
858 this._signal("change", {
859 old: old,
860 value: pos
861 });
862 };
863 Anchor.prototype.detach = function () {
864 this.document.off("change", this.$onChange);
865 };
866 Anchor.prototype.attach = function (doc) {
867 this.document = doc || this.document;
868 this.document.on("change", this.$onChange);
869 };
870 Anchor.prototype.$clipPositionToDocument = function (row, column) {
871 var pos = {};
872 if (row >= this.document.getLength()) {
873 pos.row = Math.max(0, this.document.getLength() - 1);
874 pos.column = this.document.getLine(pos.row).length;
875 }
876 else if (row < 0) {
877 pos.row = 0;
878 pos.column = 0;
879 }
880 else {
881 pos.row = row;
882 pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
883 }
884 if (column < 0)
885 pos.column = 0;
886 return pos;
887 };
888 return Anchor;
889 }());
890 Anchor.prototype.$insertRight = false;
891 oop.implement(Anchor.prototype, EventEmitter);
892 function $pointsInOrder(point1, point2, equalPointsInOrder) {
893 var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
894 return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
895 }
896 function $getTransformedPoint(delta, point, moveIfEqual) {
897 var deltaIsInsert = delta.action == "insert";
898 var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
899 var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
900 var deltaStart = delta.start;
901 var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
902 if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
903 return {
904 row: point.row,
905 column: point.column
906 };
907 }
908 if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
909 return {
910 row: point.row + deltaRowShift,
911 column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
912 };
913 }
914 return {
915 row: deltaStart.row,
916 column: deltaStart.column
917 };
918 }
919 exports.Anchor = Anchor;
920
921 });
922
923 ace.define("ace/document",[], function(require, exports, module){"use strict";
924 var oop = require("./lib/oop");
925 var applyDelta = require("./apply_delta").applyDelta;
926 var EventEmitter = require("./lib/event_emitter").EventEmitter;
927 var Range = require("./range").Range;
928 var Anchor = require("./anchor").Anchor;
929 var Document = /** @class */ (function () {
930 function Document(textOrLines) {
931 this.$lines = [""];
932 if (textOrLines.length === 0) {
933 this.$lines = [""];
934 }
935 else if (Array.isArray(textOrLines)) {
936 this.insertMergedLines({ row: 0, column: 0 }, textOrLines);
937 }
938 else {
939 this.insert({ row: 0, column: 0 }, textOrLines);
940 }
941 }
942 Document.prototype.setValue = function (text) {
943 var len = this.getLength() - 1;
944 this.remove(new Range(0, 0, len, this.getLine(len).length));
945 this.insert({ row: 0, column: 0 }, text || "");
946 };
947 Document.prototype.getValue = function () {
948 return this.getAllLines().join(this.getNewLineCharacter());
949 };
950 Document.prototype.createAnchor = function (row, column) {
951 return new Anchor(this, row, column);
952 };
953 Document.prototype.$detectNewLine = function (text) {
954 var match = text.match(/^.*?(\r\n|\r|\n)/m);
955 this.$autoNewLine = match ? match[1] : "\n";
956 this._signal("changeNewLineMode");
957 };
958 Document.prototype.getNewLineCharacter = function () {
959 switch (this.$newLineMode) {
960 case "windows":
961 return "\r\n";
962 case "unix":
963 return "\n";
964 default:
965 return this.$autoNewLine || "\n";
966 }
967 };
968 Document.prototype.setNewLineMode = function (newLineMode) {
969 if (this.$newLineMode === newLineMode)
970 return;
971 this.$newLineMode = newLineMode;
972 this._signal("changeNewLineMode");
973 };
974 Document.prototype.getNewLineMode = function () {
975 return this.$newLineMode;
976 };
977 Document.prototype.isNewLine = function (text) {
978 return (text == "\r\n" || text == "\r" || text == "\n");
979 };
980 Document.prototype.getLine = function (row) {
981 return this.$lines[row] || "";
982 };
983 Document.prototype.getLines = function (firstRow, lastRow) {
984 return this.$lines.slice(firstRow, lastRow + 1);
985 };
986 Document.prototype.getAllLines = function () {
987 return this.getLines(0, this.getLength());
988 };
989 Document.prototype.getLength = function () {
990 return this.$lines.length;
991 };
992 Document.prototype.getTextRange = function (range) {
993 return this.getLinesForRange(range).join(this.getNewLineCharacter());
994 };
995 Document.prototype.getLinesForRange = function (range) {
996 var lines;
997 if (range.start.row === range.end.row) {
998 lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
999 }
1000 else {
1001 lines = this.getLines(range.start.row, range.end.row);
1002 lines[0] = (lines[0] || "").substring(range.start.column);
1003 var l = lines.length - 1;
1004 if (range.end.row - range.start.row == l)
1005 lines[l] = lines[l].substring(0, range.end.column);
1006 }
1007 return lines;
1008 };
1009 Document.prototype.insertLines = function (row, lines) {
1010 console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
1011 return this.insertFullLines(row, lines);
1012 };
1013 Document.prototype.removeLines = function (firstRow, lastRow) {
1014 console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
1015 return this.removeFullLines(firstRow, lastRow);
1016 };
1017 Document.prototype.insertNewLine = function (position) {
1018 console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
1019 return this.insertMergedLines(position, ["", ""]);
1020 };
1021 Document.prototype.insert = function (position, text) {
1022 if (this.getLength() <= 1)
1023 this.$detectNewLine(text);
1024 return this.insertMergedLines(position, this.$split(text));
1025 };
1026 Document.prototype.insertInLine = function (position, text) {
1027 var start = this.clippedPos(position.row, position.column);
1028 var end = this.pos(position.row, position.column + text.length);
1029 this.applyDelta({
1030 start: start,
1031 end: end,
1032 action: "insert",
1033 lines: [text]
1034 }, true);
1035 return this.clonePos(end);
1036 };
1037 Document.prototype.clippedPos = function (row, column) {
1038 var length = this.getLength();
1039 if (row === undefined) {
1040 row = length;
1041 }
1042 else if (row < 0) {
1043 row = 0;
1044 }
1045 else if (row >= length) {
1046 row = length - 1;
1047 column = undefined;
1048 }
1049 var line = this.getLine(row);
1050 if (column == undefined)
1051 column = line.length;
1052 column = Math.min(Math.max(column, 0), line.length);
1053 return { row: row, column: column };
1054 };
1055 Document.prototype.clonePos = function (pos) {
1056 return { row: pos.row, column: pos.column };
1057 };
1058 Document.prototype.pos = function (row, column) {
1059 return { row: row, column: column };
1060 };
1061 Document.prototype.$clipPosition = function (position) {
1062 var length = this.getLength();
1063 if (position.row >= length) {
1064 position.row = Math.max(0, length - 1);
1065 position.column = this.getLine(length - 1).length;
1066 }
1067 else {
1068 position.row = Math.max(0, position.row);
1069 position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
1070 }
1071 return position;
1072 };
1073 Document.prototype.insertFullLines = function (row, lines) {
1074 row = Math.min(Math.max(row, 0), this.getLength());
1075 var column = 0;
1076 if (row < this.getLength()) {
1077 lines = lines.concat([""]);
1078 column = 0;
1079 }
1080 else {
1081 lines = [""].concat(lines);
1082 row--;
1083 column = this.$lines[row].length;
1084 }
1085 this.insertMergedLines({ row: row, column: column }, lines);
1086 };
1087 Document.prototype.insertMergedLines = function (position, lines) {
1088 var start = this.clippedPos(position.row, position.column);
1089 var end = {
1090 row: start.row + lines.length - 1,
1091 column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
1092 };
1093 this.applyDelta({
1094 start: start,
1095 end: end,
1096 action: "insert",
1097 lines: lines
1098 });
1099 return this.clonePos(end);
1100 };
1101 Document.prototype.remove = function (range) {
1102 var start = this.clippedPos(range.start.row, range.start.column);
1103 var end = this.clippedPos(range.end.row, range.end.column);
1104 this.applyDelta({
1105 start: start,
1106 end: end,
1107 action: "remove",
1108 lines: this.getLinesForRange({ start: start, end: end })
1109 });
1110 return this.clonePos(start);
1111 };
1112 Document.prototype.removeInLine = function (row, startColumn, endColumn) {
1113 var start = this.clippedPos(row, startColumn);
1114 var end = this.clippedPos(row, endColumn);
1115 this.applyDelta({
1116 start: start,
1117 end: end,
1118 action: "remove",
1119 lines: this.getLinesForRange({ start: start, end: end })
1120 }, true);
1121 return this.clonePos(start);
1122 };
1123 Document.prototype.removeFullLines = function (firstRow, lastRow) {
1124 firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
1125 lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1);
1126 var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
1127 var deleteLastNewLine = lastRow < this.getLength() - 1;
1128 var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow);
1129 var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0);
1130 var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow);
1131 var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length);
1132 var range = new Range(startRow, startCol, endRow, endCol);
1133 var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
1134 this.applyDelta({
1135 start: range.start,
1136 end: range.end,
1137 action: "remove",
1138 lines: this.getLinesForRange(range)
1139 });
1140 return deletedLines;
1141 };
1142 Document.prototype.removeNewLine = function (row) {
1143 if (row < this.getLength() - 1 && row >= 0) {
1144 this.applyDelta({
1145 start: this.pos(row, this.getLine(row).length),
1146 end: this.pos(row + 1, 0),
1147 action: "remove",
1148 lines: ["", ""]
1149 });
1150 }
1151 };
1152 Document.prototype.replace = function (range, text) {
1153 if (!(range instanceof Range))
1154 range = Range.fromPoints(range.start, range.end);
1155 if (text.length === 0 && range.isEmpty())
1156 return range.start;
1157 if (text == this.getTextRange(range))
1158 return range.end;
1159 this.remove(range);
1160 var end;
1161 if (text) {
1162 end = this.insert(range.start, text);
1163 }
1164 else {
1165 end = range.start;
1166 }
1167 return end;
1168 };
1169 Document.prototype.applyDeltas = function (deltas) {
1170 for (var i = 0; i < deltas.length; i++) {
1171 this.applyDelta(deltas[i]);
1172 }
1173 };
1174 Document.prototype.revertDeltas = function (deltas) {
1175 for (var i = deltas.length - 1; i >= 0; i--) {
1176 this.revertDelta(deltas[i]);
1177 }
1178 };
1179 Document.prototype.applyDelta = function (delta, doNotValidate) {
1180 var isInsert = delta.action == "insert";
1181 if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
1182 : !Range.comparePoints(delta.start, delta.end)) {
1183 return;
1184 }
1185 if (isInsert && delta.lines.length > 20000) {
1186 this.$splitAndapplyLargeDelta(delta, 20000);
1187 }
1188 else {
1189 applyDelta(this.$lines, delta, doNotValidate);
1190 this._signal("change", delta);
1191 }
1192 };
1193 Document.prototype.$safeApplyDelta = function (delta) {
1194 var docLength = this.$lines.length;
1195 if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
1196 || delta.action == "insert" && delta.start.row <= docLength) {
1197 this.applyDelta(delta);
1198 }
1199 };
1200 Document.prototype.$splitAndapplyLargeDelta = function (delta, MAX) {
1201 var lines = delta.lines;
1202 var l = lines.length - MAX + 1;
1203 var row = delta.start.row;
1204 var column = delta.start.column;
1205 for (var from = 0, to = 0; from < l; from = to) {
1206 to += MAX - 1;
1207 var chunk = lines.slice(from, to);
1208 chunk.push("");
1209 this.applyDelta({
1210 start: this.pos(row + from, column),
1211 end: this.pos(row + to, column = 0),
1212 action: delta.action,
1213 lines: chunk
1214 }, true);
1215 }
1216 delta.lines = lines.slice(from);
1217 delta.start.row = row + from;
1218 delta.start.column = column;
1219 this.applyDelta(delta, true);
1220 };
1221 Document.prototype.revertDelta = function (delta) {
1222 this.$safeApplyDelta({
1223 start: this.clonePos(delta.start),
1224 end: this.clonePos(delta.end),
1225 action: (delta.action == "insert" ? "remove" : "insert"),
1226 lines: delta.lines.slice()
1227 });
1228 };
1229 Document.prototype.indexToPosition = function (index, startRow) {
1230 var lines = this.$lines || this.getAllLines();
1231 var newlineLength = this.getNewLineCharacter().length;
1232 for (var i = startRow || 0, l = lines.length; i < l; i++) {
1233 index -= lines[i].length + newlineLength;
1234 if (index < 0)
1235 return { row: i, column: index + lines[i].length + newlineLength };
1236 }
1237 return { row: l - 1, column: index + lines[l - 1].length + newlineLength };
1238 };
1239 Document.prototype.positionToIndex = function (pos, startRow) {
1240 var lines = this.$lines || this.getAllLines();
1241 var newlineLength = this.getNewLineCharacter().length;
1242 var index = 0;
1243 var row = Math.min(pos.row, lines.length);
1244 for (var i = startRow || 0; i < row; ++i)
1245 index += lines[i].length + newlineLength;
1246 return index + pos.column;
1247 };
1248 Document.prototype.$split = function (text) {
1249 return text.split(/\r\n|\r|\n/);
1250 };
1251 return Document;
1252 }());
1253 Document.prototype.$autoNewLine = "";
1254 Document.prototype.$newLineMode = "auto";
1255 oop.implement(Document.prototype, EventEmitter);
1256 exports.Document = Document;
1257
1258 });
1259
1260 ace.define("ace/worker/mirror",[], function(require, exports, module) {
1261 "use strict";
1262
1263 var Document = require("../document").Document;
1264 var lang = require("../lib/lang");
1265
1266 var Mirror = exports.Mirror = function(sender) {
1267 this.sender = sender;
1268 var doc = this.doc = new Document("");
1269
1270 var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1271
1272 var _self = this;
1273 sender.on("change", function(e) {
1274 var data = e.data;
1275 if (data[0].start) {
1276 doc.applyDeltas(data);
1277 } else {
1278 for (var i = 0; i < data.length; i += 2) {
1279 var d, err;
1280 if (Array.isArray(data[i+1])) {
1281 d = {action: "insert", start: data[i], lines: data[i+1]};
1282 } else {
1283 d = {action: "remove", start: data[i], end: data[i+1]};
1284 }
1285
1286 if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) {
1287 err = new Error("Invalid delta");
1288 err.data = {
1289 path: _self.$path,
1290 linesLength: doc.$lines.length,
1291 start: d.start,
1292 end: d.end
1293 };
1294 throw err;
1295 }
1296
1297 doc.applyDelta(d, true);
1298 }
1299 }
1300 if (_self.$timeout)
1301 return deferredUpdate.schedule(_self.$timeout);
1302 _self.onUpdate();
1303 });
1304 };
1305
1306 (function() {
1307
1308 this.$timeout = 500;
1309
1310 this.setTimeout = function(timeout) {
1311 this.$timeout = timeout;
1312 };
1313
1314 this.setValue = function(value) {
1315 this.doc.setValue(value);
1316 this.deferredUpdate.schedule(this.$timeout);
1317 };
1318
1319 this.getValue = function(callbackId) {
1320 this.sender.callback(this.doc.getValue(), callbackId);
1321 };
1322
1323 this.onUpdate = function() {
1324 };
1325
1326 this.isPending = function() {
1327 return this.deferredUpdate.isPending();
1328 };
1329
1330 }).call(Mirror.prototype);
1331
1332 });
1333
1334 ace.define("ace/mode/xml/sax",[], function(require, exports, module) {
1335 var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
1336 var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\u00B7\u0300-\u036F\\ux203F-\u2040]");
1337 var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
1338 var S_TAG = 0;//tag name offerring
1339 var S_ATTR = 1;//attr name offerring
1340 var S_ATTR_S=2;//attr name end and space offer
1341 var S_EQ = 3;//=space?
1342 var S_V = 4;//attr value(no quot value only)
1343 var S_E = 5;//attr value end and no space(quot end)
1344 var S_S = 6;//(attr value end || tag end ) && (space offer)
1345 var S_C = 7;//closed el<el />
1346
1347 function XMLReader(){
1348
1349 }
1350
1351 XMLReader.prototype = {
1352 parse:function(source,defaultNSMap,entityMap){
1353 var domBuilder = this.domBuilder;
1354 domBuilder.startDocument();
1355 _copy(defaultNSMap ,defaultNSMap = {})
1356 parse(source,defaultNSMap,entityMap,
1357 domBuilder,this.errorHandler);
1358 domBuilder.endDocument();
1359 }
1360 }
1361 function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
1362 function fixedFromCharCode(code) {
1363 if (code > 0xffff) {
1364 code -= 0x10000;
1365 var surrogate1 = 0xd800 + (code >> 10)
1366 , surrogate2 = 0xdc00 + (code & 0x3ff);
1367
1368 return String.fromCharCode(surrogate1, surrogate2);
1369 } else {
1370 return String.fromCharCode(code);
1371 }
1372 }
1373 function entityReplacer(a){
1374 var k = a.slice(1,-1);
1375 if(k in entityMap){
1376 return entityMap[k];
1377 }else if(k.charAt(0) === '#'){
1378 return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
1379 }else{
1380 errorHandler.error('entity not found:'+a);
1381 return a;
1382 }
1383 }
1384 function appendText(end){//has some bugs
1385 var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
1386 locator&&position(start);
1387 domBuilder.characters(xt,0,end-start);
1388 start = end
1389 }
1390 function position(start,m){
1391 while(start>=endPos && (m = linePattern.exec(source))){
1392 startPos = m.index;
1393 endPos = startPos + m[0].length;
1394 locator.lineNumber++;
1395 }
1396 locator.columnNumber = start-startPos+1;
1397 }
1398 var startPos = 0;
1399 var endPos = 0;
1400 var linePattern = /.+(?:\r\n?|\n)|.*$/g
1401 var locator = domBuilder.locator;
1402
1403 var parseStack = [{currentNSMap:defaultNSMapCopy}]
1404 var closeMap = {};
1405 var start = 0;
1406 while(true){
1407 var i = source.indexOf('<',start);
1408 if(i<0){
1409 if(!source.substr(start).match(/^\s*$/)){
1410 var doc = domBuilder.document;
1411 var text = doc.createTextNode(source.substr(start));
1412 doc.appendChild(text);
1413 domBuilder.currentElement = text;
1414 }
1415 return;
1416 }
1417 if(i>start){
1418 appendText(i);
1419 }
1420 switch(source.charAt(i+1)){
1421 case '/':
1422 var end = source.indexOf('>',i+3);
1423 var tagName = source.substring(i+2,end);
1424 var config;
1425 if (parseStack.length > 1) {
1426 config = parseStack.pop();
1427 } else {
1428 errorHandler.fatalError("end tag name not found for: "+tagName);
1429 break;
1430 }
1431 var localNSMap = config.localNSMap;
1432
1433 if(config.tagName != tagName){
1434 errorHandler.fatalError("end tag name: " + tagName + " does not match the current start tagName: "+config.tagName );
1435 }
1436 domBuilder.endElement(config.uri,config.localName,tagName);
1437 if(localNSMap){
1438 for(var prefix in localNSMap){
1439 domBuilder.endPrefixMapping(prefix) ;
1440 }
1441 }
1442 end++;
1443 break;
1444 case '?':// <?...?>
1445 locator&&position(i);
1446 end = parseInstruction(source,i,domBuilder);
1447 break;
1448 case '!':// <!doctype,<![CDATA,<!--
1449 locator&&position(i);
1450 end = parseDCC(source,i,domBuilder,errorHandler);
1451 break;
1452 default:
1453 try{
1454 locator&&position(i);
1455
1456 var el = new ElementAttributes();
1457 var end = parseElementStartPart(source,i,el,entityReplacer,errorHandler);
1458 var len = el.length;
1459 if(len && locator){
1460 var backup = copyLocator(locator,{});
1461 for(var i = 0;i<len;i++){
1462 var a = el[i];
1463 position(a.offset);
1464 a.offset = copyLocator(locator,{});
1465 }
1466 copyLocator(backup,locator);
1467 }
1468 if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
1469 el.closed = true;
1470 if(!entityMap.nbsp){
1471 errorHandler.warning('unclosed xml attribute');
1472 }
1473 }
1474 appendElement(el,domBuilder,parseStack,errorHandler);
1475
1476
1477 if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
1478 end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
1479 }else{
1480 end++;
1481 }
1482 }catch(e){
1483 errorHandler.error('element parse error: '+e);
1484 end = -1;
1485 }
1486
1487 }
1488 if(end<0){
1489 appendText(i+1);
1490 }else{
1491 start = end;
1492 }
1493 }
1494 }
1495 function copyLocator(f,t){
1496 t.lineNumber = f.lineNumber;
1497 t.columnNumber = f.columnNumber;
1498 return t;
1499
1500 }
1501 function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
1502 var attrName;
1503 var value;
1504 var p = ++start;
1505 var s = S_TAG;//status
1506 while(true){
1507 var c = source.charAt(p);
1508 switch(c){
1509 case '=':
1510 if(s === S_ATTR){//attrName
1511 attrName = source.slice(start,p);
1512 s = S_EQ;
1513 }else if(s === S_ATTR_S){
1514 s = S_EQ;
1515 }else{
1516 throw new Error('attribute equal must after attrName');
1517 }
1518 break;
1519 case '\'':
1520 case '"':
1521 if(s === S_EQ){//equal
1522 start = p+1;
1523 p = source.indexOf(c,start)
1524 if(p>0){
1525 value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1526 el.add(attrName,value,start-1);
1527 s = S_E;
1528 }else{
1529 throw new Error('attribute value no end \''+c+'\' match');
1530 }
1531 }else if(s == S_V){
1532 value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1533 el.add(attrName,value,start);
1534 errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
1535 start = p+1;
1536 s = S_E
1537 }else{
1538 throw new Error('attribute value must after "="');
1539 }
1540 break;
1541 case '/':
1542 switch(s){
1543 case S_TAG:
1544 el.setTagName(source.slice(start,p));
1545 case S_E:
1546 case S_S:
1547 case S_C:
1548 s = S_C;
1549 el.closed = true;
1550 case S_V:
1551 case S_ATTR:
1552 case S_ATTR_S:
1553 break;
1554 default:
1555 throw new Error("attribute invalid close char('/')")
1556 }
1557 break;
1558 case ''://end document
1559 errorHandler.error('unexpected end of input');
1560 case '>':
1561 switch(s){
1562 case S_TAG:
1563 el.setTagName(source.slice(start,p));
1564 case S_E:
1565 case S_S:
1566 case S_C:
1567 break;//normal
1568 case S_V://Compatible state
1569 case S_ATTR:
1570 value = source.slice(start,p);
1571 if(value.slice(-1) === '/'){
1572 el.closed = true;
1573 value = value.slice(0,-1)
1574 }
1575 case S_ATTR_S:
1576 if(s === S_ATTR_S){
1577 value = attrName;
1578 }
1579 if(s == S_V){
1580 errorHandler.warning('attribute "'+value+'" missed quot(")!!');
1581 el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
1582 }else{
1583 errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
1584 el.add(value,value,start)
1585 }
1586 break;
1587 case S_EQ:
1588 throw new Error('attribute value missed!!');
1589 }
1590 return p;
1591 case '\u0080':
1592 c = ' ';
1593 default:
1594 if(c<= ' '){//space
1595 switch(s){
1596 case S_TAG:
1597 el.setTagName(source.slice(start,p));//tagName
1598 s = S_S;
1599 break;
1600 case S_ATTR:
1601 attrName = source.slice(start,p)
1602 s = S_ATTR_S;
1603 break;
1604 case S_V:
1605 var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1606 errorHandler.warning('attribute "'+value+'" missed quot(")!!');
1607 el.add(attrName,value,start)
1608 case S_E:
1609 s = S_S;
1610 break;
1611 }
1612 }else{//not space
1613 switch(s){
1614 case S_ATTR_S:
1615 errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!')
1616 el.add(attrName,attrName,start);
1617 start = p;
1618 s = S_ATTR;
1619 break;
1620 case S_E:
1621 errorHandler.warning('attribute space is required"'+attrName+'"!!')
1622 case S_S:
1623 s = S_ATTR;
1624 start = p;
1625 break;
1626 case S_EQ:
1627 s = S_V;
1628 start = p;
1629 break;
1630 case S_C:
1631 throw new Error("elements closed character '/' and '>' must be connected to");
1632 }
1633 }
1634 }
1635 p++;
1636 }
1637 }
1638 function appendElement(el,domBuilder,parseStack,errorHandler){
1639 var tagName = el.tagName;
1640 var localNSMap = null;
1641 var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
1642 var i = el.length;
1643 while(i--){
1644 var a = el[i];
1645 var qName = a.qName;
1646 var value = a.value;
1647 var nsp = qName.indexOf(':');
1648 if(nsp>0){
1649 var prefix = a.prefix = qName.slice(0,nsp);
1650 var localName = qName.slice(nsp+1);
1651 var nsPrefix = prefix === 'xmlns' && localName
1652 }else{
1653 localName = qName;
1654 prefix = null
1655 nsPrefix = qName === 'xmlns' && ''
1656 }
1657 a.localName = localName ;
1658 if(nsPrefix !== false){//hack!!
1659 if(localNSMap == null){
1660 localNSMap = {}
1661 _copy(currentNSMap,currentNSMap={})
1662 }
1663 currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
1664 a.uri = 'http://www.w3.org/2000/xmlns/'
1665 domBuilder.startPrefixMapping(nsPrefix, value)
1666 }
1667 }
1668 var i = el.length;
1669 while(i--){
1670 a = el[i];
1671 var prefix = a.prefix;
1672 if(prefix){//no prefix attribute has no namespace
1673 if(prefix === 'xml'){
1674 a.uri = 'http://www.w3.org/XML/1998/namespace';
1675 }if(prefix !== 'xmlns'){
1676 a.uri = currentNSMap[prefix]
1677 }
1678 }
1679 }
1680 var nsp = tagName.indexOf(':');
1681 if(nsp>0){
1682 prefix = el.prefix = tagName.slice(0,nsp);
1683 localName = el.localName = tagName.slice(nsp+1);
1684 }else{
1685 prefix = null;//important!!
1686 localName = el.localName = tagName;
1687 }
1688 var ns = el.uri = currentNSMap[prefix || ''];
1689 if (prefix && !ns) {
1690 errorHandler.error('unexpected namespace ' + prefix);
1691 }
1692 domBuilder.startElement(ns,localName,tagName,el);
1693 if(el.closed){
1694 domBuilder.endElement(ns,localName,tagName);
1695 if(localNSMap){
1696 for(prefix in localNSMap){
1697 domBuilder.endPrefixMapping(prefix)
1698 }
1699 }
1700 }else{
1701 el.currentNSMap = currentNSMap;
1702 el.localNSMap = localNSMap;
1703 parseStack.push(el);
1704 }
1705 }
1706 function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
1707 if(/^(?:script|textarea)$/i.test(tagName)){
1708 var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
1709 var text = source.substring(elStartEnd+1,elEndStart);
1710 if(/[&<]/.test(text)){
1711 if(/^script$/i.test(tagName)){
1712 domBuilder.characters(text,0,text.length);
1713 return elEndStart;
1714 }//}else{//text area
1715 text = text.replace(/&#?\w+;/g,entityReplacer);
1716 domBuilder.characters(text,0,text.length);
1717 return elEndStart;
1718
1719 }
1720 }
1721 return elStartEnd+1;
1722 }
1723 function fixSelfClosed(source,elStartEnd,tagName,closeMap){
1724 var pos = closeMap[tagName];
1725 if(pos == null){
1726 pos = closeMap[tagName] = source.lastIndexOf('</'+tagName+'>')
1727 }
1728 return pos<elStartEnd;
1729 }
1730 function _copy(source,target){
1731 for(var n in source){target[n] = source[n]}
1732 }
1733 function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
1734 var next= source.charAt(start+2)
1735 switch(next){
1736 case '-':
1737 if(source.charAt(start + 3) === '-'){
1738 var end = source.indexOf('-->',start+4);
1739 if(end>start){
1740 domBuilder.comment(source,start+4,end-start-4);
1741 return end+3;
1742 }else{
1743 errorHandler.error("Unclosed comment");
1744 return -1;
1745 }
1746 }else{
1747 return -1;
1748 }
1749 default:
1750 if(source.substr(start+3,6) == 'CDATA['){
1751 var end = source.indexOf(']]>',start+9);
1752 if (end > start) {
1753 domBuilder.startCDATA();
1754 domBuilder.characters(source,start+9,end-start-9);
1755 domBuilder.endCDATA()
1756 return end+3;
1757 } else {
1758 errorHandler.error("Unclosed CDATA");
1759 return -1;
1760 }
1761 }
1762 var matchs = split(source,start);
1763 var len = matchs.length;
1764 if(len>1 && /!doctype/i.test(matchs[0][0])){
1765 var name = matchs[1][0];
1766 var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
1767 var sysid = len>4 && matchs[4][0];
1768 var lastMatch = matchs[len-1]
1769 domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
1770 sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
1771 domBuilder.endDTD();
1772
1773 return lastMatch.index+lastMatch[0].length
1774 }
1775 }
1776 return -1;
1777 }
1778
1779
1780
1781 function parseInstruction(source,start,domBuilder){
1782 var end = source.indexOf('?>',start);
1783 if(end){
1784 var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
1785 if(match){
1786 var len = match[0].length;
1787 domBuilder.processingInstruction(match[1], match[2]) ;
1788 return end+2;
1789 }else{//error
1790 return -1;
1791 }
1792 }
1793 return -1;
1794 }
1795 function ElementAttributes(source){
1796
1797 }
1798 ElementAttributes.prototype = {
1799 setTagName:function(tagName){
1800 if(!tagNamePattern.test(tagName)){
1801 throw new Error('invalid tagName:'+tagName)
1802 }
1803 this.tagName = tagName
1804 },
1805 add:function(qName,value,offset){
1806 if(!tagNamePattern.test(qName)){
1807 throw new Error('invalid attribute:'+qName)
1808 }
1809 this[this.length++] = {qName:qName,value:value,offset:offset}
1810 },
1811 length:0,
1812 getLocalName:function(i){return this[i].localName},
1813 getOffset:function(i){return this[i].offset},
1814 getQName:function(i){return this[i].qName},
1815 getURI:function(i){return this[i].uri},
1816 getValue:function(i){return this[i].value}
1817 }
1818
1819
1820
1821
1822 function _set_proto_(thiz,parent){
1823 thiz.__proto__ = parent;
1824 return thiz;
1825 }
1826 if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
1827 _set_proto_ = function(thiz,parent){
1828 function p(){};
1829 p.prototype = parent;
1830 p = new p();
1831 for(parent in thiz){
1832 p[parent] = thiz[parent];
1833 }
1834 return p;
1835 }
1836 }
1837
1838 function split(source,start){
1839 var match;
1840 var buf = [];
1841 var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
1842 reg.lastIndex = start;
1843 reg.exec(source);//skip <
1844 while(match = reg.exec(source)){
1845 buf.push(match);
1846 if(match[1])return buf;
1847 }
1848 }
1849
1850 return XMLReader;
1851 });
1852
1853 ace.define("ace/mode/xml/dom",[], function(require, exports, module) {
1854
1855 function copy(src,dest){
1856 for(var p in src){
1857 dest[p] = src[p];
1858 }
1859 }
1860 function _extends(Class,Super){
1861 var t = function(){};
1862 var pt = Class.prototype;
1863 if(Object.create){
1864 var ppt = Object.create(Super.prototype);
1865 pt.__proto__ = ppt;
1866 }
1867 if(!(pt instanceof Super)){
1868 t.prototype = Super.prototype;
1869 t = new t();
1870 copy(pt,t);
1871 Class.prototype = pt = t;
1872 }
1873 if(pt.constructor != Class){
1874 if(typeof Class != 'function'){
1875 console.error("unknown Class:"+Class);
1876 }
1877 pt.constructor = Class;
1878 }
1879 }
1880 var htmlns = 'http://www.w3.org/1999/xhtml' ;
1881 var NodeType = {};
1882 var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
1883 var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
1884 var TEXT_NODE = NodeType.TEXT_NODE = 3;
1885 var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
1886 var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
1887 var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
1888 var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
1889 var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
1890 var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
1891 var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
1892 var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
1893 var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
1894 var ExceptionCode = {};
1895 var ExceptionMessage = {};
1896 var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
1897 var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
1898 var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
1899 var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
1900 var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
1901 var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
1902 var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
1903 var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
1904 var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
1905 var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
1906 var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
1907 var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
1908 var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
1909 var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
1910 var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
1911
1912
1913 function DOMException(code, message) {
1914 if(message instanceof Error){
1915 var error = message;
1916 }else{
1917 error = this;
1918 Error.call(this, ExceptionMessage[code]);
1919 this.message = ExceptionMessage[code];
1920 if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
1921 }
1922 error.code = code;
1923 if(message) this.message = this.message + ": " + message;
1924 return error;
1925 };
1926 DOMException.prototype = Error.prototype;
1927 copy(ExceptionCode,DOMException)
1928 function NodeList() {
1929 };
1930 NodeList.prototype = {
1931 length:0,
1932 item: function(index) {
1933 return this[index] || null;
1934 }
1935 };
1936 function LiveNodeList(node,refresh){
1937 this._node = node;
1938 this._refresh = refresh;
1939 _updateLiveList(this);
1940 }
1941 function _updateLiveList(list){
1942 var inc = list._node._inc || list._node.ownerDocument._inc;
1943 if(list._inc != inc){
1944 var ls = list._refresh(list._node);
1945 __set__(list,'length',ls.length);
1946 copy(ls,list);
1947 list._inc = inc;
1948 }
1949 }
1950 LiveNodeList.prototype.item = function(i){
1951 _updateLiveList(this);
1952 return this[i];
1953 }
1954
1955 _extends(LiveNodeList,NodeList);
1956 function NamedNodeMap() {
1957 };
1958
1959 function _findNodeIndex(list,node){
1960 var i = list.length;
1961 while(i--){
1962 if(list[i] === node){return i}
1963 }
1964 }
1965
1966 function _addNamedNode(el,list,newAttr,oldAttr){
1967 if(oldAttr){
1968 list[_findNodeIndex(list,oldAttr)] = newAttr;
1969 }else{
1970 list[list.length++] = newAttr;
1971 }
1972 if(el){
1973 newAttr.ownerElement = el;
1974 var doc = el.ownerDocument;
1975 if(doc){
1976 oldAttr && _onRemoveAttribute(doc,el,oldAttr);
1977 _onAddAttribute(doc,el,newAttr);
1978 }
1979 }
1980 }
1981 function _removeNamedNode(el,list,attr){
1982 var i = _findNodeIndex(list,attr);
1983 if(i>=0){
1984 var lastIndex = list.length-1;
1985 while(i<lastIndex){
1986 list[i] = list[++i];
1987 }
1988 list.length = lastIndex;
1989 if(el){
1990 var doc = el.ownerDocument;
1991 if(doc){
1992 _onRemoveAttribute(doc,el,attr);
1993 attr.ownerElement = null;
1994 }
1995 }
1996 }else{
1997 throw new DOMException(NOT_FOUND_ERR,new Error());
1998 }
1999 }
2000 NamedNodeMap.prototype = {
2001 length:0,
2002 item:NodeList.prototype.item,
2003 getNamedItem: function(key) {
2004 var i = this.length;
2005 while(i--){
2006 var attr = this[i];
2007 if(attr.nodeName == key){
2008 return attr;
2009 }
2010 }
2011 },
2012 setNamedItem: function(attr) {
2013 var el = attr.ownerElement;
2014 if(el && el!=this._ownerElement){
2015 throw new DOMException(INUSE_ATTRIBUTE_ERR);
2016 }
2017 var oldAttr = this.getNamedItem(attr.nodeName);
2018 _addNamedNode(this._ownerElement,this,attr,oldAttr);
2019 return oldAttr;
2020 },
2021 setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
2022 var el = attr.ownerElement, oldAttr;
2023 if(el && el!=this._ownerElement){
2024 throw new DOMException(INUSE_ATTRIBUTE_ERR);
2025 }
2026 oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
2027 _addNamedNode(this._ownerElement,this,attr,oldAttr);
2028 return oldAttr;
2029 },
2030 removeNamedItem: function(key) {
2031 var attr = this.getNamedItem(key);
2032 _removeNamedNode(this._ownerElement,this,attr);
2033 return attr;
2034
2035
2036 },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
2037 removeNamedItemNS:function(namespaceURI,localName){
2038 var attr = this.getNamedItemNS(namespaceURI,localName);
2039 _removeNamedNode(this._ownerElement,this,attr);
2040 return attr;
2041 },
2042 getNamedItemNS: function(namespaceURI, localName) {
2043 var i = this.length;
2044 while(i--){
2045 var node = this[i];
2046 if(node.localName == localName && node.namespaceURI == namespaceURI){
2047 return node;
2048 }
2049 }
2050 return null;
2051 }
2052 };
2053 function DOMImplementation(/* Object */ features) {
2054 this._features = {};
2055 if (features) {
2056 for (var feature in features) {
2057 this._features = features[feature];
2058 }
2059 }
2060 };
2061
2062 DOMImplementation.prototype = {
2063 hasFeature: function(/* string */ feature, /* string */ version) {
2064 var versions = this._features[feature.toLowerCase()];
2065 if (versions && (!version || version in versions)) {
2066 return true;
2067 } else {
2068 return false;
2069 }
2070 },
2071 createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
2072 var doc = new Document();
2073 doc.implementation = this;
2074 doc.childNodes = new NodeList();
2075 doc.doctype = doctype;
2076 if(doctype){
2077 doc.appendChild(doctype);
2078 }
2079 if(qualifiedName){
2080 var root = doc.createElementNS(namespaceURI,qualifiedName);
2081 doc.appendChild(root);
2082 }
2083 return doc;
2084 },
2085 createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
2086 var node = new DocumentType();
2087 node.name = qualifiedName;
2088 node.nodeName = qualifiedName;
2089 node.publicId = publicId;
2090 node.systemId = systemId;
2091 return node;
2092 }
2093 };
2094
2095 function Node() {
2096 };
2097
2098 Node.prototype = {
2099 firstChild : null,
2100 lastChild : null,
2101 previousSibling : null,
2102 nextSibling : null,
2103 attributes : null,
2104 parentNode : null,
2105 childNodes : null,
2106 ownerDocument : null,
2107 nodeValue : null,
2108 namespaceURI : null,
2109 prefix : null,
2110 localName : null,
2111 insertBefore:function(newChild, refChild){//raises
2112 return _insertBefore(this,newChild,refChild);
2113 },
2114 replaceChild:function(newChild, oldChild){//raises
2115 this.insertBefore(newChild,oldChild);
2116 if(oldChild){
2117 this.removeChild(oldChild);
2118 }
2119 },
2120 removeChild:function(oldChild){
2121 return _removeChild(this,oldChild);
2122 },
2123 appendChild:function(newChild){
2124 return this.insertBefore(newChild,null);
2125 },
2126 hasChildNodes:function(){
2127 return this.firstChild != null;
2128 },
2129 cloneNode:function(deep){
2130 return cloneNode(this.ownerDocument||this,this,deep);
2131 },
2132 normalize:function(){
2133 var child = this.firstChild;
2134 while(child){
2135 var next = child.nextSibling;
2136 if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
2137 this.removeChild(next);
2138 child.appendData(next.data);
2139 }else{
2140 child.normalize();
2141 child = next;
2142 }
2143 }
2144 },
2145 isSupported:function(feature, version){
2146 return this.ownerDocument.implementation.hasFeature(feature,version);
2147 },
2148 hasAttributes:function(){
2149 return this.attributes.length>0;
2150 },
2151 lookupPrefix:function(namespaceURI){
2152 var el = this;
2153 while(el){
2154 var map = el._nsMap;
2155 if(map){
2156 for(var n in map){
2157 if(map[n] == namespaceURI){
2158 return n;
2159 }
2160 }
2161 }
2162 el = el.nodeType == 2?el.ownerDocument : el.parentNode;
2163 }
2164 return null;
2165 },
2166 lookupNamespaceURI:function(prefix){
2167 var el = this;
2168 while(el){
2169 var map = el._nsMap;
2170 if(map){
2171 if(prefix in map){
2172 return map[prefix] ;
2173 }
2174 }
2175 el = el.nodeType == 2?el.ownerDocument : el.parentNode;
2176 }
2177 return null;
2178 },
2179 isDefaultNamespace:function(namespaceURI){
2180 var prefix = this.lookupPrefix(namespaceURI);
2181 return prefix == null;
2182 }
2183 };
2184
2185
2186 function _xmlEncoder(c){
2187 return c == '<' && '&lt;' ||
2188 c == '>' && '&gt;' ||
2189 c == '&' && '&amp;' ||
2190 c == '"' && '&quot;' ||
2191 '&#'+c.charCodeAt()+';';
2192 }
2193
2194
2195 copy(NodeType,Node);
2196 copy(NodeType,Node.prototype);
2197 function _visitNode(node,callback){
2198 if(callback(node)){
2199 return true;
2200 }
2201 if(node = node.firstChild){
2202 do{
2203 if(_visitNode(node,callback)){return true}
2204 }while(node=node.nextSibling)
2205 }
2206 }
2207
2208
2209
2210 function Document(){
2211 }
2212 function _onAddAttribute(doc,el,newAttr){
2213 doc && doc._inc++;
2214 var ns = newAttr.namespaceURI ;
2215 if(ns == 'http://www.w3.org/2000/xmlns/'){
2216 el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
2217 }
2218 }
2219 function _onRemoveAttribute(doc,el,newAttr,remove){
2220 doc && doc._inc++;
2221 var ns = newAttr.namespaceURI ;
2222 if(ns == 'http://www.w3.org/2000/xmlns/'){
2223 delete el._nsMap[newAttr.prefix?newAttr.localName:''];
2224 }
2225 }
2226 function _onUpdateChild(doc,el,newChild){
2227 if(doc && doc._inc){
2228 doc._inc++;
2229 var cs = el.childNodes;
2230 if(newChild){
2231 cs[cs.length++] = newChild;
2232 }else{
2233 var child = el.firstChild;
2234 var i = 0;
2235 while(child){
2236 cs[i++] = child;
2237 child =child.nextSibling;
2238 }
2239 cs.length = i;
2240 }
2241 }
2242 }
2243 function _removeChild(parentNode,child){
2244 var previous = child.previousSibling;
2245 var next = child.nextSibling;
2246 if(previous){
2247 previous.nextSibling = next;
2248 }else{
2249 parentNode.firstChild = next
2250 }
2251 if(next){
2252 next.previousSibling = previous;
2253 }else{
2254 parentNode.lastChild = previous;
2255 }
2256 _onUpdateChild(parentNode.ownerDocument,parentNode);
2257 return child;
2258 }
2259 function _insertBefore(parentNode,newChild,nextChild){
2260 var cp = newChild.parentNode;
2261 if(cp){
2262 cp.removeChild(newChild);//remove and update
2263 }
2264 if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
2265 var newFirst = newChild.firstChild;
2266 if (newFirst == null) {
2267 return newChild;
2268 }
2269 var newLast = newChild.lastChild;
2270 }else{
2271 newFirst = newLast = newChild;
2272 }
2273 var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
2274
2275 newFirst.previousSibling = pre;
2276 newLast.nextSibling = nextChild;
2277
2278
2279 if(pre){
2280 pre.nextSibling = newFirst;
2281 }else{
2282 parentNode.firstChild = newFirst;
2283 }
2284 if(nextChild == null){
2285 parentNode.lastChild = newLast;
2286 }else{
2287 nextChild.previousSibling = newLast;
2288 }
2289 do{
2290 newFirst.parentNode = parentNode;
2291 }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
2292 _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
2293 if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
2294 newChild.firstChild = newChild.lastChild = null;
2295 }
2296 return newChild;
2297 }
2298 function _appendSingleChild(parentNode,newChild){
2299 var cp = newChild.parentNode;
2300 if(cp){
2301 var pre = parentNode.lastChild;
2302 cp.removeChild(newChild);//remove and update
2303 var pre = parentNode.lastChild;
2304 }
2305 var pre = parentNode.lastChild;
2306 newChild.parentNode = parentNode;
2307 newChild.previousSibling = pre;
2308 newChild.nextSibling = null;
2309 if(pre){
2310 pre.nextSibling = newChild;
2311 }else{
2312 parentNode.firstChild = newChild;
2313 }
2314 parentNode.lastChild = newChild;
2315 _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
2316 return newChild;
2317 }
2318 Document.prototype = {
2319 nodeName : '#document',
2320 nodeType : DOCUMENT_NODE,
2321 doctype : null,
2322 documentElement : null,
2323 _inc : 1,
2324
2325 insertBefore : function(newChild, refChild){//raises
2326 if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
2327 var child = newChild.firstChild;
2328 while(child){
2329 var next = child.nextSibling;
2330 this.insertBefore(child,refChild);
2331 child = next;
2332 }
2333 return newChild;
2334 }
2335 if(this.documentElement == null && newChild.nodeType == 1){
2336 this.documentElement = newChild;
2337 }
2338
2339 return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
2340 },
2341 removeChild : function(oldChild){
2342 if(this.documentElement == oldChild){
2343 this.documentElement = null;
2344 }
2345 return _removeChild(this,oldChild);
2346 },
2347 importNode : function(importedNode,deep){
2348 return importNode(this,importedNode,deep);
2349 },
2350 getElementById : function(id){
2351 var rtv = null;
2352 _visitNode(this.documentElement,function(node){
2353 if(node.nodeType == 1){
2354 if(node.getAttribute('id') == id){
2355 rtv = node;
2356 return true;
2357 }
2358 }
2359 });
2360 return rtv;
2361 },
2362 createElement : function(tagName){
2363 var node = new Element();
2364 node.ownerDocument = this;
2365 node.nodeName = tagName;
2366 node.tagName = tagName;
2367 node.childNodes = new NodeList();
2368 var attrs = node.attributes = new NamedNodeMap();
2369 attrs._ownerElement = node;
2370 return node;
2371 },
2372 createDocumentFragment : function(){
2373 var node = new DocumentFragment();
2374 node.ownerDocument = this;
2375 node.childNodes = new NodeList();
2376 return node;
2377 },
2378 createTextNode : function(data){
2379 var node = new Text();
2380 node.ownerDocument = this;
2381 node.appendData(data);
2382 return node;
2383 },
2384 createComment : function(data){
2385 var node = new Comment();
2386 node.ownerDocument = this;
2387 node.appendData(data);
2388 return node;
2389 },
2390 createCDATASection : function(data){
2391 var node = new CDATASection();
2392 node.ownerDocument = this;
2393 node.appendData(data);
2394 return node;
2395 },
2396 createProcessingInstruction : function(target,data){
2397 var node = new ProcessingInstruction();
2398 node.ownerDocument = this;
2399 node.tagName = node.target = target;
2400 node.nodeValue= node.data = data;
2401 return node;
2402 },
2403 createAttribute : function(name){
2404 var node = new Attr();
2405 node.ownerDocument = this;
2406 node.name = name;
2407 node.nodeName = name;
2408 node.localName = name;
2409 node.specified = true;
2410 return node;
2411 },
2412 createEntityReference : function(name){
2413 var node = new EntityReference();
2414 node.ownerDocument = this;
2415 node.nodeName = name;
2416 return node;
2417 },
2418 createElementNS : function(namespaceURI,qualifiedName){
2419 var node = new Element();
2420 var pl = qualifiedName.split(':');
2421 var attrs = node.attributes = new NamedNodeMap();
2422 node.childNodes = new NodeList();
2423 node.ownerDocument = this;
2424 node.nodeName = qualifiedName;
2425 node.tagName = qualifiedName;
2426 node.namespaceURI = namespaceURI;
2427 if(pl.length == 2){
2428 node.prefix = pl[0];
2429 node.localName = pl[1];
2430 }else{
2431 node.localName = qualifiedName;
2432 }
2433 attrs._ownerElement = node;
2434 return node;
2435 },
2436 createAttributeNS : function(namespaceURI,qualifiedName){
2437 var node = new Attr();
2438 var pl = qualifiedName.split(':');
2439 node.ownerDocument = this;
2440 node.nodeName = qualifiedName;
2441 node.name = qualifiedName;
2442 node.namespaceURI = namespaceURI;
2443 node.specified = true;
2444 if(pl.length == 2){
2445 node.prefix = pl[0];
2446 node.localName = pl[1];
2447 }else{
2448 node.localName = qualifiedName;
2449 }
2450 return node;
2451 }
2452 };
2453 _extends(Document,Node);
2454
2455
2456 function Element() {
2457 this._nsMap = {};
2458 };
2459 Element.prototype = {
2460 nodeType : ELEMENT_NODE,
2461 hasAttribute : function(name){
2462 return this.getAttributeNode(name)!=null;
2463 },
2464 getAttribute : function(name){
2465 var attr = this.getAttributeNode(name);
2466 return attr && attr.value || '';
2467 },
2468 getAttributeNode : function(name){
2469 return this.attributes.getNamedItem(name);
2470 },
2471 setAttribute : function(name, value){
2472 var attr = this.ownerDocument.createAttribute(name);
2473 attr.value = attr.nodeValue = "" + value;
2474 this.setAttributeNode(attr);
2475 },
2476 removeAttribute : function(name){
2477 var attr = this.getAttributeNode(name);
2478 attr && this.removeAttributeNode(attr);
2479 },
2480 appendChild:function(newChild){
2481 if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
2482 return this.insertBefore(newChild,null);
2483 }else{
2484 return _appendSingleChild(this,newChild);
2485 }
2486 },
2487 setAttributeNode : function(newAttr){
2488 return this.attributes.setNamedItem(newAttr);
2489 },
2490 setAttributeNodeNS : function(newAttr){
2491 return this.attributes.setNamedItemNS(newAttr);
2492 },
2493 removeAttributeNode : function(oldAttr){
2494 return this.attributes.removeNamedItem(oldAttr.nodeName);
2495 },
2496 removeAttributeNS : function(namespaceURI, localName){
2497 var old = this.getAttributeNodeNS(namespaceURI, localName);
2498 old && this.removeAttributeNode(old);
2499 },
2500
2501 hasAttributeNS : function(namespaceURI, localName){
2502 return this.getAttributeNodeNS(namespaceURI, localName)!=null;
2503 },
2504 getAttributeNS : function(namespaceURI, localName){
2505 var attr = this.getAttributeNodeNS(namespaceURI, localName);
2506 return attr && attr.value || '';
2507 },
2508 setAttributeNS : function(namespaceURI, qualifiedName, value){
2509 var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
2510 attr.value = attr.nodeValue = "" + value;
2511 this.setAttributeNode(attr);
2512 },
2513 getAttributeNodeNS : function(namespaceURI, localName){
2514 return this.attributes.getNamedItemNS(namespaceURI, localName);
2515 },
2516
2517 getElementsByTagName : function(tagName){
2518 return new LiveNodeList(this,function(base){
2519 var ls = [];
2520 _visitNode(base,function(node){
2521 if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
2522 ls.push(node);
2523 }
2524 });
2525 return ls;
2526 });
2527 },
2528 getElementsByTagNameNS : function(namespaceURI, localName){
2529 return new LiveNodeList(this,function(base){
2530 var ls = [];
2531 _visitNode(base,function(node){
2532 if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
2533 ls.push(node);
2534 }
2535 });
2536 return ls;
2537 });
2538 }
2539 };
2540 Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
2541 Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
2542
2543
2544 _extends(Element,Node);
2545 function Attr() {
2546 };
2547 Attr.prototype.nodeType = ATTRIBUTE_NODE;
2548 _extends(Attr,Node);
2549
2550
2551 function CharacterData() {
2552 };
2553 CharacterData.prototype = {
2554 data : '',
2555 substringData : function(offset, count) {
2556 return this.data.substring(offset, offset+count);
2557 },
2558 appendData: function(text) {
2559 text = this.data+text;
2560 this.nodeValue = this.data = text;
2561 this.length = text.length;
2562 },
2563 insertData: function(offset,text) {
2564 this.replaceData(offset,0,text);
2565 },
2566 appendChild:function(newChild){
2567 throw new Error(ExceptionMessage[3]);
2568 return Node.prototype.appendChild.apply(this,arguments);
2569 },
2570 deleteData: function(offset, count) {
2571 this.replaceData(offset,count,"");
2572 },
2573 replaceData: function(offset, count, text) {
2574 var start = this.data.substring(0,offset);
2575 var end = this.data.substring(offset+count);
2576 text = start + text + end;
2577 this.nodeValue = this.data = text;
2578 this.length = text.length;
2579 }
2580 }
2581 _extends(CharacterData,Node);
2582 function Text() {
2583 };
2584 Text.prototype = {
2585 nodeName : "#text",
2586 nodeType : TEXT_NODE,
2587 splitText : function(offset) {
2588 var text = this.data;
2589 var newText = text.substring(offset);
2590 text = text.substring(0, offset);
2591 this.data = this.nodeValue = text;
2592 this.length = text.length;
2593 var newNode = this.ownerDocument.createTextNode(newText);
2594 if(this.parentNode){
2595 this.parentNode.insertBefore(newNode, this.nextSibling);
2596 }
2597 return newNode;
2598 }
2599 }
2600 _extends(Text,CharacterData);
2601 function Comment() {
2602 };
2603 Comment.prototype = {
2604 nodeName : "#comment",
2605 nodeType : COMMENT_NODE
2606 }
2607 _extends(Comment,CharacterData);
2608
2609 function CDATASection() {
2610 };
2611 CDATASection.prototype = {
2612 nodeName : "#cdata-section",
2613 nodeType : CDATA_SECTION_NODE
2614 }
2615 _extends(CDATASection,CharacterData);
2616
2617
2618 function DocumentType() {
2619 }
2620 DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
2621 _extends(DocumentType,Node);
2622
2623 function Notation() {
2624 }
2625 Notation.prototype.nodeType = NOTATION_NODE;
2626 _extends(Notation,Node);
2627
2628 function Entity() {
2629 }
2630 Entity.prototype.nodeType = ENTITY_NODE;
2631 _extends(Entity,Node);
2632
2633 function EntityReference() {
2634 }
2635 EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
2636 _extends(EntityReference,Node);
2637
2638 function DocumentFragment() {
2639 }
2640 DocumentFragment.prototype.nodeName = "#document-fragment";
2641 DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
2642 _extends(DocumentFragment,Node);
2643
2644
2645 function ProcessingInstruction() {
2646 }
2647 ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
2648 _extends(ProcessingInstruction,Node);
2649 function XMLSerializer(){}
2650 XMLSerializer.prototype.serializeToString = function(node){
2651 var buf = [];
2652 serializeToString(node,buf);
2653 return buf.join('');
2654 }
2655 Node.prototype.toString =function(){
2656 return XMLSerializer.prototype.serializeToString(this);
2657 }
2658 function serializeToString(node,buf){
2659 switch(node.nodeType){
2660 case ELEMENT_NODE:
2661 var attrs = node.attributes;
2662 var len = attrs.length;
2663 var child = node.firstChild;
2664 var nodeName = node.tagName;
2665 var isHTML = htmlns === node.namespaceURI;
2666 buf.push('<',nodeName);
2667 for(var i=0;i<len;i++){
2668 serializeToString(attrs.item(i),buf);
2669 }
2670 if(child || isHTML && !/^(?:meta|link|img|br|hr|input|button)$/i.test(nodeName)){
2671 buf.push('>');
2672 if(isHTML && /^script$/i.test(nodeName)){
2673 if(child){
2674 buf.push(child.data);
2675 }
2676 }else{
2677 while(child){
2678 serializeToString(child,buf);
2679 child = child.nextSibling;
2680 }
2681 }
2682 buf.push('</',nodeName,'>');
2683 }else{
2684 buf.push('/>');
2685 }
2686 return;
2687 case DOCUMENT_NODE:
2688 case DOCUMENT_FRAGMENT_NODE:
2689 var child = node.firstChild;
2690 while(child){
2691 serializeToString(child,buf);
2692 child = child.nextSibling;
2693 }
2694 return;
2695 case ATTRIBUTE_NODE:
2696 return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
2697 case TEXT_NODE:
2698 return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
2699 case CDATA_SECTION_NODE:
2700 return buf.push( '<![CDATA[',node.data,']]>');
2701 case COMMENT_NODE:
2702 return buf.push( "<!--",node.data,"-->");
2703 case DOCUMENT_TYPE_NODE:
2704 var pubid = node.publicId;
2705 var sysid = node.systemId;
2706 buf.push('<!DOCTYPE ',node.name);
2707 if(pubid){
2708 buf.push(' PUBLIC "',pubid);
2709 if (sysid && sysid!='.') {
2710 buf.push( '" "',sysid);
2711 }
2712 buf.push('">');
2713 }else if(sysid && sysid!='.'){
2714 buf.push(' SYSTEM "',sysid,'">');
2715 }else{
2716 var sub = node.internalSubset;
2717 if(sub){
2718 buf.push(" [",sub,"]");
2719 }
2720 buf.push(">");
2721 }
2722 return;
2723 case PROCESSING_INSTRUCTION_NODE:
2724 return buf.push( "<?",node.target," ",node.data,"?>");
2725 case ENTITY_REFERENCE_NODE:
2726 return buf.push( '&',node.nodeName,';');
2727 default:
2728 buf.push('??',node.nodeName);
2729 }
2730 }
2731 function importNode(doc,node,deep){
2732 var node2;
2733 switch (node.nodeType) {
2734 case ELEMENT_NODE:
2735 node2 = node.cloneNode(false);
2736 node2.ownerDocument = doc;
2737 case DOCUMENT_FRAGMENT_NODE:
2738 break;
2739 case ATTRIBUTE_NODE:
2740 deep = true;
2741 break;
2742 }
2743 if(!node2){
2744 node2 = node.cloneNode(false);//false
2745 }
2746 node2.ownerDocument = doc;
2747 node2.parentNode = null;
2748 if(deep){
2749 var child = node.firstChild;
2750 while(child){
2751 node2.appendChild(importNode(doc,child,deep));
2752 child = child.nextSibling;
2753 }
2754 }
2755 return node2;
2756 }
2757 function cloneNode(doc,node,deep){
2758 var node2 = new node.constructor();
2759 for(var n in node){
2760 var v = node[n];
2761 if(typeof v != 'object' ){
2762 if(v != node2[n]){
2763 node2[n] = v;
2764 }
2765 }
2766 }
2767 if(node.childNodes){
2768 node2.childNodes = new NodeList();
2769 }
2770 node2.ownerDocument = doc;
2771 switch (node2.nodeType) {
2772 case ELEMENT_NODE:
2773 var attrs = node.attributes;
2774 var attrs2 = node2.attributes = new NamedNodeMap();
2775 var len = attrs.length;
2776 attrs2._ownerElement = node2;
2777 for(var i=0;i<len;i++){
2778 node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
2779 }
2780 break;
2781 case ATTRIBUTE_NODE:
2782 deep = true;
2783 }
2784 if(deep){
2785 var child = node.firstChild;
2786 while(child){
2787 node2.appendChild(cloneNode(doc,child,deep));
2788 child = child.nextSibling;
2789 }
2790 }
2791 return node2;
2792 }
2793
2794 function __set__(object,key,value){
2795 object[key] = value;
2796 }
2797 function getTextContent(node){
2798 switch(node.nodeType){
2799 case 1:
2800 case 11:
2801 var buf = [];
2802 node = node.firstChild;
2803 while(node){
2804 if(node.nodeType!==7 && node.nodeType !==8){
2805 buf.push(getTextContent(node));
2806 }
2807 node = node.nextSibling;
2808 }
2809 return buf.join('');
2810 default:
2811 return node.nodeValue;
2812 }
2813 }
2814 try{
2815 if(Object.defineProperty){
2816 Object.defineProperty(LiveNodeList.prototype,'length',{
2817 get:function(){
2818 _updateLiveList(this);
2819 return this.$$length;
2820 }
2821 });
2822 Object.defineProperty(Node.prototype,'textContent',{
2823 get:function(){
2824 return getTextContent(this);
2825 },
2826 set:function(data){
2827 switch(this.nodeType){
2828 case 1:
2829 case 11:
2830 while(this.firstChild){
2831 this.removeChild(this.firstChild);
2832 }
2833 if(data || String(data)){
2834 this.appendChild(this.ownerDocument.createTextNode(data));
2835 }
2836 break;
2837 default:
2838 this.data = data;
2839 this.value = value;
2840 this.nodeValue = data;
2841 }
2842 }
2843 });
2844
2845 __set__ = function(object,key,value){
2846 object['$$'+key] = value;
2847 };
2848 }
2849 }catch(e){//ie8
2850 }
2851
2852 return DOMImplementation;
2853 });
2854
2855 ace.define("ace/mode/xml/dom-parser",[], function(require, exports, module) {
2856 'use strict';
2857
2858 var XMLReader = require('./sax'),
2859 DOMImplementation = require('./dom');
2860
2861 function DOMParser(options){
2862 this.options = options ||{locator:{}};
2863
2864 }
2865 DOMParser.prototype.parseFromString = function(source,mimeType){
2866 var options = this.options;
2867 var sax = new XMLReader();
2868 var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
2869 var errorHandler = options.errorHandler;
2870 var locator = options.locator;
2871 var defaultNSMap = options.xmlns||{};
2872 var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}
2873 if(locator){
2874 domBuilder.setDocumentLocator(locator)
2875 }
2876
2877 sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
2878 sax.domBuilder = options.domBuilder || domBuilder;
2879 if(/\/x?html?$/.test(mimeType)){
2880 entityMap.nbsp = '\xa0';
2881 entityMap.copy = '\xa9';
2882 defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
2883 }
2884 if(source){
2885 sax.parse(source,defaultNSMap,entityMap);
2886 }else{
2887 sax.errorHandler.error("invalid document source");
2888 }
2889 return domBuilder.document;
2890 }
2891 function buildErrorHandler(errorImpl,domBuilder,locator){
2892 if(!errorImpl){
2893 if(domBuilder instanceof DOMHandler){
2894 return domBuilder;
2895 }
2896 errorImpl = domBuilder ;
2897 }
2898 var errorHandler = {}
2899 var isCallback = errorImpl instanceof Function;
2900 locator = locator||{}
2901 function build(key){
2902 var fn = errorImpl[key];
2903 if(!fn){
2904 if(isCallback){
2905 fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
2906 }else{
2907 var i=arguments.length;
2908 while(--i){
2909 if(fn = errorImpl[arguments[i]]){
2910 break;
2911 }
2912 }
2913 }
2914 }
2915 errorHandler[key] = fn && function(msg){
2916 fn(msg+_locator(locator), msg, locator);
2917 }||function(){};
2918 }
2919 build('warning','warn');
2920 build('error','warn','warning');
2921 build('fatalError','warn','warning','error');
2922 return errorHandler;
2923 }
2924 function DOMHandler() {
2925 this.cdata = false;
2926 }
2927 function position(locator,node){
2928 node.lineNumber = locator.lineNumber;
2929 node.columnNumber = locator.columnNumber;
2930 }
2931 DOMHandler.prototype = {
2932 startDocument : function() {
2933 this.document = new DOMImplementation().createDocument(null, null, null);
2934 if (this.locator) {
2935 this.document.documentURI = this.locator.systemId;
2936 }
2937 },
2938 startElement:function(namespaceURI, localName, qName, attrs) {
2939 var doc = this.document;
2940 var el = doc.createElementNS(namespaceURI, qName||localName);
2941 var len = attrs.length;
2942 appendElement(this, el);
2943 this.currentElement = el;
2944
2945 this.locator && position(this.locator,el)
2946 for (var i = 0 ; i < len; i++) {
2947 var namespaceURI = attrs.getURI(i);
2948 var value = attrs.getValue(i);
2949 var qName = attrs.getQName(i);
2950 var attr = doc.createAttributeNS(namespaceURI, qName);
2951 if( attr.getOffset){
2952 position(attr.getOffset(1),attr)
2953 }
2954 attr.value = attr.nodeValue = value;
2955 el.setAttributeNode(attr)
2956 }
2957 },
2958 endElement:function(namespaceURI, localName, qName) {
2959 var current = this.currentElement
2960 var tagName = current.tagName;
2961 this.currentElement = current.parentNode;
2962 },
2963 startPrefixMapping:function(prefix, uri) {
2964 },
2965 endPrefixMapping:function(prefix) {
2966 },
2967 processingInstruction:function(target, data) {
2968 var ins = this.document.createProcessingInstruction(target, data);
2969 this.locator && position(this.locator,ins)
2970 appendElement(this, ins);
2971 },
2972 ignorableWhitespace:function(ch, start, length) {
2973 },
2974 characters:function(chars, start, length) {
2975 chars = _toString.apply(this,arguments)
2976 if(this.currentElement && chars){
2977 if (this.cdata) {
2978 var charNode = this.document.createCDATASection(chars);
2979 this.currentElement.appendChild(charNode);
2980 } else {
2981 var charNode = this.document.createTextNode(chars);
2982 this.currentElement.appendChild(charNode);
2983 }
2984 this.locator && position(this.locator,charNode)
2985 }
2986 },
2987 skippedEntity:function(name) {
2988 },
2989 endDocument:function() {
2990 this.document.normalize();
2991 },
2992 setDocumentLocator:function (locator) {
2993 if(this.locator = locator){// && !('lineNumber' in locator)){
2994 locator.lineNumber = 0;
2995 }
2996 },
2997 comment:function(chars, start, length) {
2998 chars = _toString.apply(this,arguments)
2999 var comm = this.document.createComment(chars);
3000 this.locator && position(this.locator,comm)
3001 appendElement(this, comm);
3002 },
3003
3004 startCDATA:function() {
3005 this.cdata = true;
3006 },
3007 endCDATA:function() {
3008 this.cdata = false;
3009 },
3010
3011 startDTD:function(name, publicId, systemId) {
3012 var impl = this.document.implementation;
3013 if (impl && impl.createDocumentType) {
3014 var dt = impl.createDocumentType(name, publicId, systemId);
3015 this.locator && position(this.locator,dt)
3016 appendElement(this, dt);
3017 }
3018 },
3019 warning:function(error) {
3020 console.warn(error,_locator(this.locator));
3021 },
3022 error:function(error) {
3023 console.error(error,_locator(this.locator));
3024 },
3025 fatalError:function(error) {
3026 console.error(error,_locator(this.locator));
3027 throw error;
3028 }
3029 }
3030 function _locator(l){
3031 if(l){
3032 return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
3033 }
3034 }
3035 function _toString(chars,start,length){
3036 if(typeof chars == 'string'){
3037 return chars.substr(start,length)
3038 }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
3039 if(chars.length >= start+length || start){
3040 return new java.lang.String(chars,start,length)+'';
3041 }
3042 return chars;
3043 }
3044 }
3045 "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
3046 DOMHandler.prototype[key] = function(){return null}
3047 })
3048 function appendElement (hander,node) {
3049 if (!hander.currentElement) {
3050 hander.document.appendChild(node);
3051 } else {
3052 hander.currentElement.appendChild(node);
3053 }
3054 }//appendChild and setAttributeNS are preformance key
3055
3056 return {
3057 DOMParser: DOMParser
3058 };
3059 });
3060
3061 ace.define("ace/mode/xml_worker",[], function(require, exports, module) {
3062 "use strict";
3063
3064 var oop = require("../lib/oop");
3065 var lang = require("../lib/lang");
3066 var Mirror = require("../worker/mirror").Mirror;
3067 var DOMParser = require("./xml/dom-parser").DOMParser;
3068
3069 var Worker = exports.Worker = function(sender) {
3070 Mirror.call(this, sender);
3071 this.setTimeout(400);
3072 this.context = null;
3073 };
3074
3075 oop.inherits(Worker, Mirror);
3076
3077 (function() {
3078
3079 this.setOptions = function(options) {
3080 this.context = options.context;
3081 };
3082
3083 this.onUpdate = function() {
3084 var value = this.doc.getValue();
3085 if (!value)
3086 return;
3087 var parser = new DOMParser();
3088 var errors = [];
3089 parser.options.errorHandler = {
3090 fatalError: function(fullMsg, errorMsg, locator) {
3091 errors.push({
3092 row: locator.lineNumber,
3093 column: locator.columnNumber,
3094 text: errorMsg,
3095 type: "error"
3096 });
3097 },
3098 error: function(fullMsg, errorMsg, locator) {
3099 errors.push({
3100 row: locator.lineNumber,
3101 column: locator.columnNumber,
3102 text: errorMsg,
3103 type: "error"
3104 });
3105 },
3106 warning: function(fullMsg, errorMsg, locator) {
3107 errors.push({
3108 row: locator.lineNumber,
3109 column: locator.columnNumber,
3110 text: errorMsg,
3111 type: "warning"
3112 });
3113 }
3114 };
3115
3116 parser.parseFromString(value);
3117 this.sender.emit("error", errors);
3118 };
3119
3120 }).call(Worker.prototype);
3121
3122 });