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-parse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
2
|
-
(function (Buffer){
|
|
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
|
+
(function (Buffer){(function (){
|
|
3
3
|
/**
|
|
4
4
|
* Module dependencies.
|
|
5
5
|
*/
|
|
@@ -216,7 +216,7 @@ function parsePlistXML (node) {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
}).call(this,require("buffer").Buffer)
|
|
219
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
220
220
|
},{"buffer":3,"xmldom":5}],2:[function(require,module,exports){
|
|
221
221
|
'use strict'
|
|
222
222
|
|
|
@@ -239,65 +239,98 @@ for (var i = 0, len = code.length; i < len; ++i) {
|
|
|
239
239
|
revLookup['-'.charCodeAt(0)] = 62
|
|
240
240
|
revLookup['_'.charCodeAt(0)] = 63
|
|
241
241
|
|
|
242
|
-
function
|
|
242
|
+
function getLens (b64) {
|
|
243
243
|
var len = b64.length
|
|
244
|
+
|
|
244
245
|
if (len % 4 > 0) {
|
|
245
246
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
246
247
|
}
|
|
247
248
|
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
250
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
251
|
+
var validLen = b64.indexOf('=')
|
|
252
|
+
if (validLen === -1) validLen = len
|
|
253
|
+
|
|
254
|
+
var placeHoldersLen = validLen === len
|
|
255
|
+
? 0
|
|
256
|
+
: 4 - (validLen % 4)
|
|
257
|
+
|
|
258
|
+
return [validLen, placeHoldersLen]
|
|
254
259
|
}
|
|
255
260
|
|
|
261
|
+
// base64 is 4/3 + up to two characters of the original data
|
|
256
262
|
function byteLength (b64) {
|
|
257
|
-
|
|
258
|
-
|
|
263
|
+
var lens = getLens(b64)
|
|
264
|
+
var validLen = lens[0]
|
|
265
|
+
var placeHoldersLen = lens[1]
|
|
266
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
270
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
259
271
|
}
|
|
260
272
|
|
|
261
273
|
function toByteArray (b64) {
|
|
262
|
-
var
|
|
263
|
-
var
|
|
264
|
-
|
|
274
|
+
var tmp
|
|
275
|
+
var lens = getLens(b64)
|
|
276
|
+
var validLen = lens[0]
|
|
277
|
+
var placeHoldersLen = lens[1]
|
|
265
278
|
|
|
266
|
-
arr = new Arr((
|
|
279
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
280
|
+
|
|
281
|
+
var curByte = 0
|
|
267
282
|
|
|
268
283
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
269
|
-
|
|
284
|
+
var len = placeHoldersLen > 0
|
|
285
|
+
? validLen - 4
|
|
286
|
+
: validLen
|
|
270
287
|
|
|
271
|
-
var
|
|
288
|
+
var i
|
|
289
|
+
for (i = 0; i < len; i += 4) {
|
|
290
|
+
tmp =
|
|
291
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
292
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
293
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
294
|
+
revLookup[b64.charCodeAt(i + 3)]
|
|
295
|
+
arr[curByte++] = (tmp >> 16) & 0xFF
|
|
296
|
+
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
297
|
+
arr[curByte++] = tmp & 0xFF
|
|
298
|
+
}
|
|
272
299
|
|
|
273
|
-
|
|
274
|
-
tmp =
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
arr[
|
|
300
|
+
if (placeHoldersLen === 2) {
|
|
301
|
+
tmp =
|
|
302
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
303
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
|
304
|
+
arr[curByte++] = tmp & 0xFF
|
|
278
305
|
}
|
|
279
306
|
|
|
280
|
-
if (
|
|
281
|
-
tmp =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
arr[
|
|
286
|
-
arr[
|
|
307
|
+
if (placeHoldersLen === 1) {
|
|
308
|
+
tmp =
|
|
309
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
310
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
311
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
|
312
|
+
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
313
|
+
arr[curByte++] = tmp & 0xFF
|
|
287
314
|
}
|
|
288
315
|
|
|
289
316
|
return arr
|
|
290
317
|
}
|
|
291
318
|
|
|
292
319
|
function tripletToBase64 (num) {
|
|
293
|
-
return lookup[num >> 18 & 0x3F] +
|
|
320
|
+
return lookup[num >> 18 & 0x3F] +
|
|
321
|
+
lookup[num >> 12 & 0x3F] +
|
|
322
|
+
lookup[num >> 6 & 0x3F] +
|
|
323
|
+
lookup[num & 0x3F]
|
|
294
324
|
}
|
|
295
325
|
|
|
296
326
|
function encodeChunk (uint8, start, end) {
|
|
297
327
|
var tmp
|
|
298
328
|
var output = []
|
|
299
329
|
for (var i = start; i < end; i += 3) {
|
|
300
|
-
tmp =
|
|
330
|
+
tmp =
|
|
331
|
+
((uint8[i] << 16) & 0xFF0000) +
|
|
332
|
+
((uint8[i + 1] << 8) & 0xFF00) +
|
|
333
|
+
(uint8[i + 2] & 0xFF)
|
|
301
334
|
output.push(tripletToBase64(tmp))
|
|
302
335
|
}
|
|
303
336
|
return output.join('')
|
|
@@ -307,7 +340,6 @@ function fromByteArray (uint8) {
|
|
|
307
340
|
var tmp
|
|
308
341
|
var len = uint8.length
|
|
309
342
|
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
310
|
-
var output = ''
|
|
311
343
|
var parts = []
|
|
312
344
|
var maxChunkLength = 16383 // must be multiple of 3
|
|
313
345
|
|
|
@@ -319,23 +351,26 @@ function fromByteArray (uint8) {
|
|
|
319
351
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
320
352
|
if (extraBytes === 1) {
|
|
321
353
|
tmp = uint8[len - 1]
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
354
|
+
parts.push(
|
|
355
|
+
lookup[tmp >> 2] +
|
|
356
|
+
lookup[(tmp << 4) & 0x3F] +
|
|
357
|
+
'=='
|
|
358
|
+
)
|
|
325
359
|
} else if (extraBytes === 2) {
|
|
326
|
-
tmp = (uint8[len - 2] << 8) +
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
360
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
|
361
|
+
parts.push(
|
|
362
|
+
lookup[tmp >> 10] +
|
|
363
|
+
lookup[(tmp >> 4) & 0x3F] +
|
|
364
|
+
lookup[(tmp << 2) & 0x3F] +
|
|
365
|
+
'='
|
|
366
|
+
)
|
|
331
367
|
}
|
|
332
368
|
|
|
333
|
-
parts.push(output)
|
|
334
|
-
|
|
335
369
|
return parts.join('')
|
|
336
370
|
}
|
|
337
371
|
|
|
338
372
|
},{}],3:[function(require,module,exports){
|
|
373
|
+
(function (Buffer){(function (){
|
|
339
374
|
/*!
|
|
340
375
|
* The buffer module from node.js, for the browser.
|
|
341
376
|
*
|
|
@@ -384,7 +419,7 @@ function typedArraySupport () {
|
|
|
384
419
|
// Can typed array instances can be augmented?
|
|
385
420
|
try {
|
|
386
421
|
var arr = new Uint8Array(1)
|
|
387
|
-
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
|
422
|
+
arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
|
|
388
423
|
return arr.foo() === 42
|
|
389
424
|
} catch (e) {
|
|
390
425
|
return false
|
|
@@ -392,26 +427,24 @@ function typedArraySupport () {
|
|
|
392
427
|
}
|
|
393
428
|
|
|
394
429
|
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
430
|
+
enumerable: true,
|
|
395
431
|
get: function () {
|
|
396
|
-
if (!(this
|
|
397
|
-
return undefined
|
|
398
|
-
}
|
|
432
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
399
433
|
return this.buffer
|
|
400
434
|
}
|
|
401
435
|
})
|
|
402
436
|
|
|
403
437
|
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
438
|
+
enumerable: true,
|
|
404
439
|
get: function () {
|
|
405
|
-
if (!(this
|
|
406
|
-
return undefined
|
|
407
|
-
}
|
|
440
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
408
441
|
return this.byteOffset
|
|
409
442
|
}
|
|
410
443
|
})
|
|
411
444
|
|
|
412
445
|
function createBuffer (length) {
|
|
413
446
|
if (length > K_MAX_LENGTH) {
|
|
414
|
-
throw new RangeError('
|
|
447
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
415
448
|
}
|
|
416
449
|
// Return an augmented `Uint8Array` instance
|
|
417
450
|
var buf = new Uint8Array(length)
|
|
@@ -433,8 +466,8 @@ function Buffer (arg, encodingOrOffset, length) {
|
|
|
433
466
|
// Common case.
|
|
434
467
|
if (typeof arg === 'number') {
|
|
435
468
|
if (typeof encodingOrOffset === 'string') {
|
|
436
|
-
throw new
|
|
437
|
-
'
|
|
469
|
+
throw new TypeError(
|
|
470
|
+
'The "string" argument must be of type string. Received type number'
|
|
438
471
|
)
|
|
439
472
|
}
|
|
440
473
|
return allocUnsafe(arg)
|
|
@@ -443,7 +476,7 @@ function Buffer (arg, encodingOrOffset, length) {
|
|
|
443
476
|
}
|
|
444
477
|
|
|
445
478
|
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
|
446
|
-
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
479
|
+
if (typeof Symbol !== 'undefined' && Symbol.species != null &&
|
|
447
480
|
Buffer[Symbol.species] === Buffer) {
|
|
448
481
|
Object.defineProperty(Buffer, Symbol.species, {
|
|
449
482
|
value: null,
|
|
@@ -456,19 +489,51 @@ if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
|
456
489
|
Buffer.poolSize = 8192 // not used by this implementation
|
|
457
490
|
|
|
458
491
|
function from (value, encodingOrOffset, length) {
|
|
459
|
-
if (typeof value === '
|
|
460
|
-
|
|
492
|
+
if (typeof value === 'string') {
|
|
493
|
+
return fromString(value, encodingOrOffset)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (ArrayBuffer.isView(value)) {
|
|
497
|
+
return fromArrayLike(value)
|
|
461
498
|
}
|
|
462
499
|
|
|
463
|
-
if (
|
|
500
|
+
if (value == null) {
|
|
501
|
+
throw TypeError(
|
|
502
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
503
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
504
|
+
)
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (isInstance(value, ArrayBuffer) ||
|
|
508
|
+
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
464
509
|
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
465
510
|
}
|
|
466
511
|
|
|
467
|
-
if (typeof value === '
|
|
468
|
-
|
|
512
|
+
if (typeof value === 'number') {
|
|
513
|
+
throw new TypeError(
|
|
514
|
+
'The "value" argument must not be of type number. Received type number'
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
var valueOf = value.valueOf && value.valueOf()
|
|
519
|
+
if (valueOf != null && valueOf !== value) {
|
|
520
|
+
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var b = fromObject(value)
|
|
524
|
+
if (b) return b
|
|
525
|
+
|
|
526
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
527
|
+
typeof value[Symbol.toPrimitive] === 'function') {
|
|
528
|
+
return Buffer.from(
|
|
529
|
+
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
|
|
530
|
+
)
|
|
469
531
|
}
|
|
470
532
|
|
|
471
|
-
|
|
533
|
+
throw new TypeError(
|
|
534
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
535
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
536
|
+
)
|
|
472
537
|
}
|
|
473
538
|
|
|
474
539
|
/**
|
|
@@ -492,7 +557,7 @@ function assertSize (size) {
|
|
|
492
557
|
if (typeof size !== 'number') {
|
|
493
558
|
throw new TypeError('"size" argument must be of type number')
|
|
494
559
|
} else if (size < 0) {
|
|
495
|
-
throw new RangeError('"size"
|
|
560
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
496
561
|
}
|
|
497
562
|
}
|
|
498
563
|
|
|
@@ -607,20 +672,16 @@ function fromObject (obj) {
|
|
|
607
672
|
return buf
|
|
608
673
|
}
|
|
609
674
|
|
|
610
|
-
if (obj) {
|
|
611
|
-
if (
|
|
612
|
-
|
|
613
|
-
return createBuffer(0)
|
|
614
|
-
}
|
|
615
|
-
return fromArrayLike(obj)
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
619
|
-
return fromArrayLike(obj.data)
|
|
675
|
+
if (obj.length !== undefined) {
|
|
676
|
+
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
677
|
+
return createBuffer(0)
|
|
620
678
|
}
|
|
679
|
+
return fromArrayLike(obj)
|
|
621
680
|
}
|
|
622
681
|
|
|
623
|
-
|
|
682
|
+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
683
|
+
return fromArrayLike(obj.data)
|
|
684
|
+
}
|
|
624
685
|
}
|
|
625
686
|
|
|
626
687
|
function checked (length) {
|
|
@@ -641,12 +702,17 @@ function SlowBuffer (length) {
|
|
|
641
702
|
}
|
|
642
703
|
|
|
643
704
|
Buffer.isBuffer = function isBuffer (b) {
|
|
644
|
-
return b != null && b._isBuffer === true
|
|
705
|
+
return b != null && b._isBuffer === true &&
|
|
706
|
+
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
645
707
|
}
|
|
646
708
|
|
|
647
709
|
Buffer.compare = function compare (a, b) {
|
|
710
|
+
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
|
|
711
|
+
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
|
|
648
712
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
649
|
-
throw new TypeError(
|
|
713
|
+
throw new TypeError(
|
|
714
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
715
|
+
)
|
|
650
716
|
}
|
|
651
717
|
|
|
652
718
|
if (a === b) return 0
|
|
@@ -707,7 +773,7 @@ Buffer.concat = function concat (list, length) {
|
|
|
707
773
|
var pos = 0
|
|
708
774
|
for (i = 0; i < list.length; ++i) {
|
|
709
775
|
var buf = list[i]
|
|
710
|
-
if (
|
|
776
|
+
if (isInstance(buf, Uint8Array)) {
|
|
711
777
|
buf = Buffer.from(buf)
|
|
712
778
|
}
|
|
713
779
|
if (!Buffer.isBuffer(buf)) {
|
|
@@ -723,15 +789,19 @@ function byteLength (string, encoding) {
|
|
|
723
789
|
if (Buffer.isBuffer(string)) {
|
|
724
790
|
return string.length
|
|
725
791
|
}
|
|
726
|
-
if (ArrayBuffer.isView(string) ||
|
|
792
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
727
793
|
return string.byteLength
|
|
728
794
|
}
|
|
729
795
|
if (typeof string !== 'string') {
|
|
730
|
-
|
|
796
|
+
throw new TypeError(
|
|
797
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
798
|
+
'Received type ' + typeof string
|
|
799
|
+
)
|
|
731
800
|
}
|
|
732
801
|
|
|
733
802
|
var len = string.length
|
|
734
|
-
|
|
803
|
+
var mustMatch = (arguments.length > 2 && arguments[2] === true)
|
|
804
|
+
if (!mustMatch && len === 0) return 0
|
|
735
805
|
|
|
736
806
|
// Use a for loop to avoid recursion
|
|
737
807
|
var loweredCase = false
|
|
@@ -743,7 +813,6 @@ function byteLength (string, encoding) {
|
|
|
743
813
|
return len
|
|
744
814
|
case 'utf8':
|
|
745
815
|
case 'utf-8':
|
|
746
|
-
case undefined:
|
|
747
816
|
return utf8ToBytes(string).length
|
|
748
817
|
case 'ucs2':
|
|
749
818
|
case 'ucs-2':
|
|
@@ -755,7 +824,9 @@ function byteLength (string, encoding) {
|
|
|
755
824
|
case 'base64':
|
|
756
825
|
return base64ToBytes(string).length
|
|
757
826
|
default:
|
|
758
|
-
if (loweredCase)
|
|
827
|
+
if (loweredCase) {
|
|
828
|
+
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
829
|
+
}
|
|
759
830
|
encoding = ('' + encoding).toLowerCase()
|
|
760
831
|
loweredCase = true
|
|
761
832
|
}
|
|
@@ -902,16 +973,20 @@ Buffer.prototype.equals = function equals (b) {
|
|
|
902
973
|
Buffer.prototype.inspect = function inspect () {
|
|
903
974
|
var str = ''
|
|
904
975
|
var max = exports.INSPECT_MAX_BYTES
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
if (this.length > max) str += ' ... '
|
|
908
|
-
}
|
|
976
|
+
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
|
|
977
|
+
if (this.length > max) str += ' ... '
|
|
909
978
|
return '<Buffer ' + str + '>'
|
|
910
979
|
}
|
|
911
980
|
|
|
912
981
|
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
982
|
+
if (isInstance(target, Uint8Array)) {
|
|
983
|
+
target = Buffer.from(target, target.offset, target.byteLength)
|
|
984
|
+
}
|
|
913
985
|
if (!Buffer.isBuffer(target)) {
|
|
914
|
-
throw new TypeError(
|
|
986
|
+
throw new TypeError(
|
|
987
|
+
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
988
|
+
'Received type ' + (typeof target)
|
|
989
|
+
)
|
|
915
990
|
}
|
|
916
991
|
|
|
917
992
|
if (start === undefined) {
|
|
@@ -990,7 +1065,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
|
990
1065
|
} else if (byteOffset < -0x80000000) {
|
|
991
1066
|
byteOffset = -0x80000000
|
|
992
1067
|
}
|
|
993
|
-
byteOffset = +byteOffset
|
|
1068
|
+
byteOffset = +byteOffset // Coerce to Number.
|
|
994
1069
|
if (numberIsNaN(byteOffset)) {
|
|
995
1070
|
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
996
1071
|
byteOffset = dir ? 0 : (buffer.length - 1)
|
|
@@ -1242,8 +1317,8 @@ function utf8Slice (buf, start, end) {
|
|
|
1242
1317
|
var codePoint = null
|
|
1243
1318
|
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
1244
1319
|
: (firstByte > 0xDF) ? 3
|
|
1245
|
-
|
|
1246
|
-
|
|
1320
|
+
: (firstByte > 0xBF) ? 2
|
|
1321
|
+
: 1
|
|
1247
1322
|
|
|
1248
1323
|
if (i + bytesPerSequence <= end) {
|
|
1249
1324
|
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
@@ -1906,7 +1981,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
|
1906
1981
|
} else {
|
|
1907
1982
|
var bytes = Buffer.isBuffer(val)
|
|
1908
1983
|
? val
|
|
1909
|
-
:
|
|
1984
|
+
: Buffer.from(val, encoding)
|
|
1910
1985
|
var len = bytes.length
|
|
1911
1986
|
if (len === 0) {
|
|
1912
1987
|
throw new TypeError('The value "' + val +
|
|
@@ -2061,19 +2136,22 @@ function blitBuffer (src, dst, offset, length) {
|
|
|
2061
2136
|
return i
|
|
2062
2137
|
}
|
|
2063
2138
|
|
|
2064
|
-
//
|
|
2065
|
-
// but they should be treated as
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2139
|
+
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
2140
|
+
// the `instanceof` check but they should be treated as of that type.
|
|
2141
|
+
// See: https://github.com/feross/buffer/issues/166
|
|
2142
|
+
function isInstance (obj, type) {
|
|
2143
|
+
return obj instanceof type ||
|
|
2144
|
+
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
2145
|
+
obj.constructor.name === type.name)
|
|
2070
2146
|
}
|
|
2071
|
-
|
|
2072
2147
|
function numberIsNaN (obj) {
|
|
2148
|
+
// For IE11 support
|
|
2073
2149
|
return obj !== obj // eslint-disable-line no-self-compare
|
|
2074
2150
|
}
|
|
2075
2151
|
|
|
2076
|
-
},
|
|
2152
|
+
}).call(this)}).call(this,require("buffer").Buffer)
|
|
2153
|
+
},{"base64-js":2,"buffer":3,"ieee754":4}],4:[function(require,module,exports){
|
|
2154
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
2077
2155
|
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
2078
2156
|
var e, m
|
|
2079
2157
|
var eLen = (nBytes * 8) - mLen - 1
|
|
@@ -2160,266 +2238,261 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
2160
2238
|
}
|
|
2161
2239
|
|
|
2162
2240
|
},{}],5:[function(require,module,exports){
|
|
2163
|
-
function DOMParser(options){
|
|
2164
|
-
this.options = options ||{locator:{}};
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
DOMParser.prototype.parseFromString = function(source,mimeType){
|
|
2168
|
-
var options = this.options;
|
|
2169
|
-
var sax = new XMLReader();
|
|
2170
|
-
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
|
2171
|
-
var errorHandler = options.errorHandler;
|
|
2172
|
-
var locator = options.locator;
|
|
2173
|
-
var defaultNSMap = options.xmlns||{};
|
|
2174
|
-
var
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
sax.
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
}
|
|
2201
|
-
var
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
build('
|
|
2214
|
-
build('
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
* +
|
|
2222
|
-
*
|
|
2223
|
-
*
|
|
2224
|
-
*
|
|
2225
|
-
* DefaultHandler
|
|
2226
|
-
*
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
node.
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
* @
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
this.
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
var
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
var
|
|
2257
|
-
var
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
var
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
* @
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
/*
|
|
2365
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
|
2366
|
-
* used method of org.xml.sax.ext.LexicalHandler:
|
|
2367
|
-
* #comment(chars, start, length)
|
|
2368
|
-
* #startCDATA()
|
|
2369
|
-
* #endCDATA()
|
|
2370
|
-
* #startDTD(name, publicId, systemId)
|
|
2371
|
-
*
|
|
2372
|
-
*
|
|
2373
|
-
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
|
2374
|
-
* #endDTD()
|
|
2375
|
-
* #startEntity(name)
|
|
2376
|
-
* #endEntity(name)
|
|
2377
|
-
*
|
|
2378
|
-
*
|
|
2379
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
|
2380
|
-
* IGNORED method of org.xml.sax.ext.DeclHandler
|
|
2381
|
-
* #attributeDecl(eName, aName, type, mode, value)
|
|
2382
|
-
* #elementDecl(name, model)
|
|
2383
|
-
* #externalEntityDecl(name, publicId, systemId)
|
|
2384
|
-
* #internalEntityDecl(name, value)
|
|
2385
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
|
2386
|
-
* IGNORED method of org.xml.sax.EntityResolver2
|
|
2387
|
-
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
|
2388
|
-
* #resolveEntity(publicId, systemId)
|
|
2389
|
-
* #getExternalSubset(name, baseURI)
|
|
2390
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
|
2391
|
-
* IGNORED method of org.xml.sax.DTDHandler
|
|
2392
|
-
* #notationDecl(name, publicId, systemId) {};
|
|
2393
|
-
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
|
2394
|
-
*/
|
|
2395
|
-
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
|
2396
|
-
DOMHandler.prototype[key] = function(){return null}
|
|
2397
|
-
})
|
|
2398
|
-
|
|
2399
|
-
/* 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 */
|
|
2400
|
-
function appendElement (hander,node) {
|
|
2401
|
-
if (!hander.currentElement) {
|
|
2402
|
-
hander.doc.appendChild(node);
|
|
2403
|
-
} else {
|
|
2404
|
-
hander.currentElement.appendChild(node);
|
|
2405
|
-
}
|
|
2406
|
-
}//appendChild and setAttributeNS are preformance key
|
|
2407
|
-
|
|
2408
|
-
//if(typeof require == 'function'){
|
|
2409
|
-
var XMLReader = require('./sax').XMLReader;
|
|
2410
|
-
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
|
|
2411
|
-
exports.XMLSerializer = require('./dom').XMLSerializer ;
|
|
2412
|
-
exports.DOMParser = DOMParser;
|
|
2413
|
-
//}
|
|
2414
|
-
|
|
2415
|
-
},{"./dom":6,"./sax":7}],6:[function(require,module,exports){
|
|
2241
|
+
function DOMParser(options){
|
|
2242
|
+
this.options = options ||{locator:{}};
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
DOMParser.prototype.parseFromString = function(source,mimeType){
|
|
2246
|
+
var options = this.options;
|
|
2247
|
+
var sax = new XMLReader();
|
|
2248
|
+
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
|
2249
|
+
var errorHandler = options.errorHandler;
|
|
2250
|
+
var locator = options.locator;
|
|
2251
|
+
var defaultNSMap = options.xmlns||{};
|
|
2252
|
+
var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
|
|
2253
|
+
var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"};
|
|
2254
|
+
if(locator){
|
|
2255
|
+
domBuilder.setDocumentLocator(locator)
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
|
2259
|
+
sax.domBuilder = options.domBuilder || domBuilder;
|
|
2260
|
+
if(isHTML){
|
|
2261
|
+
defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
|
|
2262
|
+
}
|
|
2263
|
+
defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
|
|
2264
|
+
if(source && typeof source === 'string'){
|
|
2265
|
+
sax.parse(source,defaultNSMap,entityMap);
|
|
2266
|
+
}else{
|
|
2267
|
+
sax.errorHandler.error("invalid doc source");
|
|
2268
|
+
}
|
|
2269
|
+
return domBuilder.doc;
|
|
2270
|
+
}
|
|
2271
|
+
function buildErrorHandler(errorImpl,domBuilder,locator){
|
|
2272
|
+
if(!errorImpl){
|
|
2273
|
+
if(domBuilder instanceof DOMHandler){
|
|
2274
|
+
return domBuilder;
|
|
2275
|
+
}
|
|
2276
|
+
errorImpl = domBuilder ;
|
|
2277
|
+
}
|
|
2278
|
+
var errorHandler = {}
|
|
2279
|
+
var isCallback = errorImpl instanceof Function;
|
|
2280
|
+
locator = locator||{}
|
|
2281
|
+
function build(key){
|
|
2282
|
+
var fn = errorImpl[key];
|
|
2283
|
+
if(!fn && isCallback){
|
|
2284
|
+
fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
|
|
2285
|
+
}
|
|
2286
|
+
errorHandler[key] = fn && function(msg){
|
|
2287
|
+
fn('[xmldom '+key+']\t'+msg+_locator(locator));
|
|
2288
|
+
}||function(){};
|
|
2289
|
+
}
|
|
2290
|
+
build('warning');
|
|
2291
|
+
build('error');
|
|
2292
|
+
build('fatalError');
|
|
2293
|
+
return errorHandler;
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
//console.log('#\n\n\n\n\n\n\n####')
|
|
2297
|
+
/**
|
|
2298
|
+
* +ContentHandler+ErrorHandler
|
|
2299
|
+
* +LexicalHandler+EntityResolver2
|
|
2300
|
+
* -DeclHandler-DTDHandler
|
|
2301
|
+
*
|
|
2302
|
+
* DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
|
|
2303
|
+
* DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
|
|
2304
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
|
|
2305
|
+
*/
|
|
2306
|
+
function DOMHandler() {
|
|
2307
|
+
this.cdata = false;
|
|
2308
|
+
}
|
|
2309
|
+
function position(locator,node){
|
|
2310
|
+
node.lineNumber = locator.lineNumber;
|
|
2311
|
+
node.columnNumber = locator.columnNumber;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* @see org.xml.sax.ContentHandler#startDocument
|
|
2315
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
|
|
2316
|
+
*/
|
|
2317
|
+
DOMHandler.prototype = {
|
|
2318
|
+
startDocument : function() {
|
|
2319
|
+
this.doc = new DOMImplementation().createDocument(null, null, null);
|
|
2320
|
+
if (this.locator) {
|
|
2321
|
+
this.doc.documentURI = this.locator.systemId;
|
|
2322
|
+
}
|
|
2323
|
+
},
|
|
2324
|
+
startElement:function(namespaceURI, localName, qName, attrs) {
|
|
2325
|
+
var doc = this.doc;
|
|
2326
|
+
var el = doc.createElementNS(namespaceURI, qName||localName);
|
|
2327
|
+
var len = attrs.length;
|
|
2328
|
+
appendElement(this, el);
|
|
2329
|
+
this.currentElement = el;
|
|
2330
|
+
|
|
2331
|
+
this.locator && position(this.locator,el)
|
|
2332
|
+
for (var i = 0 ; i < len; i++) {
|
|
2333
|
+
var namespaceURI = attrs.getURI(i);
|
|
2334
|
+
var value = attrs.getValue(i);
|
|
2335
|
+
var qName = attrs.getQName(i);
|
|
2336
|
+
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
2337
|
+
this.locator &&position(attrs.getLocator(i),attr);
|
|
2338
|
+
attr.value = attr.nodeValue = value;
|
|
2339
|
+
el.setAttributeNode(attr)
|
|
2340
|
+
}
|
|
2341
|
+
},
|
|
2342
|
+
endElement:function(namespaceURI, localName, qName) {
|
|
2343
|
+
var current = this.currentElement
|
|
2344
|
+
var tagName = current.tagName;
|
|
2345
|
+
this.currentElement = current.parentNode;
|
|
2346
|
+
},
|
|
2347
|
+
startPrefixMapping:function(prefix, uri) {
|
|
2348
|
+
},
|
|
2349
|
+
endPrefixMapping:function(prefix) {
|
|
2350
|
+
},
|
|
2351
|
+
processingInstruction:function(target, data) {
|
|
2352
|
+
var ins = this.doc.createProcessingInstruction(target, data);
|
|
2353
|
+
this.locator && position(this.locator,ins)
|
|
2354
|
+
appendElement(this, ins);
|
|
2355
|
+
},
|
|
2356
|
+
ignorableWhitespace:function(ch, start, length) {
|
|
2357
|
+
},
|
|
2358
|
+
characters:function(chars, start, length) {
|
|
2359
|
+
chars = _toString.apply(this,arguments)
|
|
2360
|
+
//console.log(chars)
|
|
2361
|
+
if(chars){
|
|
2362
|
+
if (this.cdata) {
|
|
2363
|
+
var charNode = this.doc.createCDATASection(chars);
|
|
2364
|
+
} else {
|
|
2365
|
+
var charNode = this.doc.createTextNode(chars);
|
|
2366
|
+
}
|
|
2367
|
+
if(this.currentElement){
|
|
2368
|
+
this.currentElement.appendChild(charNode);
|
|
2369
|
+
}else if(/^\s*$/.test(chars)){
|
|
2370
|
+
this.doc.appendChild(charNode);
|
|
2371
|
+
//process xml
|
|
2372
|
+
}
|
|
2373
|
+
this.locator && position(this.locator,charNode)
|
|
2374
|
+
}
|
|
2375
|
+
},
|
|
2376
|
+
skippedEntity:function(name) {
|
|
2377
|
+
},
|
|
2378
|
+
endDocument:function() {
|
|
2379
|
+
this.doc.normalize();
|
|
2380
|
+
},
|
|
2381
|
+
setDocumentLocator:function (locator) {
|
|
2382
|
+
if(this.locator = locator){// && !('lineNumber' in locator)){
|
|
2383
|
+
locator.lineNumber = 0;
|
|
2384
|
+
}
|
|
2385
|
+
},
|
|
2386
|
+
//LexicalHandler
|
|
2387
|
+
comment:function(chars, start, length) {
|
|
2388
|
+
chars = _toString.apply(this,arguments)
|
|
2389
|
+
var comm = this.doc.createComment(chars);
|
|
2390
|
+
this.locator && position(this.locator,comm)
|
|
2391
|
+
appendElement(this, comm);
|
|
2392
|
+
},
|
|
2393
|
+
|
|
2394
|
+
startCDATA:function() {
|
|
2395
|
+
//used in characters() methods
|
|
2396
|
+
this.cdata = true;
|
|
2397
|
+
},
|
|
2398
|
+
endCDATA:function() {
|
|
2399
|
+
this.cdata = false;
|
|
2400
|
+
},
|
|
2401
|
+
|
|
2402
|
+
startDTD:function(name, publicId, systemId) {
|
|
2403
|
+
var impl = this.doc.implementation;
|
|
2404
|
+
if (impl && impl.createDocumentType) {
|
|
2405
|
+
var dt = impl.createDocumentType(name, publicId, systemId);
|
|
2406
|
+
this.locator && position(this.locator,dt)
|
|
2407
|
+
appendElement(this, dt);
|
|
2408
|
+
}
|
|
2409
|
+
},
|
|
2410
|
+
/**
|
|
2411
|
+
* @see org.xml.sax.ErrorHandler
|
|
2412
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
|
2413
|
+
*/
|
|
2414
|
+
warning:function(error) {
|
|
2415
|
+
console.warn('[xmldom warning]\t'+error,_locator(this.locator));
|
|
2416
|
+
},
|
|
2417
|
+
error:function(error) {
|
|
2418
|
+
console.error('[xmldom error]\t'+error,_locator(this.locator));
|
|
2419
|
+
},
|
|
2420
|
+
fatalError:function(error) {
|
|
2421
|
+
throw new ParseError(error, this.locator);
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
function _locator(l){
|
|
2425
|
+
if(l){
|
|
2426
|
+
return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
function _toString(chars,start,length){
|
|
2430
|
+
if(typeof chars == 'string'){
|
|
2431
|
+
return chars.substr(start,length)
|
|
2432
|
+
}else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
|
|
2433
|
+
if(chars.length >= start+length || start){
|
|
2434
|
+
return new java.lang.String(chars,start,length)+'';
|
|
2435
|
+
}
|
|
2436
|
+
return chars;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2416
2440
|
/*
|
|
2417
|
-
*
|
|
2418
|
-
*
|
|
2419
|
-
*
|
|
2420
|
-
*
|
|
2441
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
|
2442
|
+
* used method of org.xml.sax.ext.LexicalHandler:
|
|
2443
|
+
* #comment(chars, start, length)
|
|
2444
|
+
* #startCDATA()
|
|
2445
|
+
* #endCDATA()
|
|
2446
|
+
* #startDTD(name, publicId, systemId)
|
|
2447
|
+
*
|
|
2448
|
+
*
|
|
2449
|
+
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
|
2450
|
+
* #endDTD()
|
|
2451
|
+
* #startEntity(name)
|
|
2452
|
+
* #endEntity(name)
|
|
2453
|
+
*
|
|
2454
|
+
*
|
|
2455
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
|
2456
|
+
* IGNORED method of org.xml.sax.ext.DeclHandler
|
|
2457
|
+
* #attributeDecl(eName, aName, type, mode, value)
|
|
2458
|
+
* #elementDecl(name, model)
|
|
2459
|
+
* #externalEntityDecl(name, publicId, systemId)
|
|
2460
|
+
* #internalEntityDecl(name, value)
|
|
2461
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
|
2462
|
+
* IGNORED method of org.xml.sax.EntityResolver2
|
|
2463
|
+
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
|
2464
|
+
* #resolveEntity(publicId, systemId)
|
|
2465
|
+
* #getExternalSubset(name, baseURI)
|
|
2466
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
|
2467
|
+
* IGNORED method of org.xml.sax.DTDHandler
|
|
2468
|
+
* #notationDecl(name, publicId, systemId) {};
|
|
2469
|
+
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
|
2421
2470
|
*/
|
|
2471
|
+
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
|
2472
|
+
DOMHandler.prototype[key] = function(){return null}
|
|
2473
|
+
})
|
|
2422
2474
|
|
|
2475
|
+
/* 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 */
|
|
2476
|
+
function appendElement (hander,node) {
|
|
2477
|
+
if (!hander.currentElement) {
|
|
2478
|
+
hander.doc.appendChild(node);
|
|
2479
|
+
} else {
|
|
2480
|
+
hander.currentElement.appendChild(node);
|
|
2481
|
+
}
|
|
2482
|
+
}//appendChild and setAttributeNS are preformance key
|
|
2483
|
+
|
|
2484
|
+
//if(typeof require == 'function'){
|
|
2485
|
+
var htmlEntity = require('./entities');
|
|
2486
|
+
var sax = require('./sax');
|
|
2487
|
+
var XMLReader = sax.XMLReader;
|
|
2488
|
+
var ParseError = sax.ParseError;
|
|
2489
|
+
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
|
|
2490
|
+
exports.XMLSerializer = require('./dom').XMLSerializer ;
|
|
2491
|
+
exports.DOMParser = DOMParser;
|
|
2492
|
+
exports.__DOMHandler = DOMHandler;
|
|
2493
|
+
//}
|
|
2494
|
+
|
|
2495
|
+
},{"./dom":6,"./entities":7,"./sax":8}],6:[function(require,module,exports){
|
|
2423
2496
|
function copy(src,dest){
|
|
2424
2497
|
for(var p in src){
|
|
2425
2498
|
dest[p] = src[p];
|
|
@@ -2431,10 +2504,6 @@ function copy(src,dest){
|
|
|
2431
2504
|
*/
|
|
2432
2505
|
function _extends(Class,Super){
|
|
2433
2506
|
var pt = Class.prototype;
|
|
2434
|
-
if(Object.create){
|
|
2435
|
-
var ppt = Object.create(Super.prototype)
|
|
2436
|
-
pt.__proto__ = ppt;
|
|
2437
|
-
}
|
|
2438
2507
|
if(!(pt instanceof Super)){
|
|
2439
2508
|
function t(){};
|
|
2440
2509
|
t.prototype = Super.prototype;
|
|
@@ -2485,7 +2554,12 @@ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((Exce
|
|
|
2485
2554
|
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
|
|
2486
2555
|
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
|
|
2487
2556
|
|
|
2488
|
-
|
|
2557
|
+
/**
|
|
2558
|
+
* DOM Level 2
|
|
2559
|
+
* Object DOMException
|
|
2560
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
|
|
2561
|
+
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
|
|
2562
|
+
*/
|
|
2489
2563
|
function DOMException(code, message) {
|
|
2490
2564
|
if(message instanceof Error){
|
|
2491
2565
|
var error = message;
|
|
@@ -3027,6 +3101,21 @@ Document.prototype = {
|
|
|
3027
3101
|
return rtv;
|
|
3028
3102
|
},
|
|
3029
3103
|
|
|
3104
|
+
getElementsByClassName: function(className) {
|
|
3105
|
+
var pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
|
|
3106
|
+
return new LiveNodeList(this, function(base) {
|
|
3107
|
+
var ls = [];
|
|
3108
|
+
_visitNode(base.documentElement, function(node) {
|
|
3109
|
+
if(node !== base && node.nodeType == ELEMENT_NODE) {
|
|
3110
|
+
if(pattern.test(node.getAttribute('class'))) {
|
|
3111
|
+
ls.push(node);
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
});
|
|
3115
|
+
return ls;
|
|
3116
|
+
});
|
|
3117
|
+
},
|
|
3118
|
+
|
|
3030
3119
|
//document factory method:
|
|
3031
3120
|
createElement : function(tagName){
|
|
3032
3121
|
var node = new Element();
|
|
@@ -3331,7 +3420,7 @@ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
|
|
|
3331
3420
|
Node.prototype.toString = nodeSerializeToString;
|
|
3332
3421
|
function nodeSerializeToString(isHtml,nodeFilter){
|
|
3333
3422
|
var buf = [];
|
|
3334
|
-
var refNode = this.nodeType == 9
|
|
3423
|
+
var refNode = this.nodeType == 9 && this.documentElement || this;
|
|
3335
3424
|
var prefix = refNode.prefix;
|
|
3336
3425
|
var uri = refNode.namespaceURI;
|
|
3337
3426
|
|
|
@@ -3470,9 +3559,27 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
|
3470
3559
|
}
|
|
3471
3560
|
return;
|
|
3472
3561
|
case ATTRIBUTE_NODE:
|
|
3473
|
-
return buf.push(' ',node.name,'="',node.value.replace(/[
|
|
3562
|
+
return buf.push(' ',node.name,'="',node.value.replace(/[&"]/g,_xmlEncoder),'"');
|
|
3474
3563
|
case TEXT_NODE:
|
|
3475
|
-
|
|
3564
|
+
/**
|
|
3565
|
+
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
3566
|
+
* except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
|
|
3567
|
+
* If they are needed elsewhere, they must be escaped using either numeric character references or the strings
|
|
3568
|
+
* `&` and `<` respectively.
|
|
3569
|
+
* The right angle bracket (>) may be represented using the string " > ", and must, for compatibility,
|
|
3570
|
+
* be escaped using either `>` or a character reference when it appears in the string `]]>` in content,
|
|
3571
|
+
* when that string is not marking the end of a CDATA section.
|
|
3572
|
+
*
|
|
3573
|
+
* In the content of elements, character data is any string of characters
|
|
3574
|
+
* which does not contain the start-delimiter of any markup
|
|
3575
|
+
* and does not include the CDATA-section-close delimiter, `]]>`.
|
|
3576
|
+
*
|
|
3577
|
+
* @see https://www.w3.org/TR/xml/#NT-CharData
|
|
3578
|
+
*/
|
|
3579
|
+
return buf.push(node.data
|
|
3580
|
+
.replace(/[<&]/g,_xmlEncoder)
|
|
3581
|
+
.replace(/]]>/g, ']]>')
|
|
3582
|
+
);
|
|
3476
3583
|
case CDATA_SECTION_NODE:
|
|
3477
3584
|
return buf.push( '<![CDATA[',node.data,']]>');
|
|
3478
3585
|
case COMMENT_NODE:
|
|
@@ -3482,13 +3589,13 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
|
3482
3589
|
var sysid = node.systemId;
|
|
3483
3590
|
buf.push('<!DOCTYPE ',node.name);
|
|
3484
3591
|
if(pubid){
|
|
3485
|
-
buf.push(' PUBLIC
|
|
3592
|
+
buf.push(' PUBLIC ', pubid);
|
|
3486
3593
|
if (sysid && sysid!='.') {
|
|
3487
|
-
buf.push(
|
|
3594
|
+
buf.push(' ', sysid);
|
|
3488
3595
|
}
|
|
3489
|
-
buf.push('
|
|
3596
|
+
buf.push('>');
|
|
3490
3597
|
}else if(sysid && sysid!='.'){
|
|
3491
|
-
buf.push(' SYSTEM
|
|
3598
|
+
buf.push(' SYSTEM ', sysid, '>');
|
|
3492
3599
|
}else{
|
|
3493
3600
|
var sub = node.internalSubset;
|
|
3494
3601
|
if(sub){
|
|
@@ -3654,644 +3761,904 @@ try{
|
|
|
3654
3761
|
}
|
|
3655
3762
|
|
|
3656
3763
|
//if(typeof require == 'function'){
|
|
3764
|
+
exports.Node = Node;
|
|
3765
|
+
exports.DOMException = DOMException;
|
|
3657
3766
|
exports.DOMImplementation = DOMImplementation;
|
|
3658
3767
|
exports.XMLSerializer = XMLSerializer;
|
|
3659
3768
|
//}
|
|
3660
3769
|
|
|
3661
3770
|
},{}],7:[function(require,module,exports){
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
}
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
var
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
}
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
}
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
//
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
3771
|
+
exports.entityMap = {
|
|
3772
|
+
lt: '<',
|
|
3773
|
+
gt: '>',
|
|
3774
|
+
amp: '&',
|
|
3775
|
+
quot: '"',
|
|
3776
|
+
apos: "'",
|
|
3777
|
+
Agrave: "À",
|
|
3778
|
+
Aacute: "Á",
|
|
3779
|
+
Acirc: "Â",
|
|
3780
|
+
Atilde: "Ã",
|
|
3781
|
+
Auml: "Ä",
|
|
3782
|
+
Aring: "Å",
|
|
3783
|
+
AElig: "Æ",
|
|
3784
|
+
Ccedil: "Ç",
|
|
3785
|
+
Egrave: "È",
|
|
3786
|
+
Eacute: "É",
|
|
3787
|
+
Ecirc: "Ê",
|
|
3788
|
+
Euml: "Ë",
|
|
3789
|
+
Igrave: "Ì",
|
|
3790
|
+
Iacute: "Í",
|
|
3791
|
+
Icirc: "Î",
|
|
3792
|
+
Iuml: "Ï",
|
|
3793
|
+
ETH: "Ð",
|
|
3794
|
+
Ntilde: "Ñ",
|
|
3795
|
+
Ograve: "Ò",
|
|
3796
|
+
Oacute: "Ó",
|
|
3797
|
+
Ocirc: "Ô",
|
|
3798
|
+
Otilde: "Õ",
|
|
3799
|
+
Ouml: "Ö",
|
|
3800
|
+
Oslash: "Ø",
|
|
3801
|
+
Ugrave: "Ù",
|
|
3802
|
+
Uacute: "Ú",
|
|
3803
|
+
Ucirc: "Û",
|
|
3804
|
+
Uuml: "Ü",
|
|
3805
|
+
Yacute: "Ý",
|
|
3806
|
+
THORN: "Þ",
|
|
3807
|
+
szlig: "ß",
|
|
3808
|
+
agrave: "à",
|
|
3809
|
+
aacute: "á",
|
|
3810
|
+
acirc: "â",
|
|
3811
|
+
atilde: "ã",
|
|
3812
|
+
auml: "ä",
|
|
3813
|
+
aring: "å",
|
|
3814
|
+
aelig: "æ",
|
|
3815
|
+
ccedil: "ç",
|
|
3816
|
+
egrave: "è",
|
|
3817
|
+
eacute: "é",
|
|
3818
|
+
ecirc: "ê",
|
|
3819
|
+
euml: "ë",
|
|
3820
|
+
igrave: "ì",
|
|
3821
|
+
iacute: "í",
|
|
3822
|
+
icirc: "î",
|
|
3823
|
+
iuml: "ï",
|
|
3824
|
+
eth: "ð",
|
|
3825
|
+
ntilde: "ñ",
|
|
3826
|
+
ograve: "ò",
|
|
3827
|
+
oacute: "ó",
|
|
3828
|
+
ocirc: "ô",
|
|
3829
|
+
otilde: "õ",
|
|
3830
|
+
ouml: "ö",
|
|
3831
|
+
oslash: "ø",
|
|
3832
|
+
ugrave: "ù",
|
|
3833
|
+
uacute: "ú",
|
|
3834
|
+
ucirc: "û",
|
|
3835
|
+
uuml: "ü",
|
|
3836
|
+
yacute: "ý",
|
|
3837
|
+
thorn: "þ",
|
|
3838
|
+
yuml: "ÿ",
|
|
3839
|
+
nbsp: "\u00a0",
|
|
3840
|
+
iexcl: "¡",
|
|
3841
|
+
cent: "¢",
|
|
3842
|
+
pound: "£",
|
|
3843
|
+
curren: "¤",
|
|
3844
|
+
yen: "¥",
|
|
3845
|
+
brvbar: "¦",
|
|
3846
|
+
sect: "§",
|
|
3847
|
+
uml: "¨",
|
|
3848
|
+
copy: "©",
|
|
3849
|
+
ordf: "ª",
|
|
3850
|
+
laquo: "«",
|
|
3851
|
+
not: "¬",
|
|
3852
|
+
shy: "",
|
|
3853
|
+
reg: "®",
|
|
3854
|
+
macr: "¯",
|
|
3855
|
+
deg: "°",
|
|
3856
|
+
plusmn: "±",
|
|
3857
|
+
sup2: "²",
|
|
3858
|
+
sup3: "³",
|
|
3859
|
+
acute: "´",
|
|
3860
|
+
micro: "µ",
|
|
3861
|
+
para: "¶",
|
|
3862
|
+
middot: "·",
|
|
3863
|
+
cedil: "¸",
|
|
3864
|
+
sup1: "¹",
|
|
3865
|
+
ordm: "º",
|
|
3866
|
+
raquo: "»",
|
|
3867
|
+
frac14: "¼",
|
|
3868
|
+
frac12: "½",
|
|
3869
|
+
frac34: "¾",
|
|
3870
|
+
iquest: "¿",
|
|
3871
|
+
times: "×",
|
|
3872
|
+
divide: "÷",
|
|
3873
|
+
forall: "∀",
|
|
3874
|
+
part: "∂",
|
|
3875
|
+
exist: "∃",
|
|
3876
|
+
empty: "∅",
|
|
3877
|
+
nabla: "∇",
|
|
3878
|
+
isin: "∈",
|
|
3879
|
+
notin: "∉",
|
|
3880
|
+
ni: "∋",
|
|
3881
|
+
prod: "∏",
|
|
3882
|
+
sum: "∑",
|
|
3883
|
+
minus: "−",
|
|
3884
|
+
lowast: "∗",
|
|
3885
|
+
radic: "√",
|
|
3886
|
+
prop: "∝",
|
|
3887
|
+
infin: "∞",
|
|
3888
|
+
ang: "∠",
|
|
3889
|
+
and: "∧",
|
|
3890
|
+
or: "∨",
|
|
3891
|
+
cap: "∩",
|
|
3892
|
+
cup: "∪",
|
|
3893
|
+
'int': "∫",
|
|
3894
|
+
there4: "∴",
|
|
3895
|
+
sim: "∼",
|
|
3896
|
+
cong: "≅",
|
|
3897
|
+
asymp: "≈",
|
|
3898
|
+
ne: "≠",
|
|
3899
|
+
equiv: "≡",
|
|
3900
|
+
le: "≤",
|
|
3901
|
+
ge: "≥",
|
|
3902
|
+
sub: "⊂",
|
|
3903
|
+
sup: "⊃",
|
|
3904
|
+
nsub: "⊄",
|
|
3905
|
+
sube: "⊆",
|
|
3906
|
+
supe: "⊇",
|
|
3907
|
+
oplus: "⊕",
|
|
3908
|
+
otimes: "⊗",
|
|
3909
|
+
perp: "⊥",
|
|
3910
|
+
sdot: "⋅",
|
|
3911
|
+
Alpha: "Α",
|
|
3912
|
+
Beta: "Β",
|
|
3913
|
+
Gamma: "Γ",
|
|
3914
|
+
Delta: "Δ",
|
|
3915
|
+
Epsilon: "Ε",
|
|
3916
|
+
Zeta: "Ζ",
|
|
3917
|
+
Eta: "Η",
|
|
3918
|
+
Theta: "Θ",
|
|
3919
|
+
Iota: "Ι",
|
|
3920
|
+
Kappa: "Κ",
|
|
3921
|
+
Lambda: "Λ",
|
|
3922
|
+
Mu: "Μ",
|
|
3923
|
+
Nu: "Ν",
|
|
3924
|
+
Xi: "Ξ",
|
|
3925
|
+
Omicron: "Ο",
|
|
3926
|
+
Pi: "Π",
|
|
3927
|
+
Rho: "Ρ",
|
|
3928
|
+
Sigma: "Σ",
|
|
3929
|
+
Tau: "Τ",
|
|
3930
|
+
Upsilon: "Υ",
|
|
3931
|
+
Phi: "Φ",
|
|
3932
|
+
Chi: "Χ",
|
|
3933
|
+
Psi: "Ψ",
|
|
3934
|
+
Omega: "Ω",
|
|
3935
|
+
alpha: "α",
|
|
3936
|
+
beta: "β",
|
|
3937
|
+
gamma: "γ",
|
|
3938
|
+
delta: "δ",
|
|
3939
|
+
epsilon: "ε",
|
|
3940
|
+
zeta: "ζ",
|
|
3941
|
+
eta: "η",
|
|
3942
|
+
theta: "θ",
|
|
3943
|
+
iota: "ι",
|
|
3944
|
+
kappa: "κ",
|
|
3945
|
+
lambda: "λ",
|
|
3946
|
+
mu: "μ",
|
|
3947
|
+
nu: "ν",
|
|
3948
|
+
xi: "ξ",
|
|
3949
|
+
omicron: "ο",
|
|
3950
|
+
pi: "π",
|
|
3951
|
+
rho: "ρ",
|
|
3952
|
+
sigmaf: "ς",
|
|
3953
|
+
sigma: "σ",
|
|
3954
|
+
tau: "τ",
|
|
3955
|
+
upsilon: "υ",
|
|
3956
|
+
phi: "φ",
|
|
3957
|
+
chi: "χ",
|
|
3958
|
+
psi: "ψ",
|
|
3959
|
+
omega: "ω",
|
|
3960
|
+
thetasym: "ϑ",
|
|
3961
|
+
upsih: "ϒ",
|
|
3962
|
+
piv: "ϖ",
|
|
3963
|
+
OElig: "Œ",
|
|
3964
|
+
oelig: "œ",
|
|
3965
|
+
Scaron: "Š",
|
|
3966
|
+
scaron: "š",
|
|
3967
|
+
Yuml: "Ÿ",
|
|
3968
|
+
fnof: "ƒ",
|
|
3969
|
+
circ: "ˆ",
|
|
3970
|
+
tilde: "˜",
|
|
3971
|
+
ensp: " ",
|
|
3972
|
+
emsp: " ",
|
|
3973
|
+
thinsp: " ",
|
|
3974
|
+
zwnj: "",
|
|
3975
|
+
zwj: "",
|
|
3976
|
+
lrm: "",
|
|
3977
|
+
rlm: "",
|
|
3978
|
+
ndash: "–",
|
|
3979
|
+
mdash: "—",
|
|
3980
|
+
lsquo: "‘",
|
|
3981
|
+
rsquo: "’",
|
|
3982
|
+
sbquo: "‚",
|
|
3983
|
+
ldquo: "“",
|
|
3984
|
+
rdquo: "”",
|
|
3985
|
+
bdquo: "„",
|
|
3986
|
+
dagger: "†",
|
|
3987
|
+
Dagger: "‡",
|
|
3988
|
+
bull: "•",
|
|
3989
|
+
hellip: "…",
|
|
3990
|
+
permil: "‰",
|
|
3991
|
+
prime: "′",
|
|
3992
|
+
Prime: "″",
|
|
3993
|
+
lsaquo: "‹",
|
|
3994
|
+
rsaquo: "›",
|
|
3995
|
+
oline: "‾",
|
|
3996
|
+
euro: "€",
|
|
3997
|
+
trade: "™",
|
|
3998
|
+
larr: "←",
|
|
3999
|
+
uarr: "↑",
|
|
4000
|
+
rarr: "→",
|
|
4001
|
+
darr: "↓",
|
|
4002
|
+
harr: "↔",
|
|
4003
|
+
crarr: "↵",
|
|
4004
|
+
lceil: "⌈",
|
|
4005
|
+
rceil: "⌉",
|
|
4006
|
+
lfloor: "⌊",
|
|
4007
|
+
rfloor: "⌋",
|
|
4008
|
+
loz: "◊",
|
|
4009
|
+
spades: "♠",
|
|
4010
|
+
clubs: "♣",
|
|
4011
|
+
hearts: "♥",
|
|
4012
|
+
diams: "♦"
|
|
4013
|
+
};
|
|
4014
|
+
|
|
4015
|
+
},{}],8:[function(require,module,exports){
|
|
4016
|
+
//[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]
|
|
4017
|
+
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
4018
|
+
//[5] Name ::= NameStartChar (NameChar)*
|
|
4019
|
+
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
|
|
4020
|
+
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
|
4021
|
+
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
|
|
4022
|
+
//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
|
|
4023
|
+
//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(',')
|
|
4024
|
+
|
|
4025
|
+
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
|
4026
|
+
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
|
4027
|
+
var S_TAG = 0;//tag name offerring
|
|
4028
|
+
var S_ATTR = 1;//attr name offerring
|
|
4029
|
+
var S_ATTR_SPACE=2;//attr name end and space offer
|
|
4030
|
+
var S_EQ = 3;//=space?
|
|
4031
|
+
var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
|
|
4032
|
+
var S_ATTR_END = 5;//attr value end and no space(quot end)
|
|
4033
|
+
var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
|
|
4034
|
+
var S_TAG_CLOSE = 7;//closed el<el />
|
|
4035
|
+
|
|
4036
|
+
/**
|
|
4037
|
+
* Creates an error that will not be caught by XMLReader aka the SAX parser.
|
|
4038
|
+
*
|
|
4039
|
+
* @param {string} message
|
|
4040
|
+
* @param {any?} locator Optional, can provide details about the location in the source
|
|
4041
|
+
* @constructor
|
|
4042
|
+
*/
|
|
4043
|
+
function ParseError(message, locator) {
|
|
4044
|
+
this.message = message
|
|
4045
|
+
this.locator = locator
|
|
4046
|
+
if(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
|
|
4047
|
+
}
|
|
4048
|
+
ParseError.prototype = new Error();
|
|
4049
|
+
ParseError.prototype.name = ParseError.name
|
|
4050
|
+
|
|
4051
|
+
function XMLReader(){
|
|
4052
|
+
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
XMLReader.prototype = {
|
|
4056
|
+
parse:function(source,defaultNSMap,entityMap){
|
|
4057
|
+
var domBuilder = this.domBuilder;
|
|
4058
|
+
domBuilder.startDocument();
|
|
4059
|
+
_copy(defaultNSMap ,defaultNSMap = {})
|
|
4060
|
+
parse(source,defaultNSMap,entityMap,
|
|
4061
|
+
domBuilder,this.errorHandler);
|
|
4062
|
+
domBuilder.endDocument();
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
|
|
4066
|
+
function fixedFromCharCode(code) {
|
|
4067
|
+
// String.prototype.fromCharCode does not supports
|
|
4068
|
+
// > 2 bytes unicode chars directly
|
|
4069
|
+
if (code > 0xffff) {
|
|
4070
|
+
code -= 0x10000;
|
|
4071
|
+
var surrogate1 = 0xd800 + (code >> 10)
|
|
4072
|
+
, surrogate2 = 0xdc00 + (code & 0x3ff);
|
|
4073
|
+
|
|
4074
|
+
return String.fromCharCode(surrogate1, surrogate2);
|
|
4075
|
+
} else {
|
|
4076
|
+
return String.fromCharCode(code);
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
function entityReplacer(a){
|
|
4080
|
+
var k = a.slice(1,-1);
|
|
4081
|
+
if(k in entityMap){
|
|
4082
|
+
return entityMap[k];
|
|
4083
|
+
}else if(k.charAt(0) === '#'){
|
|
4084
|
+
return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
|
|
4085
|
+
}else{
|
|
4086
|
+
errorHandler.error('entity not found:'+a);
|
|
4087
|
+
return a;
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
function appendText(end){//has some bugs
|
|
4091
|
+
if(end>start){
|
|
4092
|
+
var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
|
|
4093
|
+
locator&&position(start);
|
|
4094
|
+
domBuilder.characters(xt,0,end-start);
|
|
4095
|
+
start = end
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
function position(p,m){
|
|
4099
|
+
while(p>=lineEnd && (m = linePattern.exec(source))){
|
|
4100
|
+
lineStart = m.index;
|
|
4101
|
+
lineEnd = lineStart + m[0].length;
|
|
4102
|
+
locator.lineNumber++;
|
|
4103
|
+
//console.log('line++:',locator,startPos,endPos)
|
|
4104
|
+
}
|
|
4105
|
+
locator.columnNumber = p-lineStart+1;
|
|
4106
|
+
}
|
|
4107
|
+
var lineStart = 0;
|
|
4108
|
+
var lineEnd = 0;
|
|
4109
|
+
var linePattern = /.*(?:\r\n?|\n)|.*$/g
|
|
4110
|
+
var locator = domBuilder.locator;
|
|
4111
|
+
|
|
4112
|
+
var parseStack = [{currentNSMap:defaultNSMapCopy}]
|
|
4113
|
+
var closeMap = {};
|
|
4114
|
+
var start = 0;
|
|
4115
|
+
while(true){
|
|
4116
|
+
try{
|
|
4117
|
+
var tagStart = source.indexOf('<',start);
|
|
4118
|
+
if(tagStart<0){
|
|
4119
|
+
if(!source.substr(start).match(/^\s*$/)){
|
|
4120
|
+
var doc = domBuilder.doc;
|
|
4121
|
+
var text = doc.createTextNode(source.substr(start));
|
|
4122
|
+
doc.appendChild(text);
|
|
4123
|
+
domBuilder.currentElement = text;
|
|
4124
|
+
}
|
|
4125
|
+
return;
|
|
4126
|
+
}
|
|
4127
|
+
if(tagStart>start){
|
|
4128
|
+
appendText(tagStart);
|
|
4129
|
+
}
|
|
4130
|
+
switch(source.charAt(tagStart+1)){
|
|
4131
|
+
case '/':
|
|
4132
|
+
var end = source.indexOf('>',tagStart+3);
|
|
4133
|
+
var tagName = source.substring(tagStart+2,end);
|
|
4134
|
+
var config = parseStack.pop();
|
|
4135
|
+
if(end<0){
|
|
4136
|
+
|
|
4137
|
+
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
|
|
4138
|
+
//console.error('#@@@@@@'+tagName)
|
|
4139
|
+
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
|
|
4140
|
+
end = tagStart+1+tagName.length;
|
|
4141
|
+
}else if(tagName.match(/\s</)){
|
|
4142
|
+
tagName = tagName.replace(/[\s<].*/,'');
|
|
4143
|
+
errorHandler.error("end tag name: "+tagName+' maybe not complete');
|
|
4144
|
+
end = tagStart+1+tagName.length;
|
|
4145
|
+
}
|
|
4146
|
+
//console.error(parseStack.length,parseStack)
|
|
4147
|
+
//console.error(config);
|
|
4148
|
+
var localNSMap = config.localNSMap;
|
|
4149
|
+
var endMatch = config.tagName == tagName;
|
|
4150
|
+
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
|
|
4151
|
+
if(endIgnoreCaseMach){
|
|
4152
|
+
domBuilder.endElement(config.uri,config.localName,tagName);
|
|
4153
|
+
if(localNSMap){
|
|
4154
|
+
for(var prefix in localNSMap){
|
|
4155
|
+
domBuilder.endPrefixMapping(prefix) ;
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
if(!endMatch){
|
|
4159
|
+
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case
|
|
4160
|
+
}
|
|
4161
|
+
}else{
|
|
4162
|
+
parseStack.push(config)
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
end++;
|
|
4166
|
+
break;
|
|
4167
|
+
// end elment
|
|
4168
|
+
case '?':// <?...?>
|
|
4169
|
+
locator&&position(tagStart);
|
|
4170
|
+
end = parseInstruction(source,tagStart,domBuilder);
|
|
4171
|
+
break;
|
|
4172
|
+
case '!':// <!doctype,<![CDATA,<!--
|
|
4173
|
+
locator&&position(tagStart);
|
|
4174
|
+
end = parseDCC(source,tagStart,domBuilder,errorHandler);
|
|
4175
|
+
break;
|
|
4176
|
+
default:
|
|
4177
|
+
locator&&position(tagStart);
|
|
4178
|
+
var el = new ElementAttributes();
|
|
4179
|
+
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
|
4180
|
+
//elStartEnd
|
|
4181
|
+
var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
|
|
4182
|
+
var len = el.length;
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
|
|
4186
|
+
el.closed = true;
|
|
4187
|
+
if(!entityMap.nbsp){
|
|
4188
|
+
errorHandler.warning('unclosed xml attribute');
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
if(locator && len){
|
|
4192
|
+
var locator2 = copyLocator(locator,{});
|
|
4193
|
+
//try{//attribute position fixed
|
|
4194
|
+
for(var i = 0;i<len;i++){
|
|
4195
|
+
var a = el[i];
|
|
4196
|
+
position(a.offset);
|
|
4197
|
+
a.locator = copyLocator(locator,{});
|
|
4198
|
+
}
|
|
4199
|
+
//}catch(e){console.error('@@@@@'+e)}
|
|
4200
|
+
domBuilder.locator = locator2
|
|
4201
|
+
if(appendElement(el,domBuilder,currentNSMap)){
|
|
4202
|
+
parseStack.push(el)
|
|
4203
|
+
}
|
|
4204
|
+
domBuilder.locator = locator;
|
|
4205
|
+
}else{
|
|
4206
|
+
if(appendElement(el,domBuilder,currentNSMap)){
|
|
4207
|
+
parseStack.push(el)
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
|
|
4212
|
+
|
|
4213
|
+
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
|
|
4214
|
+
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
|
|
4215
|
+
}else{
|
|
4216
|
+
end++;
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
}catch(e){
|
|
4220
|
+
if (e instanceof ParseError) {
|
|
4221
|
+
throw e;
|
|
4222
|
+
}
|
|
4223
|
+
errorHandler.error('element parse error: '+e)
|
|
4224
|
+
end = -1;
|
|
4225
|
+
}
|
|
4226
|
+
if(end>start){
|
|
4227
|
+
start = end;
|
|
4228
|
+
}else{
|
|
4229
|
+
//TODO: 这里有可能sax回退,有位置错误风险
|
|
4230
|
+
appendText(Math.max(tagStart,start)+1);
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
function copyLocator(f,t){
|
|
4235
|
+
t.lineNumber = f.lineNumber;
|
|
4236
|
+
t.columnNumber = f.columnNumber;
|
|
4237
|
+
return t;
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4240
|
+
/**
|
|
4241
|
+
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
|
|
4242
|
+
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
|
|
4243
|
+
*/
|
|
4244
|
+
function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
|
|
4245
|
+
|
|
4246
|
+
/**
|
|
4247
|
+
* @param {string} qname
|
|
4248
|
+
* @param {string} value
|
|
4249
|
+
* @param {number} startIndex
|
|
4250
|
+
*/
|
|
4251
|
+
function addAttribute(qname, value, startIndex) {
|
|
4252
|
+
if (qname in el.attributeNames) errorHandler.fatalError('Attribute ' + qname + ' redefined')
|
|
4253
|
+
el.addValue(qname, value, startIndex)
|
|
4254
|
+
}
|
|
4255
|
+
var attrName;
|
|
4256
|
+
var value;
|
|
4257
|
+
var p = ++start;
|
|
4258
|
+
var s = S_TAG;//status
|
|
4259
|
+
while(true){
|
|
4260
|
+
var c = source.charAt(p);
|
|
4261
|
+
switch(c){
|
|
4262
|
+
case '=':
|
|
4263
|
+
if(s === S_ATTR){//attrName
|
|
4264
|
+
attrName = source.slice(start,p);
|
|
4265
|
+
s = S_EQ;
|
|
4266
|
+
}else if(s === S_ATTR_SPACE){
|
|
4267
|
+
s = S_EQ;
|
|
4268
|
+
}else{
|
|
4269
|
+
//fatalError: equal must after attrName or space after attrName
|
|
4270
|
+
throw new Error('attribute equal must after attrName'); // No known test case
|
|
4271
|
+
}
|
|
4272
|
+
break;
|
|
4273
|
+
case '\'':
|
|
4274
|
+
case '"':
|
|
4275
|
+
if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
|
|
4276
|
+
){//equal
|
|
4277
|
+
if(s === S_ATTR){
|
|
4278
|
+
errorHandler.warning('attribute value must after "="')
|
|
4279
|
+
attrName = source.slice(start,p)
|
|
4280
|
+
}
|
|
4281
|
+
start = p+1;
|
|
4282
|
+
p = source.indexOf(c,start)
|
|
4283
|
+
if(p>0){
|
|
4284
|
+
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
|
4285
|
+
addAttribute(attrName, value, start-1);
|
|
4286
|
+
s = S_ATTR_END;
|
|
4287
|
+
}else{
|
|
4288
|
+
//fatalError: no end quot match
|
|
4289
|
+
throw new Error('attribute value no end \''+c+'\' match');
|
|
4290
|
+
}
|
|
4291
|
+
}else if(s == S_ATTR_NOQUOT_VALUE){
|
|
4292
|
+
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
|
4293
|
+
//console.log(attrName,value,start,p)
|
|
4294
|
+
addAttribute(attrName, value, start);
|
|
4295
|
+
//console.dir(el)
|
|
4296
|
+
errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
|
|
4297
|
+
start = p+1;
|
|
4298
|
+
s = S_ATTR_END
|
|
4299
|
+
}else{
|
|
4300
|
+
//fatalError: no equal before
|
|
4301
|
+
throw new Error('attribute value must after "="'); // No known test case
|
|
4302
|
+
}
|
|
4303
|
+
break;
|
|
4304
|
+
case '/':
|
|
4305
|
+
switch(s){
|
|
4306
|
+
case S_TAG:
|
|
4307
|
+
el.setTagName(source.slice(start,p));
|
|
4308
|
+
case S_ATTR_END:
|
|
4309
|
+
case S_TAG_SPACE:
|
|
4310
|
+
case S_TAG_CLOSE:
|
|
4311
|
+
s =S_TAG_CLOSE;
|
|
4312
|
+
el.closed = true;
|
|
4313
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
4314
|
+
case S_ATTR:
|
|
4315
|
+
case S_ATTR_SPACE:
|
|
4316
|
+
break;
|
|
4317
|
+
//case S_EQ:
|
|
4318
|
+
default:
|
|
4319
|
+
throw new Error("attribute invalid close char('/')") // No known test case
|
|
4320
|
+
}
|
|
4321
|
+
break;
|
|
4322
|
+
case ''://end document
|
|
4323
|
+
errorHandler.error('unexpected end of input');
|
|
4324
|
+
if(s == S_TAG){
|
|
4325
|
+
el.setTagName(source.slice(start,p));
|
|
4326
|
+
}
|
|
4327
|
+
return p;
|
|
4328
|
+
case '>':
|
|
4329
|
+
switch(s){
|
|
4330
|
+
case S_TAG:
|
|
4331
|
+
el.setTagName(source.slice(start,p));
|
|
4332
|
+
case S_ATTR_END:
|
|
4333
|
+
case S_TAG_SPACE:
|
|
4334
|
+
case S_TAG_CLOSE:
|
|
4335
|
+
break;//normal
|
|
4336
|
+
case S_ATTR_NOQUOT_VALUE://Compatible state
|
|
4337
|
+
case S_ATTR:
|
|
4338
|
+
value = source.slice(start,p);
|
|
4339
|
+
if(value.slice(-1) === '/'){
|
|
4340
|
+
el.closed = true;
|
|
4341
|
+
value = value.slice(0,-1)
|
|
4342
|
+
}
|
|
4343
|
+
case S_ATTR_SPACE:
|
|
4344
|
+
if(s === S_ATTR_SPACE){
|
|
4345
|
+
value = attrName;
|
|
4346
|
+
}
|
|
4347
|
+
if(s == S_ATTR_NOQUOT_VALUE){
|
|
4348
|
+
errorHandler.warning('attribute "'+value+'" missed quot(")!');
|
|
4349
|
+
addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start)
|
|
4350
|
+
}else{
|
|
4351
|
+
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
|
|
4352
|
+
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
|
|
4353
|
+
}
|
|
4354
|
+
addAttribute(value, value, start)
|
|
4355
|
+
}
|
|
4356
|
+
break;
|
|
4357
|
+
case S_EQ:
|
|
4358
|
+
throw new Error('attribute value missed!!');
|
|
4359
|
+
}
|
|
4360
|
+
// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
|
|
4361
|
+
return p;
|
|
4362
|
+
/*xml space '\x20' | #x9 | #xD | #xA; */
|
|
4363
|
+
case '\u0080':
|
|
4364
|
+
c = ' ';
|
|
4365
|
+
default:
|
|
4366
|
+
if(c<= ' '){//space
|
|
4367
|
+
switch(s){
|
|
4368
|
+
case S_TAG:
|
|
4369
|
+
el.setTagName(source.slice(start,p));//tagName
|
|
4370
|
+
s = S_TAG_SPACE;
|
|
4371
|
+
break;
|
|
4372
|
+
case S_ATTR:
|
|
4373
|
+
attrName = source.slice(start,p)
|
|
4374
|
+
s = S_ATTR_SPACE;
|
|
4375
|
+
break;
|
|
4376
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
4377
|
+
var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
|
|
4378
|
+
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
|
|
4379
|
+
addAttribute(attrName, value, start)
|
|
4380
|
+
case S_ATTR_END:
|
|
4381
|
+
s = S_TAG_SPACE;
|
|
4382
|
+
break;
|
|
4383
|
+
//case S_TAG_SPACE:
|
|
4384
|
+
//case S_EQ:
|
|
4385
|
+
//case S_ATTR_SPACE:
|
|
4386
|
+
// void();break;
|
|
4387
|
+
//case S_TAG_CLOSE:
|
|
4388
|
+
//ignore warning
|
|
4389
|
+
}
|
|
4390
|
+
}else{//not space
|
|
4391
|
+
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
|
4392
|
+
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
|
4393
|
+
switch(s){
|
|
4394
|
+
//case S_TAG:void();break;
|
|
4395
|
+
//case S_ATTR:void();break;
|
|
4396
|
+
//case S_ATTR_NOQUOT_VALUE:void();break;
|
|
4397
|
+
case S_ATTR_SPACE:
|
|
4398
|
+
var tagName = el.tagName;
|
|
4399
|
+
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
|
|
4400
|
+
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
|
|
4401
|
+
}
|
|
4402
|
+
addAttribute(attrName, attrName, start);
|
|
4403
|
+
start = p;
|
|
4404
|
+
s = S_ATTR;
|
|
4405
|
+
break;
|
|
4406
|
+
case S_ATTR_END:
|
|
4407
|
+
errorHandler.warning('attribute space is required"'+attrName+'"!!')
|
|
4408
|
+
case S_TAG_SPACE:
|
|
4409
|
+
s = S_ATTR;
|
|
4410
|
+
start = p;
|
|
4411
|
+
break;
|
|
4412
|
+
case S_EQ:
|
|
4413
|
+
s = S_ATTR_NOQUOT_VALUE;
|
|
4414
|
+
start = p;
|
|
4415
|
+
break;
|
|
4416
|
+
case S_TAG_CLOSE:
|
|
4417
|
+
throw new Error("elements closed character '/' and '>' must be connected to");
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
}//end outer switch
|
|
4421
|
+
//console.log('p++',p)
|
|
4422
|
+
p++;
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
/**
|
|
4426
|
+
* @return true if has new namespace define
|
|
4427
|
+
*/
|
|
4428
|
+
function appendElement(el,domBuilder,currentNSMap){
|
|
4429
|
+
var tagName = el.tagName;
|
|
4430
|
+
var localNSMap = null;
|
|
4431
|
+
//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
|
4432
|
+
var i = el.length;
|
|
4433
|
+
while(i--){
|
|
4434
|
+
var a = el[i];
|
|
4435
|
+
var qName = a.qName;
|
|
4436
|
+
var value = a.value;
|
|
4437
|
+
var nsp = qName.indexOf(':');
|
|
4438
|
+
if(nsp>0){
|
|
4439
|
+
var prefix = a.prefix = qName.slice(0,nsp);
|
|
4440
|
+
var localName = qName.slice(nsp+1);
|
|
4441
|
+
var nsPrefix = prefix === 'xmlns' && localName
|
|
4442
|
+
}else{
|
|
4443
|
+
localName = qName;
|
|
4444
|
+
prefix = null
|
|
4445
|
+
nsPrefix = qName === 'xmlns' && ''
|
|
4446
|
+
}
|
|
4447
|
+
//can not set prefix,because prefix !== ''
|
|
4448
|
+
a.localName = localName ;
|
|
4449
|
+
//prefix == null for no ns prefix attribute
|
|
4450
|
+
if(nsPrefix !== false){//hack!!
|
|
4451
|
+
if(localNSMap == null){
|
|
4452
|
+
localNSMap = {}
|
|
4453
|
+
//console.log(currentNSMap,0)
|
|
4454
|
+
_copy(currentNSMap,currentNSMap={})
|
|
4455
|
+
//console.log(currentNSMap,1)
|
|
4456
|
+
}
|
|
4457
|
+
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
4458
|
+
a.uri = 'http://www.w3.org/2000/xmlns/'
|
|
4459
|
+
domBuilder.startPrefixMapping(nsPrefix, value)
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
var i = el.length;
|
|
4463
|
+
while(i--){
|
|
4464
|
+
a = el[i];
|
|
4465
|
+
var prefix = a.prefix;
|
|
4466
|
+
if(prefix){//no prefix attribute has no namespace
|
|
4467
|
+
if(prefix === 'xml'){
|
|
4468
|
+
a.uri = 'http://www.w3.org/XML/1998/namespace';
|
|
4469
|
+
}if(prefix !== 'xmlns'){
|
|
4470
|
+
a.uri = currentNSMap[prefix || '']
|
|
4471
|
+
|
|
4472
|
+
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
var nsp = tagName.indexOf(':');
|
|
4477
|
+
if(nsp>0){
|
|
4478
|
+
prefix = el.prefix = tagName.slice(0,nsp);
|
|
4479
|
+
localName = el.localName = tagName.slice(nsp+1);
|
|
4480
|
+
}else{
|
|
4481
|
+
prefix = null;//important!!
|
|
4482
|
+
localName = el.localName = tagName;
|
|
4483
|
+
}
|
|
4484
|
+
//no prefix element has default namespace
|
|
4485
|
+
var ns = el.uri = currentNSMap[prefix || ''];
|
|
4486
|
+
domBuilder.startElement(ns,localName,tagName,el);
|
|
4487
|
+
//endPrefixMapping and startPrefixMapping have not any help for dom builder
|
|
4488
|
+
//localNSMap = null
|
|
4489
|
+
if(el.closed){
|
|
4490
|
+
domBuilder.endElement(ns,localName,tagName);
|
|
4491
|
+
if(localNSMap){
|
|
4492
|
+
for(prefix in localNSMap){
|
|
4493
|
+
domBuilder.endPrefixMapping(prefix)
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
}else{
|
|
4497
|
+
el.currentNSMap = currentNSMap;
|
|
4498
|
+
el.localNSMap = localNSMap;
|
|
4499
|
+
//parseStack.push(el);
|
|
4500
|
+
return true;
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
|
|
4504
|
+
if(/^(?:script|textarea)$/i.test(tagName)){
|
|
4505
|
+
var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
|
|
4506
|
+
var text = source.substring(elStartEnd+1,elEndStart);
|
|
4507
|
+
if(/[&<]/.test(text)){
|
|
4508
|
+
if(/^script$/i.test(tagName)){
|
|
4509
|
+
//if(!/\]\]>/.test(text)){
|
|
4510
|
+
//lexHandler.startCDATA();
|
|
4511
|
+
domBuilder.characters(text,0,text.length);
|
|
4512
|
+
//lexHandler.endCDATA();
|
|
4513
|
+
return elEndStart;
|
|
4514
|
+
//}
|
|
4515
|
+
}//}else{//text area
|
|
4516
|
+
text = text.replace(/&#?\w+;/g,entityReplacer);
|
|
4517
|
+
domBuilder.characters(text,0,text.length);
|
|
4518
|
+
return elEndStart;
|
|
4519
|
+
//}
|
|
4520
|
+
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
return elStartEnd+1;
|
|
4524
|
+
}
|
|
4525
|
+
function fixSelfClosed(source,elStartEnd,tagName,closeMap){
|
|
4526
|
+
//if(tagName in closeMap){
|
|
4527
|
+
var pos = closeMap[tagName];
|
|
4528
|
+
if(pos == null){
|
|
4529
|
+
//console.log(tagName)
|
|
4530
|
+
pos = source.lastIndexOf('</'+tagName+'>')
|
|
4531
|
+
if(pos<elStartEnd){//忘记闭合
|
|
4532
|
+
pos = source.lastIndexOf('</'+tagName)
|
|
4533
|
+
}
|
|
4534
|
+
closeMap[tagName] =pos
|
|
4535
|
+
}
|
|
4536
|
+
return pos<elStartEnd;
|
|
4537
|
+
//}
|
|
4538
|
+
}
|
|
4539
|
+
function _copy(source,target){
|
|
4540
|
+
for(var n in source){target[n] = source[n]}
|
|
4541
|
+
}
|
|
4542
|
+
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
|
|
4543
|
+
var next= source.charAt(start+2)
|
|
4544
|
+
switch(next){
|
|
4545
|
+
case '-':
|
|
4546
|
+
if(source.charAt(start + 3) === '-'){
|
|
4547
|
+
var end = source.indexOf('-->',start+4);
|
|
4548
|
+
//append comment source.substring(4,end)//<!--
|
|
4549
|
+
if(end>start){
|
|
4550
|
+
domBuilder.comment(source,start+4,end-start-4);
|
|
4551
|
+
return end+3;
|
|
4552
|
+
}else{
|
|
4553
|
+
errorHandler.error("Unclosed comment");
|
|
4554
|
+
return -1;
|
|
4555
|
+
}
|
|
4556
|
+
}else{
|
|
4557
|
+
//error
|
|
4558
|
+
return -1;
|
|
4559
|
+
}
|
|
4560
|
+
default:
|
|
4561
|
+
if(source.substr(start+3,6) == 'CDATA['){
|
|
4562
|
+
var end = source.indexOf(']]>',start+9);
|
|
4563
|
+
domBuilder.startCDATA();
|
|
4564
|
+
domBuilder.characters(source,start+9,end-start-9);
|
|
4565
|
+
domBuilder.endCDATA()
|
|
4566
|
+
return end+3;
|
|
4567
|
+
}
|
|
4568
|
+
//<!DOCTYPE
|
|
4569
|
+
//startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
|
|
4570
|
+
var matchs = split(source,start);
|
|
4571
|
+
var len = matchs.length;
|
|
4572
|
+
if(len>1 && /!doctype/i.test(matchs[0][0])){
|
|
4573
|
+
var name = matchs[1][0];
|
|
4574
|
+
var pubid = false;
|
|
4575
|
+
var sysid = false;
|
|
4576
|
+
if(len>3){
|
|
4577
|
+
if(/^public$/i.test(matchs[2][0])){
|
|
4578
|
+
pubid = matchs[3][0];
|
|
4579
|
+
sysid = len>4 && matchs[4][0];
|
|
4580
|
+
}else if(/^system$/i.test(matchs[2][0])){
|
|
4581
|
+
sysid = matchs[3][0];
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4584
|
+
var lastMatch = matchs[len-1]
|
|
4585
|
+
domBuilder.startDTD(name, pubid, sysid);
|
|
4586
|
+
domBuilder.endDTD();
|
|
4587
|
+
|
|
4588
|
+
return lastMatch.index+lastMatch[0].length
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
return -1;
|
|
4592
|
+
}
|
|
4593
|
+
|
|
4594
|
+
|
|
4595
|
+
|
|
4596
|
+
function parseInstruction(source,start,domBuilder){
|
|
4597
|
+
var end = source.indexOf('?>',start);
|
|
4598
|
+
if(end){
|
|
4599
|
+
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
|
4600
|
+
if(match){
|
|
4601
|
+
var len = match[0].length;
|
|
4602
|
+
domBuilder.processingInstruction(match[1], match[2]) ;
|
|
4603
|
+
return end+2;
|
|
4604
|
+
}else{//error
|
|
4605
|
+
return -1;
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4608
|
+
return -1;
|
|
4609
|
+
}
|
|
4610
|
+
|
|
4611
|
+
function ElementAttributes(){
|
|
4612
|
+
this.attributeNames = {}
|
|
4613
|
+
}
|
|
4614
|
+
ElementAttributes.prototype = {
|
|
4615
|
+
setTagName:function(tagName){
|
|
4616
|
+
if(!tagNamePattern.test(tagName)){
|
|
4617
|
+
throw new Error('invalid tagName:'+tagName)
|
|
4618
|
+
}
|
|
4619
|
+
this.tagName = tagName
|
|
4620
|
+
},
|
|
4621
|
+
addValue:function(qName, value, offset) {
|
|
4622
|
+
if(!tagNamePattern.test(qName)){
|
|
4623
|
+
throw new Error('invalid attribute:'+qName)
|
|
4624
|
+
}
|
|
4625
|
+
this.attributeNames[qName] = this.length;
|
|
4626
|
+
this[this.length++] = {qName:qName,value:value,offset:offset}
|
|
4627
|
+
},
|
|
4628
|
+
length:0,
|
|
4629
|
+
getLocalName:function(i){return this[i].localName},
|
|
4630
|
+
getLocator:function(i){return this[i].locator},
|
|
4631
|
+
getQName:function(i){return this[i].qName},
|
|
4632
|
+
getURI:function(i){return this[i].uri},
|
|
4633
|
+
getValue:function(i){return this[i].value}
|
|
4634
|
+
// ,getIndex:function(uri, localName)){
|
|
4635
|
+
// if(localName){
|
|
4636
|
+
//
|
|
4637
|
+
// }else{
|
|
4638
|
+
// var qName = uri
|
|
4639
|
+
// }
|
|
4640
|
+
// },
|
|
4641
|
+
// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
|
|
4642
|
+
// getType:function(uri,localName){}
|
|
4643
|
+
// getType:function(i){},
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4646
|
+
|
|
4647
|
+
|
|
4648
|
+
function split(source,start){
|
|
4649
|
+
var match;
|
|
4650
|
+
var buf = [];
|
|
4651
|
+
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
|
4652
|
+
reg.lastIndex = start;
|
|
4653
|
+
reg.exec(source);//skip <
|
|
4654
|
+
while(match = reg.exec(source)){
|
|
4655
|
+
buf.push(match);
|
|
4656
|
+
if(match[1])return buf;
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
exports.XMLReader = XMLReader;
|
|
4661
|
+
exports.ParseError = ParseError;
|
|
4295
4662
|
|
|
4296
4663
|
},{}]},{},[1])(1)
|
|
4297
4664
|
});
|