plist 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +8 -19
- package/History.md +12 -0
- package/README.md +7 -0
- package/dist/plist-build.js +78 -44
- package/dist/plist-parse.js +1366 -999
- package/dist/plist.js +1368 -1001
- package/package.json +6 -6
package/dist/plist.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function e
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
2
|
/**
|
|
3
3
|
* Parser functions.
|
|
4
4
|
*/
|
|
@@ -14,7 +14,7 @@ var builderFunctions = require('./lib/build');
|
|
|
14
14
|
Object.keys(builderFunctions).forEach(function (k) { exports[k] = builderFunctions[k]; });
|
|
15
15
|
|
|
16
16
|
},{"./lib/build":2,"./lib/parse":3}],2:[function(require,module,exports){
|
|
17
|
-
(function (Buffer){
|
|
17
|
+
(function (Buffer){(function (){
|
|
18
18
|
/**
|
|
19
19
|
* Module dependencies.
|
|
20
20
|
*/
|
|
@@ -153,9 +153,9 @@ function walk_obj(next, next_child) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
|
|
156
|
+
}).call(this)}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
|
|
157
157
|
},{"../node_modules/is-buffer/index.js":7,"base64-js":4,"xmlbuilder":29}],3:[function(require,module,exports){
|
|
158
|
-
(function (Buffer){
|
|
158
|
+
(function (Buffer){(function (){
|
|
159
159
|
/**
|
|
160
160
|
* Module dependencies.
|
|
161
161
|
*/
|
|
@@ -372,7 +372,7 @@ function parsePlistXML (node) {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
}).call(this,require("buffer").Buffer)
|
|
375
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
376
376
|
},{"buffer":5,"xmldom":30}],4:[function(require,module,exports){
|
|
377
377
|
'use strict'
|
|
378
378
|
|
|
@@ -395,65 +395,98 @@ for (var i = 0, len = code.length; i < len; ++i) {
|
|
|
395
395
|
revLookup['-'.charCodeAt(0)] = 62
|
|
396
396
|
revLookup['_'.charCodeAt(0)] = 63
|
|
397
397
|
|
|
398
|
-
function
|
|
398
|
+
function getLens (b64) {
|
|
399
399
|
var len = b64.length
|
|
400
|
+
|
|
400
401
|
if (len % 4 > 0) {
|
|
401
402
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
402
403
|
}
|
|
403
404
|
|
|
404
|
-
//
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
405
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
406
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
407
|
+
var validLen = b64.indexOf('=')
|
|
408
|
+
if (validLen === -1) validLen = len
|
|
409
|
+
|
|
410
|
+
var placeHoldersLen = validLen === len
|
|
411
|
+
? 0
|
|
412
|
+
: 4 - (validLen % 4)
|
|
413
|
+
|
|
414
|
+
return [validLen, placeHoldersLen]
|
|
410
415
|
}
|
|
411
416
|
|
|
417
|
+
// base64 is 4/3 + up to two characters of the original data
|
|
412
418
|
function byteLength (b64) {
|
|
413
|
-
|
|
414
|
-
|
|
419
|
+
var lens = getLens(b64)
|
|
420
|
+
var validLen = lens[0]
|
|
421
|
+
var placeHoldersLen = lens[1]
|
|
422
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
426
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
415
427
|
}
|
|
416
428
|
|
|
417
429
|
function toByteArray (b64) {
|
|
418
|
-
var
|
|
419
|
-
var
|
|
420
|
-
|
|
430
|
+
var tmp
|
|
431
|
+
var lens = getLens(b64)
|
|
432
|
+
var validLen = lens[0]
|
|
433
|
+
var placeHoldersLen = lens[1]
|
|
421
434
|
|
|
422
|
-
arr = new Arr((
|
|
435
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
436
|
+
|
|
437
|
+
var curByte = 0
|
|
423
438
|
|
|
424
439
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
425
|
-
|
|
440
|
+
var len = placeHoldersLen > 0
|
|
441
|
+
? validLen - 4
|
|
442
|
+
: validLen
|
|
426
443
|
|
|
427
|
-
var
|
|
444
|
+
var i
|
|
445
|
+
for (i = 0; i < len; i += 4) {
|
|
446
|
+
tmp =
|
|
447
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
448
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
449
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
450
|
+
revLookup[b64.charCodeAt(i + 3)]
|
|
451
|
+
arr[curByte++] = (tmp >> 16) & 0xFF
|
|
452
|
+
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
453
|
+
arr[curByte++] = tmp & 0xFF
|
|
454
|
+
}
|
|
428
455
|
|
|
429
|
-
|
|
430
|
-
tmp =
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
arr[
|
|
456
|
+
if (placeHoldersLen === 2) {
|
|
457
|
+
tmp =
|
|
458
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
459
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
|
460
|
+
arr[curByte++] = tmp & 0xFF
|
|
434
461
|
}
|
|
435
462
|
|
|
436
|
-
if (
|
|
437
|
-
tmp =
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
arr[
|
|
442
|
-
arr[
|
|
463
|
+
if (placeHoldersLen === 1) {
|
|
464
|
+
tmp =
|
|
465
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
466
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
467
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
|
468
|
+
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
469
|
+
arr[curByte++] = tmp & 0xFF
|
|
443
470
|
}
|
|
444
471
|
|
|
445
472
|
return arr
|
|
446
473
|
}
|
|
447
474
|
|
|
448
475
|
function tripletToBase64 (num) {
|
|
449
|
-
return lookup[num >> 18 & 0x3F] +
|
|
476
|
+
return lookup[num >> 18 & 0x3F] +
|
|
477
|
+
lookup[num >> 12 & 0x3F] +
|
|
478
|
+
lookup[num >> 6 & 0x3F] +
|
|
479
|
+
lookup[num & 0x3F]
|
|
450
480
|
}
|
|
451
481
|
|
|
452
482
|
function encodeChunk (uint8, start, end) {
|
|
453
483
|
var tmp
|
|
454
484
|
var output = []
|
|
455
485
|
for (var i = start; i < end; i += 3) {
|
|
456
|
-
tmp =
|
|
486
|
+
tmp =
|
|
487
|
+
((uint8[i] << 16) & 0xFF0000) +
|
|
488
|
+
((uint8[i + 1] << 8) & 0xFF00) +
|
|
489
|
+
(uint8[i + 2] & 0xFF)
|
|
457
490
|
output.push(tripletToBase64(tmp))
|
|
458
491
|
}
|
|
459
492
|
return output.join('')
|
|
@@ -463,7 +496,6 @@ function fromByteArray (uint8) {
|
|
|
463
496
|
var tmp
|
|
464
497
|
var len = uint8.length
|
|
465
498
|
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
466
|
-
var output = ''
|
|
467
499
|
var parts = []
|
|
468
500
|
var maxChunkLength = 16383 // must be multiple of 3
|
|
469
501
|
|
|
@@ -475,23 +507,26 @@ function fromByteArray (uint8) {
|
|
|
475
507
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
476
508
|
if (extraBytes === 1) {
|
|
477
509
|
tmp = uint8[len - 1]
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
510
|
+
parts.push(
|
|
511
|
+
lookup[tmp >> 2] +
|
|
512
|
+
lookup[(tmp << 4) & 0x3F] +
|
|
513
|
+
'=='
|
|
514
|
+
)
|
|
481
515
|
} else if (extraBytes === 2) {
|
|
482
|
-
tmp = (uint8[len - 2] << 8) +
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
516
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
|
517
|
+
parts.push(
|
|
518
|
+
lookup[tmp >> 10] +
|
|
519
|
+
lookup[(tmp >> 4) & 0x3F] +
|
|
520
|
+
lookup[(tmp << 2) & 0x3F] +
|
|
521
|
+
'='
|
|
522
|
+
)
|
|
487
523
|
}
|
|
488
524
|
|
|
489
|
-
parts.push(output)
|
|
490
|
-
|
|
491
525
|
return parts.join('')
|
|
492
526
|
}
|
|
493
527
|
|
|
494
528
|
},{}],5:[function(require,module,exports){
|
|
529
|
+
(function (Buffer){(function (){
|
|
495
530
|
/*!
|
|
496
531
|
* The buffer module from node.js, for the browser.
|
|
497
532
|
*
|
|
@@ -540,7 +575,7 @@ function typedArraySupport () {
|
|
|
540
575
|
// Can typed array instances can be augmented?
|
|
541
576
|
try {
|
|
542
577
|
var arr = new Uint8Array(1)
|
|
543
|
-
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
|
578
|
+
arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
|
|
544
579
|
return arr.foo() === 42
|
|
545
580
|
} catch (e) {
|
|
546
581
|
return false
|
|
@@ -548,26 +583,24 @@ function typedArraySupport () {
|
|
|
548
583
|
}
|
|
549
584
|
|
|
550
585
|
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
586
|
+
enumerable: true,
|
|
551
587
|
get: function () {
|
|
552
|
-
if (!(this
|
|
553
|
-
return undefined
|
|
554
|
-
}
|
|
588
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
555
589
|
return this.buffer
|
|
556
590
|
}
|
|
557
591
|
})
|
|
558
592
|
|
|
559
593
|
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
594
|
+
enumerable: true,
|
|
560
595
|
get: function () {
|
|
561
|
-
if (!(this
|
|
562
|
-
return undefined
|
|
563
|
-
}
|
|
596
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
564
597
|
return this.byteOffset
|
|
565
598
|
}
|
|
566
599
|
})
|
|
567
600
|
|
|
568
601
|
function createBuffer (length) {
|
|
569
602
|
if (length > K_MAX_LENGTH) {
|
|
570
|
-
throw new RangeError('
|
|
603
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
571
604
|
}
|
|
572
605
|
// Return an augmented `Uint8Array` instance
|
|
573
606
|
var buf = new Uint8Array(length)
|
|
@@ -589,8 +622,8 @@ function Buffer (arg, encodingOrOffset, length) {
|
|
|
589
622
|
// Common case.
|
|
590
623
|
if (typeof arg === 'number') {
|
|
591
624
|
if (typeof encodingOrOffset === 'string') {
|
|
592
|
-
throw new
|
|
593
|
-
'
|
|
625
|
+
throw new TypeError(
|
|
626
|
+
'The "string" argument must be of type string. Received type number'
|
|
594
627
|
)
|
|
595
628
|
}
|
|
596
629
|
return allocUnsafe(arg)
|
|
@@ -599,7 +632,7 @@ function Buffer (arg, encodingOrOffset, length) {
|
|
|
599
632
|
}
|
|
600
633
|
|
|
601
634
|
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
|
602
|
-
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
635
|
+
if (typeof Symbol !== 'undefined' && Symbol.species != null &&
|
|
603
636
|
Buffer[Symbol.species] === Buffer) {
|
|
604
637
|
Object.defineProperty(Buffer, Symbol.species, {
|
|
605
638
|
value: null,
|
|
@@ -612,19 +645,51 @@ if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
|
612
645
|
Buffer.poolSize = 8192 // not used by this implementation
|
|
613
646
|
|
|
614
647
|
function from (value, encodingOrOffset, length) {
|
|
615
|
-
if (typeof value === '
|
|
616
|
-
|
|
648
|
+
if (typeof value === 'string') {
|
|
649
|
+
return fromString(value, encodingOrOffset)
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (ArrayBuffer.isView(value)) {
|
|
653
|
+
return fromArrayLike(value)
|
|
617
654
|
}
|
|
618
655
|
|
|
619
|
-
if (
|
|
656
|
+
if (value == null) {
|
|
657
|
+
throw TypeError(
|
|
658
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
659
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (isInstance(value, ArrayBuffer) ||
|
|
664
|
+
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
620
665
|
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
621
666
|
}
|
|
622
667
|
|
|
623
|
-
if (typeof value === '
|
|
624
|
-
|
|
668
|
+
if (typeof value === 'number') {
|
|
669
|
+
throw new TypeError(
|
|
670
|
+
'The "value" argument must not be of type number. Received type number'
|
|
671
|
+
)
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
var valueOf = value.valueOf && value.valueOf()
|
|
675
|
+
if (valueOf != null && valueOf !== value) {
|
|
676
|
+
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
var b = fromObject(value)
|
|
680
|
+
if (b) return b
|
|
681
|
+
|
|
682
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
683
|
+
typeof value[Symbol.toPrimitive] === 'function') {
|
|
684
|
+
return Buffer.from(
|
|
685
|
+
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
|
|
686
|
+
)
|
|
625
687
|
}
|
|
626
688
|
|
|
627
|
-
|
|
689
|
+
throw new TypeError(
|
|
690
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
691
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
692
|
+
)
|
|
628
693
|
}
|
|
629
694
|
|
|
630
695
|
/**
|
|
@@ -648,7 +713,7 @@ function assertSize (size) {
|
|
|
648
713
|
if (typeof size !== 'number') {
|
|
649
714
|
throw new TypeError('"size" argument must be of type number')
|
|
650
715
|
} else if (size < 0) {
|
|
651
|
-
throw new RangeError('"size"
|
|
716
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
652
717
|
}
|
|
653
718
|
}
|
|
654
719
|
|
|
@@ -763,20 +828,16 @@ function fromObject (obj) {
|
|
|
763
828
|
return buf
|
|
764
829
|
}
|
|
765
830
|
|
|
766
|
-
if (obj) {
|
|
767
|
-
if (
|
|
768
|
-
|
|
769
|
-
return createBuffer(0)
|
|
770
|
-
}
|
|
771
|
-
return fromArrayLike(obj)
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
775
|
-
return fromArrayLike(obj.data)
|
|
831
|
+
if (obj.length !== undefined) {
|
|
832
|
+
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
833
|
+
return createBuffer(0)
|
|
776
834
|
}
|
|
835
|
+
return fromArrayLike(obj)
|
|
777
836
|
}
|
|
778
837
|
|
|
779
|
-
|
|
838
|
+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
839
|
+
return fromArrayLike(obj.data)
|
|
840
|
+
}
|
|
780
841
|
}
|
|
781
842
|
|
|
782
843
|
function checked (length) {
|
|
@@ -797,12 +858,17 @@ function SlowBuffer (length) {
|
|
|
797
858
|
}
|
|
798
859
|
|
|
799
860
|
Buffer.isBuffer = function isBuffer (b) {
|
|
800
|
-
return b != null && b._isBuffer === true
|
|
861
|
+
return b != null && b._isBuffer === true &&
|
|
862
|
+
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
801
863
|
}
|
|
802
864
|
|
|
803
865
|
Buffer.compare = function compare (a, b) {
|
|
866
|
+
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
|
|
867
|
+
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
|
|
804
868
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
805
|
-
throw new TypeError(
|
|
869
|
+
throw new TypeError(
|
|
870
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
871
|
+
)
|
|
806
872
|
}
|
|
807
873
|
|
|
808
874
|
if (a === b) return 0
|
|
@@ -863,7 +929,7 @@ Buffer.concat = function concat (list, length) {
|
|
|
863
929
|
var pos = 0
|
|
864
930
|
for (i = 0; i < list.length; ++i) {
|
|
865
931
|
var buf = list[i]
|
|
866
|
-
if (
|
|
932
|
+
if (isInstance(buf, Uint8Array)) {
|
|
867
933
|
buf = Buffer.from(buf)
|
|
868
934
|
}
|
|
869
935
|
if (!Buffer.isBuffer(buf)) {
|
|
@@ -879,15 +945,19 @@ function byteLength (string, encoding) {
|
|
|
879
945
|
if (Buffer.isBuffer(string)) {
|
|
880
946
|
return string.length
|
|
881
947
|
}
|
|
882
|
-
if (ArrayBuffer.isView(string) ||
|
|
948
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
883
949
|
return string.byteLength
|
|
884
950
|
}
|
|
885
951
|
if (typeof string !== 'string') {
|
|
886
|
-
|
|
952
|
+
throw new TypeError(
|
|
953
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
954
|
+
'Received type ' + typeof string
|
|
955
|
+
)
|
|
887
956
|
}
|
|
888
957
|
|
|
889
958
|
var len = string.length
|
|
890
|
-
|
|
959
|
+
var mustMatch = (arguments.length > 2 && arguments[2] === true)
|
|
960
|
+
if (!mustMatch && len === 0) return 0
|
|
891
961
|
|
|
892
962
|
// Use a for loop to avoid recursion
|
|
893
963
|
var loweredCase = false
|
|
@@ -899,7 +969,6 @@ function byteLength (string, encoding) {
|
|
|
899
969
|
return len
|
|
900
970
|
case 'utf8':
|
|
901
971
|
case 'utf-8':
|
|
902
|
-
case undefined:
|
|
903
972
|
return utf8ToBytes(string).length
|
|
904
973
|
case 'ucs2':
|
|
905
974
|
case 'ucs-2':
|
|
@@ -911,7 +980,9 @@ function byteLength (string, encoding) {
|
|
|
911
980
|
case 'base64':
|
|
912
981
|
return base64ToBytes(string).length
|
|
913
982
|
default:
|
|
914
|
-
if (loweredCase)
|
|
983
|
+
if (loweredCase) {
|
|
984
|
+
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
985
|
+
}
|
|
915
986
|
encoding = ('' + encoding).toLowerCase()
|
|
916
987
|
loweredCase = true
|
|
917
988
|
}
|
|
@@ -1058,16 +1129,20 @@ Buffer.prototype.equals = function equals (b) {
|
|
|
1058
1129
|
Buffer.prototype.inspect = function inspect () {
|
|
1059
1130
|
var str = ''
|
|
1060
1131
|
var max = exports.INSPECT_MAX_BYTES
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
if (this.length > max) str += ' ... '
|
|
1064
|
-
}
|
|
1132
|
+
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
|
|
1133
|
+
if (this.length > max) str += ' ... '
|
|
1065
1134
|
return '<Buffer ' + str + '>'
|
|
1066
1135
|
}
|
|
1067
1136
|
|
|
1068
1137
|
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
1138
|
+
if (isInstance(target, Uint8Array)) {
|
|
1139
|
+
target = Buffer.from(target, target.offset, target.byteLength)
|
|
1140
|
+
}
|
|
1069
1141
|
if (!Buffer.isBuffer(target)) {
|
|
1070
|
-
throw new TypeError(
|
|
1142
|
+
throw new TypeError(
|
|
1143
|
+
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
1144
|
+
'Received type ' + (typeof target)
|
|
1145
|
+
)
|
|
1071
1146
|
}
|
|
1072
1147
|
|
|
1073
1148
|
if (start === undefined) {
|
|
@@ -1146,7 +1221,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
|
1146
1221
|
} else if (byteOffset < -0x80000000) {
|
|
1147
1222
|
byteOffset = -0x80000000
|
|
1148
1223
|
}
|
|
1149
|
-
byteOffset = +byteOffset
|
|
1224
|
+
byteOffset = +byteOffset // Coerce to Number.
|
|
1150
1225
|
if (numberIsNaN(byteOffset)) {
|
|
1151
1226
|
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
1152
1227
|
byteOffset = dir ? 0 : (buffer.length - 1)
|
|
@@ -1398,8 +1473,8 @@ function utf8Slice (buf, start, end) {
|
|
|
1398
1473
|
var codePoint = null
|
|
1399
1474
|
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
1400
1475
|
: (firstByte > 0xDF) ? 3
|
|
1401
|
-
|
|
1402
|
-
|
|
1476
|
+
: (firstByte > 0xBF) ? 2
|
|
1477
|
+
: 1
|
|
1403
1478
|
|
|
1404
1479
|
if (i + bytesPerSequence <= end) {
|
|
1405
1480
|
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
@@ -2062,7 +2137,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
|
2062
2137
|
} else {
|
|
2063
2138
|
var bytes = Buffer.isBuffer(val)
|
|
2064
2139
|
? val
|
|
2065
|
-
:
|
|
2140
|
+
: Buffer.from(val, encoding)
|
|
2066
2141
|
var len = bytes.length
|
|
2067
2142
|
if (len === 0) {
|
|
2068
2143
|
throw new TypeError('The value "' + val +
|
|
@@ -2217,19 +2292,22 @@ function blitBuffer (src, dst, offset, length) {
|
|
|
2217
2292
|
return i
|
|
2218
2293
|
}
|
|
2219
2294
|
|
|
2220
|
-
//
|
|
2221
|
-
// but they should be treated as
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2295
|
+
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
2296
|
+
// the `instanceof` check but they should be treated as of that type.
|
|
2297
|
+
// See: https://github.com/feross/buffer/issues/166
|
|
2298
|
+
function isInstance (obj, type) {
|
|
2299
|
+
return obj instanceof type ||
|
|
2300
|
+
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
2301
|
+
obj.constructor.name === type.name)
|
|
2226
2302
|
}
|
|
2227
|
-
|
|
2228
2303
|
function numberIsNaN (obj) {
|
|
2304
|
+
// For IE11 support
|
|
2229
2305
|
return obj !== obj // eslint-disable-line no-self-compare
|
|
2230
2306
|
}
|
|
2231
2307
|
|
|
2232
|
-
},
|
|
2308
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
2309
|
+
},{"base64-js":4,"buffer":5,"ieee754":6}],6:[function(require,module,exports){
|
|
2310
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
2233
2311
|
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
2234
2312
|
var e, m
|
|
2235
2313
|
var eLen = (nBytes * 8) - mLen - 1
|
|
@@ -4887,266 +4965,261 @@ function isSlowBuffer (obj) {
|
|
|
4887
4965
|
}).call(this);
|
|
4888
4966
|
|
|
4889
4967
|
},{"./Utility":8,"./XMLDocument":18,"./XMLDocumentCB":19,"./XMLStreamWriter":24,"./XMLStringWriter":25}],30:[function(require,module,exports){
|
|
4890
|
-
function DOMParser(options){
|
|
4891
|
-
this.options = options ||{locator:{}};
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
DOMParser.prototype.parseFromString = function(source,mimeType){
|
|
4895
|
-
var options = this.options;
|
|
4896
|
-
var sax = new XMLReader();
|
|
4897
|
-
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
|
4898
|
-
var errorHandler = options.errorHandler;
|
|
4899
|
-
var locator = options.locator;
|
|
4900
|
-
var defaultNSMap = options.xmlns||{};
|
|
4901
|
-
var
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
sax.
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
}
|
|
4928
|
-
var
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
build('
|
|
4941
|
-
build('
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
* +
|
|
4949
|
-
*
|
|
4950
|
-
*
|
|
4951
|
-
*
|
|
4952
|
-
* DefaultHandler
|
|
4953
|
-
*
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
node.
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
* @
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
this.
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
var
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
var
|
|
4984
|
-
var
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
var
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
* @
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
}
|
|
5090
|
-
|
|
5091
|
-
/*
|
|
5092
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
|
5093
|
-
* used method of org.xml.sax.ext.LexicalHandler:
|
|
5094
|
-
* #comment(chars, start, length)
|
|
5095
|
-
* #startCDATA()
|
|
5096
|
-
* #endCDATA()
|
|
5097
|
-
* #startDTD(name, publicId, systemId)
|
|
5098
|
-
*
|
|
5099
|
-
*
|
|
5100
|
-
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
|
5101
|
-
* #endDTD()
|
|
5102
|
-
* #startEntity(name)
|
|
5103
|
-
* #endEntity(name)
|
|
5104
|
-
*
|
|
5105
|
-
*
|
|
5106
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
|
5107
|
-
* IGNORED method of org.xml.sax.ext.DeclHandler
|
|
5108
|
-
* #attributeDecl(eName, aName, type, mode, value)
|
|
5109
|
-
* #elementDecl(name, model)
|
|
5110
|
-
* #externalEntityDecl(name, publicId, systemId)
|
|
5111
|
-
* #internalEntityDecl(name, value)
|
|
5112
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
|
5113
|
-
* IGNORED method of org.xml.sax.EntityResolver2
|
|
5114
|
-
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
|
5115
|
-
* #resolveEntity(publicId, systemId)
|
|
5116
|
-
* #getExternalSubset(name, baseURI)
|
|
5117
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
|
5118
|
-
* IGNORED method of org.xml.sax.DTDHandler
|
|
5119
|
-
* #notationDecl(name, publicId, systemId) {};
|
|
5120
|
-
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
|
5121
|
-
*/
|
|
5122
|
-
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
|
5123
|
-
DOMHandler.prototype[key] = function(){return null}
|
|
5124
|
-
})
|
|
5125
|
-
|
|
5126
|
-
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
|
|
5127
|
-
function appendElement (hander,node) {
|
|
5128
|
-
if (!hander.currentElement) {
|
|
5129
|
-
hander.doc.appendChild(node);
|
|
5130
|
-
} else {
|
|
5131
|
-
hander.currentElement.appendChild(node);
|
|
5132
|
-
}
|
|
5133
|
-
}//appendChild and setAttributeNS are preformance key
|
|
5134
|
-
|
|
5135
|
-
//if(typeof require == 'function'){
|
|
5136
|
-
var XMLReader = require('./sax').XMLReader;
|
|
5137
|
-
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
|
|
5138
|
-
exports.XMLSerializer = require('./dom').XMLSerializer ;
|
|
5139
|
-
exports.DOMParser = DOMParser;
|
|
5140
|
-
//}
|
|
5141
|
-
|
|
5142
|
-
},{"./dom":31,"./sax":32}],31:[function(require,module,exports){
|
|
4968
|
+
function DOMParser(options){
|
|
4969
|
+
this.options = options ||{locator:{}};
|
|
4970
|
+
}
|
|
4971
|
+
|
|
4972
|
+
DOMParser.prototype.parseFromString = function(source,mimeType){
|
|
4973
|
+
var options = this.options;
|
|
4974
|
+
var sax = new XMLReader();
|
|
4975
|
+
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
|
4976
|
+
var errorHandler = options.errorHandler;
|
|
4977
|
+
var locator = options.locator;
|
|
4978
|
+
var defaultNSMap = options.xmlns||{};
|
|
4979
|
+
var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
|
|
4980
|
+
var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"};
|
|
4981
|
+
if(locator){
|
|
4982
|
+
domBuilder.setDocumentLocator(locator)
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4985
|
+
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
|
4986
|
+
sax.domBuilder = options.domBuilder || domBuilder;
|
|
4987
|
+
if(isHTML){
|
|
4988
|
+
defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
|
|
4989
|
+
}
|
|
4990
|
+
defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
|
|
4991
|
+
if(source && typeof source === 'string'){
|
|
4992
|
+
sax.parse(source,defaultNSMap,entityMap);
|
|
4993
|
+
}else{
|
|
4994
|
+
sax.errorHandler.error("invalid doc source");
|
|
4995
|
+
}
|
|
4996
|
+
return domBuilder.doc;
|
|
4997
|
+
}
|
|
4998
|
+
function buildErrorHandler(errorImpl,domBuilder,locator){
|
|
4999
|
+
if(!errorImpl){
|
|
5000
|
+
if(domBuilder instanceof DOMHandler){
|
|
5001
|
+
return domBuilder;
|
|
5002
|
+
}
|
|
5003
|
+
errorImpl = domBuilder ;
|
|
5004
|
+
}
|
|
5005
|
+
var errorHandler = {}
|
|
5006
|
+
var isCallback = errorImpl instanceof Function;
|
|
5007
|
+
locator = locator||{}
|
|
5008
|
+
function build(key){
|
|
5009
|
+
var fn = errorImpl[key];
|
|
5010
|
+
if(!fn && isCallback){
|
|
5011
|
+
fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
|
|
5012
|
+
}
|
|
5013
|
+
errorHandler[key] = fn && function(msg){
|
|
5014
|
+
fn('[xmldom '+key+']\t'+msg+_locator(locator));
|
|
5015
|
+
}||function(){};
|
|
5016
|
+
}
|
|
5017
|
+
build('warning');
|
|
5018
|
+
build('error');
|
|
5019
|
+
build('fatalError');
|
|
5020
|
+
return errorHandler;
|
|
5021
|
+
}
|
|
5022
|
+
|
|
5023
|
+
//console.log('#\n\n\n\n\n\n\n####')
|
|
5024
|
+
/**
|
|
5025
|
+
* +ContentHandler+ErrorHandler
|
|
5026
|
+
* +LexicalHandler+EntityResolver2
|
|
5027
|
+
* -DeclHandler-DTDHandler
|
|
5028
|
+
*
|
|
5029
|
+
* DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
|
|
5030
|
+
* DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
|
|
5031
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
|
|
5032
|
+
*/
|
|
5033
|
+
function DOMHandler() {
|
|
5034
|
+
this.cdata = false;
|
|
5035
|
+
}
|
|
5036
|
+
function position(locator,node){
|
|
5037
|
+
node.lineNumber = locator.lineNumber;
|
|
5038
|
+
node.columnNumber = locator.columnNumber;
|
|
5039
|
+
}
|
|
5040
|
+
/**
|
|
5041
|
+
* @see org.xml.sax.ContentHandler#startDocument
|
|
5042
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
|
|
5043
|
+
*/
|
|
5044
|
+
DOMHandler.prototype = {
|
|
5045
|
+
startDocument : function() {
|
|
5046
|
+
this.doc = new DOMImplementation().createDocument(null, null, null);
|
|
5047
|
+
if (this.locator) {
|
|
5048
|
+
this.doc.documentURI = this.locator.systemId;
|
|
5049
|
+
}
|
|
5050
|
+
},
|
|
5051
|
+
startElement:function(namespaceURI, localName, qName, attrs) {
|
|
5052
|
+
var doc = this.doc;
|
|
5053
|
+
var el = doc.createElementNS(namespaceURI, qName||localName);
|
|
5054
|
+
var len = attrs.length;
|
|
5055
|
+
appendElement(this, el);
|
|
5056
|
+
this.currentElement = el;
|
|
5057
|
+
|
|
5058
|
+
this.locator && position(this.locator,el)
|
|
5059
|
+
for (var i = 0 ; i < len; i++) {
|
|
5060
|
+
var namespaceURI = attrs.getURI(i);
|
|
5061
|
+
var value = attrs.getValue(i);
|
|
5062
|
+
var qName = attrs.getQName(i);
|
|
5063
|
+
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
5064
|
+
this.locator &&position(attrs.getLocator(i),attr);
|
|
5065
|
+
attr.value = attr.nodeValue = value;
|
|
5066
|
+
el.setAttributeNode(attr)
|
|
5067
|
+
}
|
|
5068
|
+
},
|
|
5069
|
+
endElement:function(namespaceURI, localName, qName) {
|
|
5070
|
+
var current = this.currentElement
|
|
5071
|
+
var tagName = current.tagName;
|
|
5072
|
+
this.currentElement = current.parentNode;
|
|
5073
|
+
},
|
|
5074
|
+
startPrefixMapping:function(prefix, uri) {
|
|
5075
|
+
},
|
|
5076
|
+
endPrefixMapping:function(prefix) {
|
|
5077
|
+
},
|
|
5078
|
+
processingInstruction:function(target, data) {
|
|
5079
|
+
var ins = this.doc.createProcessingInstruction(target, data);
|
|
5080
|
+
this.locator && position(this.locator,ins)
|
|
5081
|
+
appendElement(this, ins);
|
|
5082
|
+
},
|
|
5083
|
+
ignorableWhitespace:function(ch, start, length) {
|
|
5084
|
+
},
|
|
5085
|
+
characters:function(chars, start, length) {
|
|
5086
|
+
chars = _toString.apply(this,arguments)
|
|
5087
|
+
//console.log(chars)
|
|
5088
|
+
if(chars){
|
|
5089
|
+
if (this.cdata) {
|
|
5090
|
+
var charNode = this.doc.createCDATASection(chars);
|
|
5091
|
+
} else {
|
|
5092
|
+
var charNode = this.doc.createTextNode(chars);
|
|
5093
|
+
}
|
|
5094
|
+
if(this.currentElement){
|
|
5095
|
+
this.currentElement.appendChild(charNode);
|
|
5096
|
+
}else if(/^\s*$/.test(chars)){
|
|
5097
|
+
this.doc.appendChild(charNode);
|
|
5098
|
+
//process xml
|
|
5099
|
+
}
|
|
5100
|
+
this.locator && position(this.locator,charNode)
|
|
5101
|
+
}
|
|
5102
|
+
},
|
|
5103
|
+
skippedEntity:function(name) {
|
|
5104
|
+
},
|
|
5105
|
+
endDocument:function() {
|
|
5106
|
+
this.doc.normalize();
|
|
5107
|
+
},
|
|
5108
|
+
setDocumentLocator:function (locator) {
|
|
5109
|
+
if(this.locator = locator){// && !('lineNumber' in locator)){
|
|
5110
|
+
locator.lineNumber = 0;
|
|
5111
|
+
}
|
|
5112
|
+
},
|
|
5113
|
+
//LexicalHandler
|
|
5114
|
+
comment:function(chars, start, length) {
|
|
5115
|
+
chars = _toString.apply(this,arguments)
|
|
5116
|
+
var comm = this.doc.createComment(chars);
|
|
5117
|
+
this.locator && position(this.locator,comm)
|
|
5118
|
+
appendElement(this, comm);
|
|
5119
|
+
},
|
|
5120
|
+
|
|
5121
|
+
startCDATA:function() {
|
|
5122
|
+
//used in characters() methods
|
|
5123
|
+
this.cdata = true;
|
|
5124
|
+
},
|
|
5125
|
+
endCDATA:function() {
|
|
5126
|
+
this.cdata = false;
|
|
5127
|
+
},
|
|
5128
|
+
|
|
5129
|
+
startDTD:function(name, publicId, systemId) {
|
|
5130
|
+
var impl = this.doc.implementation;
|
|
5131
|
+
if (impl && impl.createDocumentType) {
|
|
5132
|
+
var dt = impl.createDocumentType(name, publicId, systemId);
|
|
5133
|
+
this.locator && position(this.locator,dt)
|
|
5134
|
+
appendElement(this, dt);
|
|
5135
|
+
}
|
|
5136
|
+
},
|
|
5137
|
+
/**
|
|
5138
|
+
* @see org.xml.sax.ErrorHandler
|
|
5139
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
|
5140
|
+
*/
|
|
5141
|
+
warning:function(error) {
|
|
5142
|
+
console.warn('[xmldom warning]\t'+error,_locator(this.locator));
|
|
5143
|
+
},
|
|
5144
|
+
error:function(error) {
|
|
5145
|
+
console.error('[xmldom error]\t'+error,_locator(this.locator));
|
|
5146
|
+
},
|
|
5147
|
+
fatalError:function(error) {
|
|
5148
|
+
throw new ParseError(error, this.locator);
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
function _locator(l){
|
|
5152
|
+
if(l){
|
|
5153
|
+
return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
function _toString(chars,start,length){
|
|
5157
|
+
if(typeof chars == 'string'){
|
|
5158
|
+
return chars.substr(start,length)
|
|
5159
|
+
}else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
|
|
5160
|
+
if(chars.length >= start+length || start){
|
|
5161
|
+
return new java.lang.String(chars,start,length)+'';
|
|
5162
|
+
}
|
|
5163
|
+
return chars;
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
|
|
5143
5167
|
/*
|
|
5144
|
-
*
|
|
5145
|
-
*
|
|
5146
|
-
*
|
|
5147
|
-
*
|
|
5168
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
|
5169
|
+
* used method of org.xml.sax.ext.LexicalHandler:
|
|
5170
|
+
* #comment(chars, start, length)
|
|
5171
|
+
* #startCDATA()
|
|
5172
|
+
* #endCDATA()
|
|
5173
|
+
* #startDTD(name, publicId, systemId)
|
|
5174
|
+
*
|
|
5175
|
+
*
|
|
5176
|
+
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
|
5177
|
+
* #endDTD()
|
|
5178
|
+
* #startEntity(name)
|
|
5179
|
+
* #endEntity(name)
|
|
5180
|
+
*
|
|
5181
|
+
*
|
|
5182
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
|
5183
|
+
* IGNORED method of org.xml.sax.ext.DeclHandler
|
|
5184
|
+
* #attributeDecl(eName, aName, type, mode, value)
|
|
5185
|
+
* #elementDecl(name, model)
|
|
5186
|
+
* #externalEntityDecl(name, publicId, systemId)
|
|
5187
|
+
* #internalEntityDecl(name, value)
|
|
5188
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
|
5189
|
+
* IGNORED method of org.xml.sax.EntityResolver2
|
|
5190
|
+
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
|
5191
|
+
* #resolveEntity(publicId, systemId)
|
|
5192
|
+
* #getExternalSubset(name, baseURI)
|
|
5193
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
|
5194
|
+
* IGNORED method of org.xml.sax.DTDHandler
|
|
5195
|
+
* #notationDecl(name, publicId, systemId) {};
|
|
5196
|
+
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
|
5148
5197
|
*/
|
|
5198
|
+
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
|
5199
|
+
DOMHandler.prototype[key] = function(){return null}
|
|
5200
|
+
})
|
|
5149
5201
|
|
|
5202
|
+
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
|
|
5203
|
+
function appendElement (hander,node) {
|
|
5204
|
+
if (!hander.currentElement) {
|
|
5205
|
+
hander.doc.appendChild(node);
|
|
5206
|
+
} else {
|
|
5207
|
+
hander.currentElement.appendChild(node);
|
|
5208
|
+
}
|
|
5209
|
+
}//appendChild and setAttributeNS are preformance key
|
|
5210
|
+
|
|
5211
|
+
//if(typeof require == 'function'){
|
|
5212
|
+
var htmlEntity = require('./entities');
|
|
5213
|
+
var sax = require('./sax');
|
|
5214
|
+
var XMLReader = sax.XMLReader;
|
|
5215
|
+
var ParseError = sax.ParseError;
|
|
5216
|
+
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
|
|
5217
|
+
exports.XMLSerializer = require('./dom').XMLSerializer ;
|
|
5218
|
+
exports.DOMParser = DOMParser;
|
|
5219
|
+
exports.__DOMHandler = DOMHandler;
|
|
5220
|
+
//}
|
|
5221
|
+
|
|
5222
|
+
},{"./dom":31,"./entities":32,"./sax":33}],31:[function(require,module,exports){
|
|
5150
5223
|
function copy(src,dest){
|
|
5151
5224
|
for(var p in src){
|
|
5152
5225
|
dest[p] = src[p];
|
|
@@ -5158,10 +5231,6 @@ function copy(src,dest){
|
|
|
5158
5231
|
*/
|
|
5159
5232
|
function _extends(Class,Super){
|
|
5160
5233
|
var pt = Class.prototype;
|
|
5161
|
-
if(Object.create){
|
|
5162
|
-
var ppt = Object.create(Super.prototype)
|
|
5163
|
-
pt.__proto__ = ppt;
|
|
5164
|
-
}
|
|
5165
5234
|
if(!(pt instanceof Super)){
|
|
5166
5235
|
function t(){};
|
|
5167
5236
|
t.prototype = Super.prototype;
|
|
@@ -5212,7 +5281,12 @@ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((Exce
|
|
|
5212
5281
|
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
|
|
5213
5282
|
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
|
|
5214
5283
|
|
|
5215
|
-
|
|
5284
|
+
/**
|
|
5285
|
+
* DOM Level 2
|
|
5286
|
+
* Object DOMException
|
|
5287
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
|
|
5288
|
+
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
|
|
5289
|
+
*/
|
|
5216
5290
|
function DOMException(code, message) {
|
|
5217
5291
|
if(message instanceof Error){
|
|
5218
5292
|
var error = message;
|
|
@@ -5754,6 +5828,21 @@ Document.prototype = {
|
|
|
5754
5828
|
return rtv;
|
|
5755
5829
|
},
|
|
5756
5830
|
|
|
5831
|
+
getElementsByClassName: function(className) {
|
|
5832
|
+
var pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
|
|
5833
|
+
return new LiveNodeList(this, function(base) {
|
|
5834
|
+
var ls = [];
|
|
5835
|
+
_visitNode(base.documentElement, function(node) {
|
|
5836
|
+
if(node !== base && node.nodeType == ELEMENT_NODE) {
|
|
5837
|
+
if(pattern.test(node.getAttribute('class'))) {
|
|
5838
|
+
ls.push(node);
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
});
|
|
5842
|
+
return ls;
|
|
5843
|
+
});
|
|
5844
|
+
},
|
|
5845
|
+
|
|
5757
5846
|
//document factory method:
|
|
5758
5847
|
createElement : function(tagName){
|
|
5759
5848
|
var node = new Element();
|
|
@@ -6058,7 +6147,7 @@ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
|
|
|
6058
6147
|
Node.prototype.toString = nodeSerializeToString;
|
|
6059
6148
|
function nodeSerializeToString(isHtml,nodeFilter){
|
|
6060
6149
|
var buf = [];
|
|
6061
|
-
var refNode = this.nodeType == 9
|
|
6150
|
+
var refNode = this.nodeType == 9 && this.documentElement || this;
|
|
6062
6151
|
var prefix = refNode.prefix;
|
|
6063
6152
|
var uri = refNode.namespaceURI;
|
|
6064
6153
|
|
|
@@ -6197,9 +6286,27 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
|
6197
6286
|
}
|
|
6198
6287
|
return;
|
|
6199
6288
|
case ATTRIBUTE_NODE:
|
|
6200
|
-
return buf.push(' ',node.name,'="',node.value.replace(/[
|
|
6289
|
+
return buf.push(' ',node.name,'="',node.value.replace(/[&"]/g,_xmlEncoder),'"');
|
|
6201
6290
|
case TEXT_NODE:
|
|
6202
|
-
|
|
6291
|
+
/**
|
|
6292
|
+
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
6293
|
+
* except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
|
|
6294
|
+
* If they are needed elsewhere, they must be escaped using either numeric character references or the strings
|
|
6295
|
+
* `&` and `<` respectively.
|
|
6296
|
+
* The right angle bracket (>) may be represented using the string " > ", and must, for compatibility,
|
|
6297
|
+
* be escaped using either `>` or a character reference when it appears in the string `]]>` in content,
|
|
6298
|
+
* when that string is not marking the end of a CDATA section.
|
|
6299
|
+
*
|
|
6300
|
+
* In the content of elements, character data is any string of characters
|
|
6301
|
+
* which does not contain the start-delimiter of any markup
|
|
6302
|
+
* and does not include the CDATA-section-close delimiter, `]]>`.
|
|
6303
|
+
*
|
|
6304
|
+
* @see https://www.w3.org/TR/xml/#NT-CharData
|
|
6305
|
+
*/
|
|
6306
|
+
return buf.push(node.data
|
|
6307
|
+
.replace(/[<&]/g,_xmlEncoder)
|
|
6308
|
+
.replace(/]]>/g, ']]>')
|
|
6309
|
+
);
|
|
6203
6310
|
case CDATA_SECTION_NODE:
|
|
6204
6311
|
return buf.push( '<![CDATA[',node.data,']]>');
|
|
6205
6312
|
case COMMENT_NODE:
|
|
@@ -6209,13 +6316,13 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
|
6209
6316
|
var sysid = node.systemId;
|
|
6210
6317
|
buf.push('<!DOCTYPE ',node.name);
|
|
6211
6318
|
if(pubid){
|
|
6212
|
-
buf.push(' PUBLIC
|
|
6319
|
+
buf.push(' PUBLIC ', pubid);
|
|
6213
6320
|
if (sysid && sysid!='.') {
|
|
6214
|
-
buf.push(
|
|
6321
|
+
buf.push(' ', sysid);
|
|
6215
6322
|
}
|
|
6216
|
-
buf.push('
|
|
6323
|
+
buf.push('>');
|
|
6217
6324
|
}else if(sysid && sysid!='.'){
|
|
6218
|
-
buf.push(' SYSTEM
|
|
6325
|
+
buf.push(' SYSTEM ', sysid, '>');
|
|
6219
6326
|
}else{
|
|
6220
6327
|
var sub = node.internalSubset;
|
|
6221
6328
|
if(sub){
|
|
@@ -6381,644 +6488,904 @@ try{
|
|
|
6381
6488
|
}
|
|
6382
6489
|
|
|
6383
6490
|
//if(typeof require == 'function'){
|
|
6491
|
+
exports.Node = Node;
|
|
6492
|
+
exports.DOMException = DOMException;
|
|
6384
6493
|
exports.DOMImplementation = DOMImplementation;
|
|
6385
6494
|
exports.XMLSerializer = XMLSerializer;
|
|
6386
6495
|
//}
|
|
6387
6496
|
|
|
6388
6497
|
},{}],32:[function(require,module,exports){
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
}
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
}
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
}
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
var
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
}
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
}
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
//
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
6498
|
+
exports.entityMap = {
|
|
6499
|
+
lt: '<',
|
|
6500
|
+
gt: '>',
|
|
6501
|
+
amp: '&',
|
|
6502
|
+
quot: '"',
|
|
6503
|
+
apos: "'",
|
|
6504
|
+
Agrave: "À",
|
|
6505
|
+
Aacute: "Á",
|
|
6506
|
+
Acirc: "Â",
|
|
6507
|
+
Atilde: "Ã",
|
|
6508
|
+
Auml: "Ä",
|
|
6509
|
+
Aring: "Å",
|
|
6510
|
+
AElig: "Æ",
|
|
6511
|
+
Ccedil: "Ç",
|
|
6512
|
+
Egrave: "È",
|
|
6513
|
+
Eacute: "É",
|
|
6514
|
+
Ecirc: "Ê",
|
|
6515
|
+
Euml: "Ë",
|
|
6516
|
+
Igrave: "Ì",
|
|
6517
|
+
Iacute: "Í",
|
|
6518
|
+
Icirc: "Î",
|
|
6519
|
+
Iuml: "Ï",
|
|
6520
|
+
ETH: "Ð",
|
|
6521
|
+
Ntilde: "Ñ",
|
|
6522
|
+
Ograve: "Ò",
|
|
6523
|
+
Oacute: "Ó",
|
|
6524
|
+
Ocirc: "Ô",
|
|
6525
|
+
Otilde: "Õ",
|
|
6526
|
+
Ouml: "Ö",
|
|
6527
|
+
Oslash: "Ø",
|
|
6528
|
+
Ugrave: "Ù",
|
|
6529
|
+
Uacute: "Ú",
|
|
6530
|
+
Ucirc: "Û",
|
|
6531
|
+
Uuml: "Ü",
|
|
6532
|
+
Yacute: "Ý",
|
|
6533
|
+
THORN: "Þ",
|
|
6534
|
+
szlig: "ß",
|
|
6535
|
+
agrave: "à",
|
|
6536
|
+
aacute: "á",
|
|
6537
|
+
acirc: "â",
|
|
6538
|
+
atilde: "ã",
|
|
6539
|
+
auml: "ä",
|
|
6540
|
+
aring: "å",
|
|
6541
|
+
aelig: "æ",
|
|
6542
|
+
ccedil: "ç",
|
|
6543
|
+
egrave: "è",
|
|
6544
|
+
eacute: "é",
|
|
6545
|
+
ecirc: "ê",
|
|
6546
|
+
euml: "ë",
|
|
6547
|
+
igrave: "ì",
|
|
6548
|
+
iacute: "í",
|
|
6549
|
+
icirc: "î",
|
|
6550
|
+
iuml: "ï",
|
|
6551
|
+
eth: "ð",
|
|
6552
|
+
ntilde: "ñ",
|
|
6553
|
+
ograve: "ò",
|
|
6554
|
+
oacute: "ó",
|
|
6555
|
+
ocirc: "ô",
|
|
6556
|
+
otilde: "õ",
|
|
6557
|
+
ouml: "ö",
|
|
6558
|
+
oslash: "ø",
|
|
6559
|
+
ugrave: "ù",
|
|
6560
|
+
uacute: "ú",
|
|
6561
|
+
ucirc: "û",
|
|
6562
|
+
uuml: "ü",
|
|
6563
|
+
yacute: "ý",
|
|
6564
|
+
thorn: "þ",
|
|
6565
|
+
yuml: "ÿ",
|
|
6566
|
+
nbsp: "\u00a0",
|
|
6567
|
+
iexcl: "¡",
|
|
6568
|
+
cent: "¢",
|
|
6569
|
+
pound: "£",
|
|
6570
|
+
curren: "¤",
|
|
6571
|
+
yen: "¥",
|
|
6572
|
+
brvbar: "¦",
|
|
6573
|
+
sect: "§",
|
|
6574
|
+
uml: "¨",
|
|
6575
|
+
copy: "©",
|
|
6576
|
+
ordf: "ª",
|
|
6577
|
+
laquo: "«",
|
|
6578
|
+
not: "¬",
|
|
6579
|
+
shy: "",
|
|
6580
|
+
reg: "®",
|
|
6581
|
+
macr: "¯",
|
|
6582
|
+
deg: "°",
|
|
6583
|
+
plusmn: "±",
|
|
6584
|
+
sup2: "²",
|
|
6585
|
+
sup3: "³",
|
|
6586
|
+
acute: "´",
|
|
6587
|
+
micro: "µ",
|
|
6588
|
+
para: "¶",
|
|
6589
|
+
middot: "·",
|
|
6590
|
+
cedil: "¸",
|
|
6591
|
+
sup1: "¹",
|
|
6592
|
+
ordm: "º",
|
|
6593
|
+
raquo: "»",
|
|
6594
|
+
frac14: "¼",
|
|
6595
|
+
frac12: "½",
|
|
6596
|
+
frac34: "¾",
|
|
6597
|
+
iquest: "¿",
|
|
6598
|
+
times: "×",
|
|
6599
|
+
divide: "÷",
|
|
6600
|
+
forall: "∀",
|
|
6601
|
+
part: "∂",
|
|
6602
|
+
exist: "∃",
|
|
6603
|
+
empty: "∅",
|
|
6604
|
+
nabla: "∇",
|
|
6605
|
+
isin: "∈",
|
|
6606
|
+
notin: "∉",
|
|
6607
|
+
ni: "∋",
|
|
6608
|
+
prod: "∏",
|
|
6609
|
+
sum: "∑",
|
|
6610
|
+
minus: "−",
|
|
6611
|
+
lowast: "∗",
|
|
6612
|
+
radic: "√",
|
|
6613
|
+
prop: "∝",
|
|
6614
|
+
infin: "∞",
|
|
6615
|
+
ang: "∠",
|
|
6616
|
+
and: "∧",
|
|
6617
|
+
or: "∨",
|
|
6618
|
+
cap: "∩",
|
|
6619
|
+
cup: "∪",
|
|
6620
|
+
'int': "∫",
|
|
6621
|
+
there4: "∴",
|
|
6622
|
+
sim: "∼",
|
|
6623
|
+
cong: "≅",
|
|
6624
|
+
asymp: "≈",
|
|
6625
|
+
ne: "≠",
|
|
6626
|
+
equiv: "≡",
|
|
6627
|
+
le: "≤",
|
|
6628
|
+
ge: "≥",
|
|
6629
|
+
sub: "⊂",
|
|
6630
|
+
sup: "⊃",
|
|
6631
|
+
nsub: "⊄",
|
|
6632
|
+
sube: "⊆",
|
|
6633
|
+
supe: "⊇",
|
|
6634
|
+
oplus: "⊕",
|
|
6635
|
+
otimes: "⊗",
|
|
6636
|
+
perp: "⊥",
|
|
6637
|
+
sdot: "⋅",
|
|
6638
|
+
Alpha: "Α",
|
|
6639
|
+
Beta: "Β",
|
|
6640
|
+
Gamma: "Γ",
|
|
6641
|
+
Delta: "Δ",
|
|
6642
|
+
Epsilon: "Ε",
|
|
6643
|
+
Zeta: "Ζ",
|
|
6644
|
+
Eta: "Η",
|
|
6645
|
+
Theta: "Θ",
|
|
6646
|
+
Iota: "Ι",
|
|
6647
|
+
Kappa: "Κ",
|
|
6648
|
+
Lambda: "Λ",
|
|
6649
|
+
Mu: "Μ",
|
|
6650
|
+
Nu: "Ν",
|
|
6651
|
+
Xi: "Ξ",
|
|
6652
|
+
Omicron: "Ο",
|
|
6653
|
+
Pi: "Π",
|
|
6654
|
+
Rho: "Ρ",
|
|
6655
|
+
Sigma: "Σ",
|
|
6656
|
+
Tau: "Τ",
|
|
6657
|
+
Upsilon: "Υ",
|
|
6658
|
+
Phi: "Φ",
|
|
6659
|
+
Chi: "Χ",
|
|
6660
|
+
Psi: "Ψ",
|
|
6661
|
+
Omega: "Ω",
|
|
6662
|
+
alpha: "α",
|
|
6663
|
+
beta: "β",
|
|
6664
|
+
gamma: "γ",
|
|
6665
|
+
delta: "δ",
|
|
6666
|
+
epsilon: "ε",
|
|
6667
|
+
zeta: "ζ",
|
|
6668
|
+
eta: "η",
|
|
6669
|
+
theta: "θ",
|
|
6670
|
+
iota: "ι",
|
|
6671
|
+
kappa: "κ",
|
|
6672
|
+
lambda: "λ",
|
|
6673
|
+
mu: "μ",
|
|
6674
|
+
nu: "ν",
|
|
6675
|
+
xi: "ξ",
|
|
6676
|
+
omicron: "ο",
|
|
6677
|
+
pi: "π",
|
|
6678
|
+
rho: "ρ",
|
|
6679
|
+
sigmaf: "ς",
|
|
6680
|
+
sigma: "σ",
|
|
6681
|
+
tau: "τ",
|
|
6682
|
+
upsilon: "υ",
|
|
6683
|
+
phi: "φ",
|
|
6684
|
+
chi: "χ",
|
|
6685
|
+
psi: "ψ",
|
|
6686
|
+
omega: "ω",
|
|
6687
|
+
thetasym: "ϑ",
|
|
6688
|
+
upsih: "ϒ",
|
|
6689
|
+
piv: "ϖ",
|
|
6690
|
+
OElig: "Œ",
|
|
6691
|
+
oelig: "œ",
|
|
6692
|
+
Scaron: "Š",
|
|
6693
|
+
scaron: "š",
|
|
6694
|
+
Yuml: "Ÿ",
|
|
6695
|
+
fnof: "ƒ",
|
|
6696
|
+
circ: "ˆ",
|
|
6697
|
+
tilde: "˜",
|
|
6698
|
+
ensp: " ",
|
|
6699
|
+
emsp: " ",
|
|
6700
|
+
thinsp: " ",
|
|
6701
|
+
zwnj: "",
|
|
6702
|
+
zwj: "",
|
|
6703
|
+
lrm: "",
|
|
6704
|
+
rlm: "",
|
|
6705
|
+
ndash: "–",
|
|
6706
|
+
mdash: "—",
|
|
6707
|
+
lsquo: "‘",
|
|
6708
|
+
rsquo: "’",
|
|
6709
|
+
sbquo: "‚",
|
|
6710
|
+
ldquo: "“",
|
|
6711
|
+
rdquo: "”",
|
|
6712
|
+
bdquo: "„",
|
|
6713
|
+
dagger: "†",
|
|
6714
|
+
Dagger: "‡",
|
|
6715
|
+
bull: "•",
|
|
6716
|
+
hellip: "…",
|
|
6717
|
+
permil: "‰",
|
|
6718
|
+
prime: "′",
|
|
6719
|
+
Prime: "″",
|
|
6720
|
+
lsaquo: "‹",
|
|
6721
|
+
rsaquo: "›",
|
|
6722
|
+
oline: "‾",
|
|
6723
|
+
euro: "€",
|
|
6724
|
+
trade: "™",
|
|
6725
|
+
larr: "←",
|
|
6726
|
+
uarr: "↑",
|
|
6727
|
+
rarr: "→",
|
|
6728
|
+
darr: "↓",
|
|
6729
|
+
harr: "↔",
|
|
6730
|
+
crarr: "↵",
|
|
6731
|
+
lceil: "⌈",
|
|
6732
|
+
rceil: "⌉",
|
|
6733
|
+
lfloor: "⌊",
|
|
6734
|
+
rfloor: "⌋",
|
|
6735
|
+
loz: "◊",
|
|
6736
|
+
spades: "♠",
|
|
6737
|
+
clubs: "♣",
|
|
6738
|
+
hearts: "♥",
|
|
6739
|
+
diams: "♦"
|
|
6740
|
+
};
|
|
6741
|
+
|
|
6742
|
+
},{}],33:[function(require,module,exports){
|
|
6743
|
+
//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
6744
|
+
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
6745
|
+
//[5] Name ::= NameStartChar (NameChar)*
|
|
6746
|
+
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
|
|
6747
|
+
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
|
6748
|
+
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
|
|
6749
|
+
//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
|
|
6750
|
+
//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
|
|
6751
|
+
|
|
6752
|
+
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
|
6753
|
+
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
|
6754
|
+
var S_TAG = 0;//tag name offerring
|
|
6755
|
+
var S_ATTR = 1;//attr name offerring
|
|
6756
|
+
var S_ATTR_SPACE=2;//attr name end and space offer
|
|
6757
|
+
var S_EQ = 3;//=space?
|
|
6758
|
+
var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
|
|
6759
|
+
var S_ATTR_END = 5;//attr value end and no space(quot end)
|
|
6760
|
+
var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
|
|
6761
|
+
var S_TAG_CLOSE = 7;//closed el<el />
|
|
6762
|
+
|
|
6763
|
+
/**
|
|
6764
|
+
* Creates an error that will not be caught by XMLReader aka the SAX parser.
|
|
6765
|
+
*
|
|
6766
|
+
* @param {string} message
|
|
6767
|
+
* @param {any?} locator Optional, can provide details about the location in the source
|
|
6768
|
+
* @constructor
|
|
6769
|
+
*/
|
|
6770
|
+
function ParseError(message, locator) {
|
|
6771
|
+
this.message = message
|
|
6772
|
+
this.locator = locator
|
|
6773
|
+
if(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
|
|
6774
|
+
}
|
|
6775
|
+
ParseError.prototype = new Error();
|
|
6776
|
+
ParseError.prototype.name = ParseError.name
|
|
6777
|
+
|
|
6778
|
+
function XMLReader(){
|
|
6779
|
+
|
|
6780
|
+
}
|
|
6781
|
+
|
|
6782
|
+
XMLReader.prototype = {
|
|
6783
|
+
parse:function(source,defaultNSMap,entityMap){
|
|
6784
|
+
var domBuilder = this.domBuilder;
|
|
6785
|
+
domBuilder.startDocument();
|
|
6786
|
+
_copy(defaultNSMap ,defaultNSMap = {})
|
|
6787
|
+
parse(source,defaultNSMap,entityMap,
|
|
6788
|
+
domBuilder,this.errorHandler);
|
|
6789
|
+
domBuilder.endDocument();
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6792
|
+
function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
|
|
6793
|
+
function fixedFromCharCode(code) {
|
|
6794
|
+
// String.prototype.fromCharCode does not supports
|
|
6795
|
+
// > 2 bytes unicode chars directly
|
|
6796
|
+
if (code > 0xffff) {
|
|
6797
|
+
code -= 0x10000;
|
|
6798
|
+
var surrogate1 = 0xd800 + (code >> 10)
|
|
6799
|
+
, surrogate2 = 0xdc00 + (code & 0x3ff);
|
|
6800
|
+
|
|
6801
|
+
return String.fromCharCode(surrogate1, surrogate2);
|
|
6802
|
+
} else {
|
|
6803
|
+
return String.fromCharCode(code);
|
|
6804
|
+
}
|
|
6805
|
+
}
|
|
6806
|
+
function entityReplacer(a){
|
|
6807
|
+
var k = a.slice(1,-1);
|
|
6808
|
+
if(k in entityMap){
|
|
6809
|
+
return entityMap[k];
|
|
6810
|
+
}else if(k.charAt(0) === '#'){
|
|
6811
|
+
return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
|
|
6812
|
+
}else{
|
|
6813
|
+
errorHandler.error('entity not found:'+a);
|
|
6814
|
+
return a;
|
|
6815
|
+
}
|
|
6816
|
+
}
|
|
6817
|
+
function appendText(end){//has some bugs
|
|
6818
|
+
if(end>start){
|
|
6819
|
+
var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
|
|
6820
|
+
locator&&position(start);
|
|
6821
|
+
domBuilder.characters(xt,0,end-start);
|
|
6822
|
+
start = end
|
|
6823
|
+
}
|
|
6824
|
+
}
|
|
6825
|
+
function position(p,m){
|
|
6826
|
+
while(p>=lineEnd && (m = linePattern.exec(source))){
|
|
6827
|
+
lineStart = m.index;
|
|
6828
|
+
lineEnd = lineStart + m[0].length;
|
|
6829
|
+
locator.lineNumber++;
|
|
6830
|
+
//console.log('line++:',locator,startPos,endPos)
|
|
6831
|
+
}
|
|
6832
|
+
locator.columnNumber = p-lineStart+1;
|
|
6833
|
+
}
|
|
6834
|
+
var lineStart = 0;
|
|
6835
|
+
var lineEnd = 0;
|
|
6836
|
+
var linePattern = /.*(?:\r\n?|\n)|.*$/g
|
|
6837
|
+
var locator = domBuilder.locator;
|
|
6838
|
+
|
|
6839
|
+
var parseStack = [{currentNSMap:defaultNSMapCopy}]
|
|
6840
|
+
var closeMap = {};
|
|
6841
|
+
var start = 0;
|
|
6842
|
+
while(true){
|
|
6843
|
+
try{
|
|
6844
|
+
var tagStart = source.indexOf('<',start);
|
|
6845
|
+
if(tagStart<0){
|
|
6846
|
+
if(!source.substr(start).match(/^\s*$/)){
|
|
6847
|
+
var doc = domBuilder.doc;
|
|
6848
|
+
var text = doc.createTextNode(source.substr(start));
|
|
6849
|
+
doc.appendChild(text);
|
|
6850
|
+
domBuilder.currentElement = text;
|
|
6851
|
+
}
|
|
6852
|
+
return;
|
|
6853
|
+
}
|
|
6854
|
+
if(tagStart>start){
|
|
6855
|
+
appendText(tagStart);
|
|
6856
|
+
}
|
|
6857
|
+
switch(source.charAt(tagStart+1)){
|
|
6858
|
+
case '/':
|
|
6859
|
+
var end = source.indexOf('>',tagStart+3);
|
|
6860
|
+
var tagName = source.substring(tagStart+2,end);
|
|
6861
|
+
var config = parseStack.pop();
|
|
6862
|
+
if(end<0){
|
|
6863
|
+
|
|
6864
|
+
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
|
|
6865
|
+
//console.error('#@@@@@@'+tagName)
|
|
6866
|
+
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
|
|
6867
|
+
end = tagStart+1+tagName.length;
|
|
6868
|
+
}else if(tagName.match(/\s</)){
|
|
6869
|
+
tagName = tagName.replace(/[\s<].*/,'');
|
|
6870
|
+
errorHandler.error("end tag name: "+tagName+' maybe not complete');
|
|
6871
|
+
end = tagStart+1+tagName.length;
|
|
6872
|
+
}
|
|
6873
|
+
//console.error(parseStack.length,parseStack)
|
|
6874
|
+
//console.error(config);
|
|
6875
|
+
var localNSMap = config.localNSMap;
|
|
6876
|
+
var endMatch = config.tagName == tagName;
|
|
6877
|
+
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
|
|
6878
|
+
if(endIgnoreCaseMach){
|
|
6879
|
+
domBuilder.endElement(config.uri,config.localName,tagName);
|
|
6880
|
+
if(localNSMap){
|
|
6881
|
+
for(var prefix in localNSMap){
|
|
6882
|
+
domBuilder.endPrefixMapping(prefix) ;
|
|
6883
|
+
}
|
|
6884
|
+
}
|
|
6885
|
+
if(!endMatch){
|
|
6886
|
+
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case
|
|
6887
|
+
}
|
|
6888
|
+
}else{
|
|
6889
|
+
parseStack.push(config)
|
|
6890
|
+
}
|
|
6891
|
+
|
|
6892
|
+
end++;
|
|
6893
|
+
break;
|
|
6894
|
+
// end elment
|
|
6895
|
+
case '?':// <?...?>
|
|
6896
|
+
locator&&position(tagStart);
|
|
6897
|
+
end = parseInstruction(source,tagStart,domBuilder);
|
|
6898
|
+
break;
|
|
6899
|
+
case '!':// <!doctype,<![CDATA,<!--
|
|
6900
|
+
locator&&position(tagStart);
|
|
6901
|
+
end = parseDCC(source,tagStart,domBuilder,errorHandler);
|
|
6902
|
+
break;
|
|
6903
|
+
default:
|
|
6904
|
+
locator&&position(tagStart);
|
|
6905
|
+
var el = new ElementAttributes();
|
|
6906
|
+
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
|
6907
|
+
//elStartEnd
|
|
6908
|
+
var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
|
|
6909
|
+
var len = el.length;
|
|
6910
|
+
|
|
6911
|
+
|
|
6912
|
+
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
|
|
6913
|
+
el.closed = true;
|
|
6914
|
+
if(!entityMap.nbsp){
|
|
6915
|
+
errorHandler.warning('unclosed xml attribute');
|
|
6916
|
+
}
|
|
6917
|
+
}
|
|
6918
|
+
if(locator && len){
|
|
6919
|
+
var locator2 = copyLocator(locator,{});
|
|
6920
|
+
//try{//attribute position fixed
|
|
6921
|
+
for(var i = 0;i<len;i++){
|
|
6922
|
+
var a = el[i];
|
|
6923
|
+
position(a.offset);
|
|
6924
|
+
a.locator = copyLocator(locator,{});
|
|
6925
|
+
}
|
|
6926
|
+
//}catch(e){console.error('@@@@@'+e)}
|
|
6927
|
+
domBuilder.locator = locator2
|
|
6928
|
+
if(appendElement(el,domBuilder,currentNSMap)){
|
|
6929
|
+
parseStack.push(el)
|
|
6930
|
+
}
|
|
6931
|
+
domBuilder.locator = locator;
|
|
6932
|
+
}else{
|
|
6933
|
+
if(appendElement(el,domBuilder,currentNSMap)){
|
|
6934
|
+
parseStack.push(el)
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
6937
|
+
|
|
6938
|
+
|
|
6939
|
+
|
|
6940
|
+
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
|
|
6941
|
+
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
|
|
6942
|
+
}else{
|
|
6943
|
+
end++;
|
|
6944
|
+
}
|
|
6945
|
+
}
|
|
6946
|
+
}catch(e){
|
|
6947
|
+
if (e instanceof ParseError) {
|
|
6948
|
+
throw e;
|
|
6949
|
+
}
|
|
6950
|
+
errorHandler.error('element parse error: '+e)
|
|
6951
|
+
end = -1;
|
|
6952
|
+
}
|
|
6953
|
+
if(end>start){
|
|
6954
|
+
start = end;
|
|
6955
|
+
}else{
|
|
6956
|
+
//TODO: 这里有可能sax回退,有位置错误风险
|
|
6957
|
+
appendText(Math.max(tagStart,start)+1);
|
|
6958
|
+
}
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
function copyLocator(f,t){
|
|
6962
|
+
t.lineNumber = f.lineNumber;
|
|
6963
|
+
t.columnNumber = f.columnNumber;
|
|
6964
|
+
return t;
|
|
6965
|
+
}
|
|
6966
|
+
|
|
6967
|
+
/**
|
|
6968
|
+
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
|
|
6969
|
+
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
|
|
6970
|
+
*/
|
|
6971
|
+
function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
|
|
6972
|
+
|
|
6973
|
+
/**
|
|
6974
|
+
* @param {string} qname
|
|
6975
|
+
* @param {string} value
|
|
6976
|
+
* @param {number} startIndex
|
|
6977
|
+
*/
|
|
6978
|
+
function addAttribute(qname, value, startIndex) {
|
|
6979
|
+
if (qname in el.attributeNames) errorHandler.fatalError('Attribute ' + qname + ' redefined')
|
|
6980
|
+
el.addValue(qname, value, startIndex)
|
|
6981
|
+
}
|
|
6982
|
+
var attrName;
|
|
6983
|
+
var value;
|
|
6984
|
+
var p = ++start;
|
|
6985
|
+
var s = S_TAG;//status
|
|
6986
|
+
while(true){
|
|
6987
|
+
var c = source.charAt(p);
|
|
6988
|
+
switch(c){
|
|
6989
|
+
case '=':
|
|
6990
|
+
if(s === S_ATTR){//attrName
|
|
6991
|
+
attrName = source.slice(start,p);
|
|
6992
|
+
s = S_EQ;
|
|
6993
|
+
}else if(s === S_ATTR_SPACE){
|
|
6994
|
+
s = S_EQ;
|
|
6995
|
+
}else{
|
|
6996
|
+
//fatalError: equal must after attrName or space after attrName
|
|
6997
|
+
throw new Error('attribute equal must after attrName'); // No known test case
|
|
6998
|
+
}
|
|
6999
|
+
break;
|
|
7000
|
+
case '\'':
|
|
7001
|
+
case '"':
|
|
7002
|
+
if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
|
|
7003
|
+
){//equal
|
|
7004
|
+
if(s === S_ATTR){
|
|
7005
|
+
errorHandler.warning('attribute value must after "="')
|
|
7006
|
+
attrName = source.slice(start,p)
|
|
7007
|
+
}
|
|
7008
|
+
start = p+1;
|
|
7009
|
+
p = source.indexOf(c,start)
|
|
7010
|
+
if(p>0){
|
|
7011
|
+
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
|
7012
|
+
addAttribute(attrName, value, start-1);
|
|
7013
|
+
s = S_ATTR_END;
|
|
7014
|
+
}else{
|
|
7015
|
+
//fatalError: no end quot match
|
|
7016
|
+
throw new Error('attribute value no end \''+c+'\' match');
|
|
7017
|
+
}
|
|
7018
|
+
}else if(s == S_ATTR_NOQUOT_VALUE){
|
|
7019
|
+
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
|
7020
|
+
//console.log(attrName,value,start,p)
|
|
7021
|
+
addAttribute(attrName, value, start);
|
|
7022
|
+
//console.dir(el)
|
|
7023
|
+
errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
|
|
7024
|
+
start = p+1;
|
|
7025
|
+
s = S_ATTR_END
|
|
7026
|
+
}else{
|
|
7027
|
+
//fatalError: no equal before
|
|
7028
|
+
throw new Error('attribute value must after "="'); // No known test case
|
|
7029
|
+
}
|
|
7030
|
+
break;
|
|
7031
|
+
case '/':
|
|
7032
|
+
switch(s){
|
|
7033
|
+
case S_TAG:
|
|
7034
|
+
el.setTagName(source.slice(start,p));
|
|
7035
|
+
case S_ATTR_END:
|
|
7036
|
+
case S_TAG_SPACE:
|
|
7037
|
+
case S_TAG_CLOSE:
|
|
7038
|
+
s =S_TAG_CLOSE;
|
|
7039
|
+
el.closed = true;
|
|
7040
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
7041
|
+
case S_ATTR:
|
|
7042
|
+
case S_ATTR_SPACE:
|
|
7043
|
+
break;
|
|
7044
|
+
//case S_EQ:
|
|
7045
|
+
default:
|
|
7046
|
+
throw new Error("attribute invalid close char('/')") // No known test case
|
|
7047
|
+
}
|
|
7048
|
+
break;
|
|
7049
|
+
case ''://end document
|
|
7050
|
+
errorHandler.error('unexpected end of input');
|
|
7051
|
+
if(s == S_TAG){
|
|
7052
|
+
el.setTagName(source.slice(start,p));
|
|
7053
|
+
}
|
|
7054
|
+
return p;
|
|
7055
|
+
case '>':
|
|
7056
|
+
switch(s){
|
|
7057
|
+
case S_TAG:
|
|
7058
|
+
el.setTagName(source.slice(start,p));
|
|
7059
|
+
case S_ATTR_END:
|
|
7060
|
+
case S_TAG_SPACE:
|
|
7061
|
+
case S_TAG_CLOSE:
|
|
7062
|
+
break;//normal
|
|
7063
|
+
case S_ATTR_NOQUOT_VALUE://Compatible state
|
|
7064
|
+
case S_ATTR:
|
|
7065
|
+
value = source.slice(start,p);
|
|
7066
|
+
if(value.slice(-1) === '/'){
|
|
7067
|
+
el.closed = true;
|
|
7068
|
+
value = value.slice(0,-1)
|
|
7069
|
+
}
|
|
7070
|
+
case S_ATTR_SPACE:
|
|
7071
|
+
if(s === S_ATTR_SPACE){
|
|
7072
|
+
value = attrName;
|
|
7073
|
+
}
|
|
7074
|
+
if(s == S_ATTR_NOQUOT_VALUE){
|
|
7075
|
+
errorHandler.warning('attribute "'+value+'" missed quot(")!');
|
|
7076
|
+
addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start)
|
|
7077
|
+
}else{
|
|
7078
|
+
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
|
|
7079
|
+
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
|
|
7080
|
+
}
|
|
7081
|
+
addAttribute(value, value, start)
|
|
7082
|
+
}
|
|
7083
|
+
break;
|
|
7084
|
+
case S_EQ:
|
|
7085
|
+
throw new Error('attribute value missed!!');
|
|
7086
|
+
}
|
|
7087
|
+
// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
|
|
7088
|
+
return p;
|
|
7089
|
+
/*xml space '\x20' | #x9 | #xD | #xA; */
|
|
7090
|
+
case '\u0080':
|
|
7091
|
+
c = ' ';
|
|
7092
|
+
default:
|
|
7093
|
+
if(c<= ' '){//space
|
|
7094
|
+
switch(s){
|
|
7095
|
+
case S_TAG:
|
|
7096
|
+
el.setTagName(source.slice(start,p));//tagName
|
|
7097
|
+
s = S_TAG_SPACE;
|
|
7098
|
+
break;
|
|
7099
|
+
case S_ATTR:
|
|
7100
|
+
attrName = source.slice(start,p)
|
|
7101
|
+
s = S_ATTR_SPACE;
|
|
7102
|
+
break;
|
|
7103
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
7104
|
+
var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
|
7105
|
+
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
|
|
7106
|
+
addAttribute(attrName, value, start)
|
|
7107
|
+
case S_ATTR_END:
|
|
7108
|
+
s = S_TAG_SPACE;
|
|
7109
|
+
break;
|
|
7110
|
+
//case S_TAG_SPACE:
|
|
7111
|
+
//case S_EQ:
|
|
7112
|
+
//case S_ATTR_SPACE:
|
|
7113
|
+
// void();break;
|
|
7114
|
+
//case S_TAG_CLOSE:
|
|
7115
|
+
//ignore warning
|
|
7116
|
+
}
|
|
7117
|
+
}else{//not space
|
|
7118
|
+
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
|
7119
|
+
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
|
7120
|
+
switch(s){
|
|
7121
|
+
//case S_TAG:void();break;
|
|
7122
|
+
//case S_ATTR:void();break;
|
|
7123
|
+
//case S_ATTR_NOQUOT_VALUE:void();break;
|
|
7124
|
+
case S_ATTR_SPACE:
|
|
7125
|
+
var tagName = el.tagName;
|
|
7126
|
+
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
|
|
7127
|
+
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
|
|
7128
|
+
}
|
|
7129
|
+
addAttribute(attrName, attrName, start);
|
|
7130
|
+
start = p;
|
|
7131
|
+
s = S_ATTR;
|
|
7132
|
+
break;
|
|
7133
|
+
case S_ATTR_END:
|
|
7134
|
+
errorHandler.warning('attribute space is required"'+attrName+'"!!')
|
|
7135
|
+
case S_TAG_SPACE:
|
|
7136
|
+
s = S_ATTR;
|
|
7137
|
+
start = p;
|
|
7138
|
+
break;
|
|
7139
|
+
case S_EQ:
|
|
7140
|
+
s = S_ATTR_NOQUOT_VALUE;
|
|
7141
|
+
start = p;
|
|
7142
|
+
break;
|
|
7143
|
+
case S_TAG_CLOSE:
|
|
7144
|
+
throw new Error("elements closed character '/' and '>' must be connected to");
|
|
7145
|
+
}
|
|
7146
|
+
}
|
|
7147
|
+
}//end outer switch
|
|
7148
|
+
//console.log('p++',p)
|
|
7149
|
+
p++;
|
|
7150
|
+
}
|
|
7151
|
+
}
|
|
7152
|
+
/**
|
|
7153
|
+
* @return true if has new namespace define
|
|
7154
|
+
*/
|
|
7155
|
+
function appendElement(el,domBuilder,currentNSMap){
|
|
7156
|
+
var tagName = el.tagName;
|
|
7157
|
+
var localNSMap = null;
|
|
7158
|
+
//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
|
7159
|
+
var i = el.length;
|
|
7160
|
+
while(i--){
|
|
7161
|
+
var a = el[i];
|
|
7162
|
+
var qName = a.qName;
|
|
7163
|
+
var value = a.value;
|
|
7164
|
+
var nsp = qName.indexOf(':');
|
|
7165
|
+
if(nsp>0){
|
|
7166
|
+
var prefix = a.prefix = qName.slice(0,nsp);
|
|
7167
|
+
var localName = qName.slice(nsp+1);
|
|
7168
|
+
var nsPrefix = prefix === 'xmlns' && localName
|
|
7169
|
+
}else{
|
|
7170
|
+
localName = qName;
|
|
7171
|
+
prefix = null
|
|
7172
|
+
nsPrefix = qName === 'xmlns' && ''
|
|
7173
|
+
}
|
|
7174
|
+
//can not set prefix,because prefix !== ''
|
|
7175
|
+
a.localName = localName ;
|
|
7176
|
+
//prefix == null for no ns prefix attribute
|
|
7177
|
+
if(nsPrefix !== false){//hack!!
|
|
7178
|
+
if(localNSMap == null){
|
|
7179
|
+
localNSMap = {}
|
|
7180
|
+
//console.log(currentNSMap,0)
|
|
7181
|
+
_copy(currentNSMap,currentNSMap={})
|
|
7182
|
+
//console.log(currentNSMap,1)
|
|
7183
|
+
}
|
|
7184
|
+
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
7185
|
+
a.uri = 'http://www.w3.org/2000/xmlns/'
|
|
7186
|
+
domBuilder.startPrefixMapping(nsPrefix, value)
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
var i = el.length;
|
|
7190
|
+
while(i--){
|
|
7191
|
+
a = el[i];
|
|
7192
|
+
var prefix = a.prefix;
|
|
7193
|
+
if(prefix){//no prefix attribute has no namespace
|
|
7194
|
+
if(prefix === 'xml'){
|
|
7195
|
+
a.uri = 'http://www.w3.org/XML/1998/namespace';
|
|
7196
|
+
}if(prefix !== 'xmlns'){
|
|
7197
|
+
a.uri = currentNSMap[prefix || '']
|
|
7198
|
+
|
|
7199
|
+
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
|
|
7200
|
+
}
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
var nsp = tagName.indexOf(':');
|
|
7204
|
+
if(nsp>0){
|
|
7205
|
+
prefix = el.prefix = tagName.slice(0,nsp);
|
|
7206
|
+
localName = el.localName = tagName.slice(nsp+1);
|
|
7207
|
+
}else{
|
|
7208
|
+
prefix = null;//important!!
|
|
7209
|
+
localName = el.localName = tagName;
|
|
7210
|
+
}
|
|
7211
|
+
//no prefix element has default namespace
|
|
7212
|
+
var ns = el.uri = currentNSMap[prefix || ''];
|
|
7213
|
+
domBuilder.startElement(ns,localName,tagName,el);
|
|
7214
|
+
//endPrefixMapping and startPrefixMapping have not any help for dom builder
|
|
7215
|
+
//localNSMap = null
|
|
7216
|
+
if(el.closed){
|
|
7217
|
+
domBuilder.endElement(ns,localName,tagName);
|
|
7218
|
+
if(localNSMap){
|
|
7219
|
+
for(prefix in localNSMap){
|
|
7220
|
+
domBuilder.endPrefixMapping(prefix)
|
|
7221
|
+
}
|
|
7222
|
+
}
|
|
7223
|
+
}else{
|
|
7224
|
+
el.currentNSMap = currentNSMap;
|
|
7225
|
+
el.localNSMap = localNSMap;
|
|
7226
|
+
//parseStack.push(el);
|
|
7227
|
+
return true;
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7230
|
+
function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
|
|
7231
|
+
if(/^(?:script|textarea)$/i.test(tagName)){
|
|
7232
|
+
var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
|
|
7233
|
+
var text = source.substring(elStartEnd+1,elEndStart);
|
|
7234
|
+
if(/[&<]/.test(text)){
|
|
7235
|
+
if(/^script$/i.test(tagName)){
|
|
7236
|
+
//if(!/\]\]>/.test(text)){
|
|
7237
|
+
//lexHandler.startCDATA();
|
|
7238
|
+
domBuilder.characters(text,0,text.length);
|
|
7239
|
+
//lexHandler.endCDATA();
|
|
7240
|
+
return elEndStart;
|
|
7241
|
+
//}
|
|
7242
|
+
}//}else{//text area
|
|
7243
|
+
text = text.replace(/&#?\w+;/g,entityReplacer);
|
|
7244
|
+
domBuilder.characters(text,0,text.length);
|
|
7245
|
+
return elEndStart;
|
|
7246
|
+
//}
|
|
7247
|
+
|
|
7248
|
+
}
|
|
7249
|
+
}
|
|
7250
|
+
return elStartEnd+1;
|
|
7251
|
+
}
|
|
7252
|
+
function fixSelfClosed(source,elStartEnd,tagName,closeMap){
|
|
7253
|
+
//if(tagName in closeMap){
|
|
7254
|
+
var pos = closeMap[tagName];
|
|
7255
|
+
if(pos == null){
|
|
7256
|
+
//console.log(tagName)
|
|
7257
|
+
pos = source.lastIndexOf('</'+tagName+'>')
|
|
7258
|
+
if(pos<elStartEnd){//忘记闭合
|
|
7259
|
+
pos = source.lastIndexOf('</'+tagName)
|
|
7260
|
+
}
|
|
7261
|
+
closeMap[tagName] =pos
|
|
7262
|
+
}
|
|
7263
|
+
return pos<elStartEnd;
|
|
7264
|
+
//}
|
|
7265
|
+
}
|
|
7266
|
+
function _copy(source,target){
|
|
7267
|
+
for(var n in source){target[n] = source[n]}
|
|
7268
|
+
}
|
|
7269
|
+
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
|
|
7270
|
+
var next= source.charAt(start+2)
|
|
7271
|
+
switch(next){
|
|
7272
|
+
case '-':
|
|
7273
|
+
if(source.charAt(start + 3) === '-'){
|
|
7274
|
+
var end = source.indexOf('-->',start+4);
|
|
7275
|
+
//append comment source.substring(4,end)//<!--
|
|
7276
|
+
if(end>start){
|
|
7277
|
+
domBuilder.comment(source,start+4,end-start-4);
|
|
7278
|
+
return end+3;
|
|
7279
|
+
}else{
|
|
7280
|
+
errorHandler.error("Unclosed comment");
|
|
7281
|
+
return -1;
|
|
7282
|
+
}
|
|
7283
|
+
}else{
|
|
7284
|
+
//error
|
|
7285
|
+
return -1;
|
|
7286
|
+
}
|
|
7287
|
+
default:
|
|
7288
|
+
if(source.substr(start+3,6) == 'CDATA['){
|
|
7289
|
+
var end = source.indexOf(']]>',start+9);
|
|
7290
|
+
domBuilder.startCDATA();
|
|
7291
|
+
domBuilder.characters(source,start+9,end-start-9);
|
|
7292
|
+
domBuilder.endCDATA()
|
|
7293
|
+
return end+3;
|
|
7294
|
+
}
|
|
7295
|
+
//<!DOCTYPE
|
|
7296
|
+
//startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
|
|
7297
|
+
var matchs = split(source,start);
|
|
7298
|
+
var len = matchs.length;
|
|
7299
|
+
if(len>1 && /!doctype/i.test(matchs[0][0])){
|
|
7300
|
+
var name = matchs[1][0];
|
|
7301
|
+
var pubid = false;
|
|
7302
|
+
var sysid = false;
|
|
7303
|
+
if(len>3){
|
|
7304
|
+
if(/^public$/i.test(matchs[2][0])){
|
|
7305
|
+
pubid = matchs[3][0];
|
|
7306
|
+
sysid = len>4 && matchs[4][0];
|
|
7307
|
+
}else if(/^system$/i.test(matchs[2][0])){
|
|
7308
|
+
sysid = matchs[3][0];
|
|
7309
|
+
}
|
|
7310
|
+
}
|
|
7311
|
+
var lastMatch = matchs[len-1]
|
|
7312
|
+
domBuilder.startDTD(name, pubid, sysid);
|
|
7313
|
+
domBuilder.endDTD();
|
|
7314
|
+
|
|
7315
|
+
return lastMatch.index+lastMatch[0].length
|
|
7316
|
+
}
|
|
7317
|
+
}
|
|
7318
|
+
return -1;
|
|
7319
|
+
}
|
|
7320
|
+
|
|
7321
|
+
|
|
7322
|
+
|
|
7323
|
+
function parseInstruction(source,start,domBuilder){
|
|
7324
|
+
var end = source.indexOf('?>',start);
|
|
7325
|
+
if(end){
|
|
7326
|
+
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
|
7327
|
+
if(match){
|
|
7328
|
+
var len = match[0].length;
|
|
7329
|
+
domBuilder.processingInstruction(match[1], match[2]) ;
|
|
7330
|
+
return end+2;
|
|
7331
|
+
}else{//error
|
|
7332
|
+
return -1;
|
|
7333
|
+
}
|
|
7334
|
+
}
|
|
7335
|
+
return -1;
|
|
7336
|
+
}
|
|
7337
|
+
|
|
7338
|
+
function ElementAttributes(){
|
|
7339
|
+
this.attributeNames = {}
|
|
7340
|
+
}
|
|
7341
|
+
ElementAttributes.prototype = {
|
|
7342
|
+
setTagName:function(tagName){
|
|
7343
|
+
if(!tagNamePattern.test(tagName)){
|
|
7344
|
+
throw new Error('invalid tagName:'+tagName)
|
|
7345
|
+
}
|
|
7346
|
+
this.tagName = tagName
|
|
7347
|
+
},
|
|
7348
|
+
addValue:function(qName, value, offset) {
|
|
7349
|
+
if(!tagNamePattern.test(qName)){
|
|
7350
|
+
throw new Error('invalid attribute:'+qName)
|
|
7351
|
+
}
|
|
7352
|
+
this.attributeNames[qName] = this.length;
|
|
7353
|
+
this[this.length++] = {qName:qName,value:value,offset:offset}
|
|
7354
|
+
},
|
|
7355
|
+
length:0,
|
|
7356
|
+
getLocalName:function(i){return this[i].localName},
|
|
7357
|
+
getLocator:function(i){return this[i].locator},
|
|
7358
|
+
getQName:function(i){return this[i].qName},
|
|
7359
|
+
getURI:function(i){return this[i].uri},
|
|
7360
|
+
getValue:function(i){return this[i].value}
|
|
7361
|
+
// ,getIndex:function(uri, localName)){
|
|
7362
|
+
// if(localName){
|
|
7363
|
+
//
|
|
7364
|
+
// }else{
|
|
7365
|
+
// var qName = uri
|
|
7366
|
+
// }
|
|
7367
|
+
// },
|
|
7368
|
+
// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
|
|
7369
|
+
// getType:function(uri,localName){}
|
|
7370
|
+
// getType:function(i){},
|
|
7371
|
+
}
|
|
7372
|
+
|
|
7373
|
+
|
|
7374
|
+
|
|
7375
|
+
function split(source,start){
|
|
7376
|
+
var match;
|
|
7377
|
+
var buf = [];
|
|
7378
|
+
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
|
7379
|
+
reg.lastIndex = start;
|
|
7380
|
+
reg.exec(source);//skip <
|
|
7381
|
+
while(match = reg.exec(source)){
|
|
7382
|
+
buf.push(match);
|
|
7383
|
+
if(match[1])return buf;
|
|
7384
|
+
}
|
|
7385
|
+
}
|
|
7386
|
+
|
|
7387
|
+
exports.XMLReader = XMLReader;
|
|
7388
|
+
exports.ParseError = ParseError;
|
|
7022
7389
|
|
|
7023
7390
|
},{}]},{},[1])(1)
|
|
7024
7391
|
});
|