forked from yaronn/xpath.js
-
Notifications
You must be signed in to change notification settings - Fork 71
/
xpath.js
5041 lines (4404 loc) · 170 KB
/
xpath.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* xpath.js
*
* An XPath 1.0 library for JavaScript.
*
* Cameron McCormack <cam (at) mcc.id.au>
*
* This work is licensed under the MIT License.
*
* Revision 20: April 26, 2011
* Fixed a typo resulting in FIRST_ORDERED_NODE_TYPE results being wrong,
* thanks to <shi_a009 (at) hotmail.com>.
*
* Revision 19: November 29, 2005
* Nodesets now store their nodes in a height balanced tree, increasing
* performance for the common case of selecting nodes in document order,
* thanks to Sébastien Cramatte <contact (at) zeninteractif.com>.
* AVL tree code adapted from Raimund Neumann <rnova (at) gmx.net>.
*
* Revision 18: October 27, 2005
* DOM 3 XPath support. Caveats:
* - namespace prefixes aren't resolved in XPathEvaluator.createExpression,
* but in XPathExpression.evaluate.
* - XPathResult.invalidIteratorState is not implemented.
*
* Revision 17: October 25, 2005
* Some core XPath function fixes and a patch to avoid crashing certain
* versions of MSXML in PathExpr.prototype.getOwnerElement, thanks to
* Sébastien Cramatte <contact (at) zeninteractif.com>.
*
* Revision 16: September 22, 2005
* Workarounds for some IE 5.5 deficiencies.
* Fixed problem with prefix node tests on attribute nodes.
*
* Revision 15: May 21, 2005
* Fixed problem with QName node tests on elements with an xmlns="...".
*
* Revision 14: May 19, 2005
* Fixed QName node tests on attribute node regression.
*
* Revision 13: May 3, 2005
* Node tests are case insensitive now if working in an HTML DOM.
*
* Revision 12: April 26, 2005
* Updated licence. Slight code changes to enable use of Dean
* Edwards' script compression, http://dean.edwards.name/packer/ .
*
* Revision 11: April 23, 2005
* Fixed bug with 'and' and 'or' operators, fix thanks to
* Sandy McArthur <sandy (at) mcarthur.org>.
*
* Revision 10: April 15, 2005
* Added support for a virtual root node, supposedly helpful for
* implementing XForms. Fixed problem with QName node tests and
* the parent axis.
*
* Revision 9: March 17, 2005
* Namespace resolver tweaked so using the document node as the context
* for namespace lookups is equivalent to using the document element.
*
* Revision 8: February 13, 2005
* Handle implicit declaration of 'xmlns' namespace prefix.
* Fixed bug when comparing nodesets.
* Instance data can now be associated with a FunctionResolver, and
* workaround for MSXML not supporting 'localName' and 'getElementById',
* thanks to Grant Gongaware.
* Fix a few problems when the context node is the root node.
*
* Revision 7: February 11, 2005
* Default namespace resolver fix from Grant Gongaware
* <grant (at) gongaware.com>.
*
* Revision 6: February 10, 2005
* Fixed bug in 'number' function.
*
* Revision 5: February 9, 2005
* Fixed bug where text nodes not getting converted to string values.
*
* Revision 4: January 21, 2005
* Bug in 'name' function, fix thanks to Bill Edney.
* Fixed incorrect processing of namespace nodes.
* Fixed NamespaceResolver to resolve 'xml' namespace.
* Implemented union '|' operator.
*
* Revision 3: January 14, 2005
* Fixed bug with nodeset comparisons, bug lexing < and >.
*
* Revision 2: October 26, 2004
* QName node test namespace handling fixed. Few other bug fixes.
*
* Revision 1: August 13, 2004
* Bug fixes from William J. Edney <bedney (at) technicalpursuit.com>.
* Added minimal licence.
*
* Initial version: June 14, 2004
*/
// non-node wrapper
var xpath = (typeof exports === 'undefined') ? {} : exports;
(function (exports) {
"use strict";
// namespace nodes are not part of the DOM spec, so we use a custom nodetype for them.
// should NOT be used externally
var NAMESPACE_NODE_NODETYPE = '__namespace';
var isNil = function (x) {
return x === null || x === undefined;
};
var isValidNodeType = function (nodeType) {
return nodeType === NAMESPACE_NODE_NODETYPE ||
(Number.isInteger(nodeType)
&& nodeType >= 1
&& nodeType <= 11
);
};
var isNodeLike = function (value) {
return value
&& isValidNodeType(value.nodeType)
&& typeof value.nodeName === "string";
};
// functional helpers
function curry(func) {
var slice = Array.prototype.slice,
totalargs = func.length,
partial = function (args, fn) {
return function () {
return fn.apply(this, args.concat(slice.call(arguments)));
}
},
fn = function () {
var args = slice.call(arguments);
return (args.length < totalargs) ?
partial(args, fn) :
func.apply(this, slice.apply(arguments, [0, totalargs]));
};
return fn;
}
var forEach = function (f, xs) {
for (var i = 0; i < xs.length; i += 1) {
f(xs[i], i, xs);
}
};
var reduce = function (f, seed, xs) {
var acc = seed;
forEach(function (x, i) { acc = f(acc, x, i); }, xs);
return acc;
};
var map = function (f, xs) {
var mapped = new Array(xs.length);
forEach(function (x, i) { mapped[i] = f(x); }, xs);
return mapped;
};
var filter = function (f, xs) {
var filtered = [];
forEach(function (x, i) { if (f(x, i)) { filtered.push(x); } }, xs);
return filtered;
};
var includes = function (values, value) {
for (var i = 0; i < values.length; i += 1) {
if (values[i] === value) {
return true;
}
}
return false;
};
function always(value) { return function () { return value; } }
function toString(x) { return x.toString(); }
var join = function (s, xs) { return xs.join(s); };
var wrap = function (pref, suf, str) { return pref + str + suf; };
var prototypeConcat = Array.prototype.concat;
var sortNodes = function (nodes, reverse) {
var ns = new XNodeSet();
ns.addArray(nodes);
var sorted = ns.toArray();
return reverse ? sorted.reverse() : sorted;
}
// .apply() fails above a certain number of arguments - https://github.com/goto100/xpath/pull/98
var MAX_ARGUMENT_LENGTH = 32767;
function flatten(arr) {
var result = [];
for (var start = 0; start < arr.length; start += MAX_ARGUMENT_LENGTH) {
var chunk = arr.slice(start, start + MAX_ARGUMENT_LENGTH);
result = prototypeConcat.apply(result, chunk);
}
return result;
}
function assign(target, varArgs) { // .length of function is 2
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
}
var NodeTypes = {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NAMESPACE_NODE: NAMESPACE_NODE_NODETYPE,
};
// XPathParser ///////////////////////////////////////////////////////////////
XPathParser.prototype = new Object();
XPathParser.prototype.constructor = XPathParser;
XPathParser.superclass = Object.prototype;
function XPathParser() {
this.init();
}
XPathParser.prototype.init = function () {
this.reduceActions = [];
this.reduceActions[3] = function (rhs) {
return new OrOperation(rhs[0], rhs[2]);
};
this.reduceActions[5] = function (rhs) {
return new AndOperation(rhs[0], rhs[2]);
};
this.reduceActions[7] = function (rhs) {
return new EqualsOperation(rhs[0], rhs[2]);
};
this.reduceActions[8] = function (rhs) {
return new NotEqualOperation(rhs[0], rhs[2]);
};
this.reduceActions[10] = function (rhs) {
return new LessThanOperation(rhs[0], rhs[2]);
};
this.reduceActions[11] = function (rhs) {
return new GreaterThanOperation(rhs[0], rhs[2]);
};
this.reduceActions[12] = function (rhs) {
return new LessThanOrEqualOperation(rhs[0], rhs[2]);
};
this.reduceActions[13] = function (rhs) {
return new GreaterThanOrEqualOperation(rhs[0], rhs[2]);
};
this.reduceActions[15] = function (rhs) {
return new PlusOperation(rhs[0], rhs[2]);
};
this.reduceActions[16] = function (rhs) {
return new MinusOperation(rhs[0], rhs[2]);
};
this.reduceActions[18] = function (rhs) {
return new MultiplyOperation(rhs[0], rhs[2]);
};
this.reduceActions[19] = function (rhs) {
return new DivOperation(rhs[0], rhs[2]);
};
this.reduceActions[20] = function (rhs) {
return new ModOperation(rhs[0], rhs[2]);
};
this.reduceActions[22] = function (rhs) {
return new UnaryMinusOperation(rhs[1]);
};
this.reduceActions[24] = function (rhs) {
return new BarOperation(rhs[0], rhs[2]);
};
this.reduceActions[25] = function (rhs) {
return new PathExpr(undefined, undefined, rhs[0]);
};
this.reduceActions[27] = function (rhs) {
rhs[0].locationPath = rhs[2];
return rhs[0];
};
this.reduceActions[28] = function (rhs) {
rhs[0].locationPath = rhs[2];
rhs[0].locationPath.steps.unshift(new Step(Step.DESCENDANTORSELF, NodeTest.nodeTest, []));
return rhs[0];
};
this.reduceActions[29] = function (rhs) {
return new PathExpr(rhs[0], [], undefined);
};
this.reduceActions[30] = function (rhs) {
if (Utilities.instance_of(rhs[0], PathExpr)) {
if (rhs[0].filterPredicates == undefined) {
rhs[0].filterPredicates = [];
}
rhs[0].filterPredicates.push(rhs[1]);
return rhs[0];
} else {
return new PathExpr(rhs[0], [rhs[1]], undefined);
}
};
this.reduceActions[32] = function (rhs) {
return rhs[1];
};
this.reduceActions[33] = function (rhs) {
return new XString(rhs[0]);
};
this.reduceActions[34] = function (rhs) {
return new XNumber(rhs[0]);
};
this.reduceActions[36] = function (rhs) {
return new FunctionCall(rhs[0], []);
};
this.reduceActions[37] = function (rhs) {
return new FunctionCall(rhs[0], rhs[2]);
};
this.reduceActions[38] = function (rhs) {
return [rhs[0]];
};
this.reduceActions[39] = function (rhs) {
rhs[2].unshift(rhs[0]);
return rhs[2];
};
this.reduceActions[43] = function (rhs) {
return new LocationPath(true, []);
};
this.reduceActions[44] = function (rhs) {
rhs[1].absolute = true;
return rhs[1];
};
this.reduceActions[46] = function (rhs) {
return new LocationPath(false, [rhs[0]]);
};
this.reduceActions[47] = function (rhs) {
rhs[0].steps.push(rhs[2]);
return rhs[0];
};
this.reduceActions[49] = function (rhs) {
return new Step(rhs[0], rhs[1], []);
};
this.reduceActions[50] = function (rhs) {
return new Step(Step.CHILD, rhs[0], []);
};
this.reduceActions[51] = function (rhs) {
return new Step(rhs[0], rhs[1], rhs[2]);
};
this.reduceActions[52] = function (rhs) {
return new Step(Step.CHILD, rhs[0], rhs[1]);
};
this.reduceActions[54] = function (rhs) {
return [rhs[0]];
};
this.reduceActions[55] = function (rhs) {
rhs[1].unshift(rhs[0]);
return rhs[1];
};
this.reduceActions[56] = function (rhs) {
if (rhs[0] == "ancestor") {
return Step.ANCESTOR;
} else if (rhs[0] == "ancestor-or-self") {
return Step.ANCESTORORSELF;
} else if (rhs[0] == "attribute") {
return Step.ATTRIBUTE;
} else if (rhs[0] == "child") {
return Step.CHILD;
} else if (rhs[0] == "descendant") {
return Step.DESCENDANT;
} else if (rhs[0] == "descendant-or-self") {
return Step.DESCENDANTORSELF;
} else if (rhs[0] == "following") {
return Step.FOLLOWING;
} else if (rhs[0] == "following-sibling") {
return Step.FOLLOWINGSIBLING;
} else if (rhs[0] == "namespace") {
return Step.NAMESPACE;
} else if (rhs[0] == "parent") {
return Step.PARENT;
} else if (rhs[0] == "preceding") {
return Step.PRECEDING;
} else if (rhs[0] == "preceding-sibling") {
return Step.PRECEDINGSIBLING;
} else if (rhs[0] == "self") {
return Step.SELF;
}
return -1;
};
this.reduceActions[57] = function (rhs) {
return Step.ATTRIBUTE;
};
this.reduceActions[59] = function (rhs) {
if (rhs[0] == "comment") {
return NodeTest.commentTest;
} else if (rhs[0] == "text") {
return NodeTest.textTest;
} else if (rhs[0] == "processing-instruction") {
return NodeTest.anyPiTest;
} else if (rhs[0] == "node") {
return NodeTest.nodeTest;
}
return new NodeTest(-1, undefined);
};
this.reduceActions[60] = function (rhs) {
return new NodeTest.PITest(rhs[2]);
};
this.reduceActions[61] = function (rhs) {
return rhs[1];
};
this.reduceActions[63] = function (rhs) {
rhs[1].absolute = true;
rhs[1].steps.unshift(new Step(Step.DESCENDANTORSELF, NodeTest.nodeTest, []));
return rhs[1];
};
this.reduceActions[64] = function (rhs) {
rhs[0].steps.push(new Step(Step.DESCENDANTORSELF, NodeTest.nodeTest, []));
rhs[0].steps.push(rhs[2]);
return rhs[0];
};
this.reduceActions[65] = function (rhs) {
return new Step(Step.SELF, NodeTest.nodeTest, []);
};
this.reduceActions[66] = function (rhs) {
return new Step(Step.PARENT, NodeTest.nodeTest, []);
};
this.reduceActions[67] = function (rhs) {
return new VariableReference(rhs[1]);
};
this.reduceActions[68] = function (rhs) {
return NodeTest.nameTestAny;
};
this.reduceActions[69] = function (rhs) {
return new NodeTest.NameTestPrefixAny(rhs[0].split(':')[0]);
};
this.reduceActions[70] = function (rhs) {
return new NodeTest.NameTestQName(rhs[0]);
};
};
XPathParser.actionTable = [
" s s sssssssss s ss s ss",
" s ",
"r rrrrrrrrr rrrrrrr rr r ",
" rrrrr ",
" s s sssssssss s ss s ss",
"rs rrrrrrrr s sssssrrrrrr rrs rs ",
" s s sssssssss s ss s ss",
" s ",
" s ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
" s ",
" s ",
" s s sssss s s ",
"r rrrrrrrrr rrrrrrr rr r ",
"a ",
"r s rr r ",
"r sr rr r ",
"r s rr s rr r ",
"r rssrr rss rr r ",
"r rrrrr rrrss rr r ",
"r rrrrrsss rrrrr rr r ",
"r rrrrrrrr rrrrr rr r ",
"r rrrrrrrr rrrrrs rr r ",
"r rrrrrrrr rrrrrr rr r ",
"r rrrrrrrr rrrrrr rr r ",
"r srrrrrrrr rrrrrrs rr sr ",
"r srrrrrrrr rrrrrrs rr r ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrr rrrrrr rr r ",
"r rrrrrrrr rrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr r ",
" sssss ",
"r rrrrrrrrr rrrrrrr rr sr ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
" s ",
"r srrrrrrrr rrrrrrs rr r ",
"r rrrrrrrr rrrrr rr r ",
" s ",
" s ",
" rrrrr ",
" s s sssssssss s sss s ss",
"r srrrrrrrr rrrrrrs rr r ",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss s ss s ss",
" s s sssssssss ss s ss",
" s s sssssssss s ss s ss",
" s s sssss s s ",
" s s sssss s s ",
"r rrrrrrrrr rrrrrrr rr rr ",
" s s sssss s s ",
" s s sssss s s ",
"r rrrrrrrrr rrrrrrr rr sr ",
"r rrrrrrrrr rrrrrrr rr sr ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr rr ",
" s ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
" rr ",
" s ",
" rs ",
"r sr rr r ",
"r s rr s rr r ",
"r rssrr rss rr r ",
"r rssrr rss rr r ",
"r rrrrr rrrss rr r ",
"r rrrrr rrrss rr r ",
"r rrrrr rrrss rr r ",
"r rrrrr rrrss rr r ",
"r rrrrrsss rrrrr rr r ",
"r rrrrrsss rrrrr rr r ",
"r rrrrrrrr rrrrr rr r ",
"r rrrrrrrr rrrrr rr r ",
"r rrrrrrrr rrrrr rr r ",
"r rrrrrrrr rrrrrr rr r ",
" r ",
" s ",
"r srrrrrrrr rrrrrrs rr r ",
"r srrrrrrrr rrrrrrs rr r ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr r ",
"r rrrrrrrrr rrrrrrr rr rr ",
"r rrrrrrrrr rrrrrrr rr rr ",
" s s sssssssss s ss s ss",
"r rrrrrrrrr rrrrrrr rr rr ",
" r "
];
XPathParser.actionTableNumber = [
" 1 0 /.-,+*)(' & %$ # \"!",
" J ",
"a aaaaaaaaa aaaaaaa aa a ",
" YYYYY ",
" 1 0 /.-,+*)(' & %$ # \"!",
"K1 KKKKKKKK . +*)('KKKKKK KK# K\" ",
" 1 0 /.-,+*)(' & %$ # \"!",
" N ",
" O ",
"e eeeeeeeee eeeeeee ee ee ",
"f fffffffff fffffff ff ff ",
"d ddddddddd ddddddd dd dd ",
"B BBBBBBBBB BBBBBBB BB BB ",
"A AAAAAAAAA AAAAAAA AA AA ",
" P ",
" Q ",
" 1 . +*)(' # \" ",
"b bbbbbbbbb bbbbbbb bb b ",
" ",
"! S !! ! ",
"\" T\" \"\" \" ",
"$ V $$ U $$ $ ",
"& &ZY&& &XW && & ",
") ))))) )))\\[ )) ) ",
". ....._^] ..... .. . ",
"1 11111111 11111 11 1 ",
"5 55555555 55555` 55 5 ",
"7 77777777 777777 77 7 ",
"9 99999999 999999 99 9 ",
": c:::::::: ::::::b :: a: ",
"I fIIIIIIII IIIIIIe II I ",
"= ========= ======= == == ",
"? ????????? ??????? ?? ?? ",
"C CCCCCCCCC CCCCCCC CC CC ",
"J JJJJJJJJ JJJJJJ JJ J ",
"M MMMMMMMM MMMMMM MM M ",
"N NNNNNNNNN NNNNNNN NN N ",
"P PPPPPPPPP PPPPPPP PP P ",
" +*)(' ",
"R RRRRRRRRR RRRRRRR RR aR ",
"U UUUUUUUUU UUUUUUU UU U ",
"Z ZZZZZZZZZ ZZZZZZZ ZZ ZZ ",
"c ccccccccc ccccccc cc cc ",
" j ",
"L fLLLLLLLL LLLLLLe LL L ",
"6 66666666 66666 66 6 ",
" k ",
" l ",
" XXXXX ",
" 1 0 /.-,+*)(' & %$m # \"!",
"_ f________ ______e __ _ ",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 0 /.-,+*)(' %$ # \"!",
" 1 0 /.-,+*)(' & %$ # \"!",
" 1 . +*)(' # \" ",
" 1 . +*)(' # \" ",
"> >>>>>>>>> >>>>>>> >> >> ",
" 1 . +*)(' # \" ",
" 1 . +*)(' # \" ",
"Q QQQQQQQQQ QQQQQQQ QQ aQ ",
"V VVVVVVVVV VVVVVVV VV aV ",
"T TTTTTTTTT TTTTTTT TT T ",
"@ @@@@@@@@@ @@@@@@@ @@ @@ ",
" \x87 ",
"[ [[[[[[[[[ [[[[[[[ [[ [[ ",
"D DDDDDDDDD DDDDDDD DD DD ",
" HH ",
" \x88 ",
" F\x89 ",
"# T# ## # ",
"% V %% U %% % ",
"' 'ZY'' 'XW '' ' ",
"( (ZY(( (XW (( ( ",
"+ +++++ +++\\[ ++ + ",
"* ***** ***\\[ ** * ",
"- ----- ---\\[ -- - ",
", ,,,,, ,,,\\[ ,, , ",
"0 00000_^] 00000 00 0 ",
"/ /////_^] ///// // / ",
"2 22222222 22222 22 2 ",
"3 33333333 33333 33 3 ",
"4 44444444 44444 44 4 ",
"8 88888888 888888 88 8 ",
" ^ ",
" \x8a ",
"; f;;;;;;;; ;;;;;;e ;; ; ",
"< f<<<<<<<< <<<<<<e << < ",
"O OOOOOOOOO OOOOOOO OO O ",
"` ````````` ``````` `` ` ",
"S SSSSSSSSS SSSSSSS SS S ",
"W WWWWWWWWW WWWWWWW WW W ",
"\\ \\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\ \\\\ \\\\ ",
"E EEEEEEEEE EEEEEEE EE EE ",
" 1 0 /.-,+*)(' & %$ # \"!",
"] ]]]]]]]]] ]]]]]]] ]] ]] ",
" G "
];
XPathParser.gotoTable = [
"3456789:;<=>?@ AB CDEFGH IJ ",
" ",
" ",
" ",
"L456789:;<=>?@ AB CDEFGH IJ ",
" M EFGH IJ ",
" N;<=>?@ AB CDEFGH IJ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" S EFGH IJ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" e ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" h J ",
" i j ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"o456789:;<=>?@ ABpqCDEFGH IJ ",
" ",
" r6789:;<=>?@ AB CDEFGH IJ ",
" s789:;<=>?@ AB CDEFGH IJ ",
" t89:;<=>?@ AB CDEFGH IJ ",
" u89:;<=>?@ AB CDEFGH IJ ",
" v9:;<=>?@ AB CDEFGH IJ ",
" w9:;<=>?@ AB CDEFGH IJ ",
" x9:;<=>?@ AB CDEFGH IJ ",
" y9:;<=>?@ AB CDEFGH IJ ",
" z:;<=>?@ AB CDEFGH IJ ",
" {:;<=>?@ AB CDEFGH IJ ",
" |;<=>?@ AB CDEFGH IJ ",
" };<=>?@ AB CDEFGH IJ ",
" ~;<=>?@ AB CDEFGH IJ ",
" \x7f=>?@ AB CDEFGH IJ ",
"\x80456789:;<=>?@ AB CDEFGH IJ\x81",
" \x82 EFGH IJ ",
" \x83 EFGH IJ ",
" ",
" \x84 GH IJ ",
" \x85 GH IJ ",
" i \x86 ",
" i \x87 ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"o456789:;<=>?@ AB\x8cqCDEFGH IJ ",
" ",
" "
];
XPathParser.productions = [
[1, 1, 2],
[2, 1, 3],
[3, 1, 4],
[3, 3, 3, -9, 4],
[4, 1, 5],
[4, 3, 4, -8, 5],
[5, 1, 6],
[5, 3, 5, -22, 6],
[5, 3, 5, -5, 6],
[6, 1, 7],
[6, 3, 6, -23, 7],
[6, 3, 6, -24, 7],
[6, 3, 6, -6, 7],
[6, 3, 6, -7, 7],
[7, 1, 8],
[7, 3, 7, -25, 8],
[7, 3, 7, -26, 8],
[8, 1, 9],
[8, 3, 8, -12, 9],
[8, 3, 8, -11, 9],
[8, 3, 8, -10, 9],
[9, 1, 10],
[9, 2, -26, 9],
[10, 1, 11],
[10, 3, 10, -27, 11],
[11, 1, 12],
[11, 1, 13],
[11, 3, 13, -28, 14],
[11, 3, 13, -4, 14],
[13, 1, 15],
[13, 2, 13, 16],
[15, 1, 17],
[15, 3, -29, 2, -30],
[15, 1, -15],
[15, 1, -16],
[15, 1, 18],
[18, 3, -13, -29, -30],
[18, 4, -13, -29, 19, -30],
[19, 1, 20],
[19, 3, 20, -31, 19],
[20, 1, 2],
[12, 1, 14],
[12, 1, 21],
[21, 1, -28],
[21, 2, -28, 14],
[21, 1, 22],
[14, 1, 23],
[14, 3, 14, -28, 23],
[14, 1, 24],
[23, 2, 25, 26],
[23, 1, 26],
[23, 3, 25, 26, 27],
[23, 2, 26, 27],
[23, 1, 28],
[27, 1, 16],
[27, 2, 16, 27],
[25, 2, -14, -3],
[25, 1, -32],
[26, 1, 29],
[26, 3, -20, -29, -30],
[26, 4, -21, -29, -15, -30],
[16, 3, -33, 30, -34],
[30, 1, 2],
[22, 2, -4, 14],
[24, 3, 14, -4, 23],
[28, 1, -35],
[28, 1, -2],
[17, 2, -36, -18],
[29, 1, -17],
[29, 1, -19],
[29, 1, -18]
];
XPathParser.DOUBLEDOT = 2;
XPathParser.DOUBLECOLON = 3;
XPathParser.DOUBLESLASH = 4;
XPathParser.NOTEQUAL = 5;
XPathParser.LESSTHANOREQUAL = 6;
XPathParser.GREATERTHANOREQUAL = 7;
XPathParser.AND = 8;
XPathParser.OR = 9;
XPathParser.MOD = 10;
XPathParser.DIV = 11;
XPathParser.MULTIPLYOPERATOR = 12;
XPathParser.FUNCTIONNAME = 13;
XPathParser.AXISNAME = 14;
XPathParser.LITERAL = 15;
XPathParser.NUMBER = 16;
XPathParser.ASTERISKNAMETEST = 17;
XPathParser.QNAME = 18;
XPathParser.NCNAMECOLONASTERISK = 19;
XPathParser.NODETYPE = 20;
XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL = 21;
XPathParser.EQUALS = 22;
XPathParser.LESSTHAN = 23;
XPathParser.GREATERTHAN = 24;
XPathParser.PLUS = 25;
XPathParser.MINUS = 26;
XPathParser.BAR = 27;
XPathParser.SLASH = 28;
XPathParser.LEFTPARENTHESIS = 29;
XPathParser.RIGHTPARENTHESIS = 30;
XPathParser.COMMA = 31;
XPathParser.AT = 32;
XPathParser.LEFTBRACKET = 33;
XPathParser.RIGHTBRACKET = 34;
XPathParser.DOT = 35;
XPathParser.DOLLAR = 36;
XPathParser.prototype.tokenize = function (s1) {
var types = [];
var values = [];
var s = s1 + '\0';
var pos = 0;
var c = s.charAt(pos++);
while (1) {
while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
c = s.charAt(pos++);
}
if (c == '\0' || pos >= s.length) {
break;
}
if (c == '(') {
types.push(XPathParser.LEFTPARENTHESIS);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == ')') {
types.push(XPathParser.RIGHTPARENTHESIS);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '[') {
types.push(XPathParser.LEFTBRACKET);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == ']') {
types.push(XPathParser.RIGHTBRACKET);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '@') {
types.push(XPathParser.AT);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == ',') {
types.push(XPathParser.COMMA);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '|') {
types.push(XPathParser.BAR);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '+') {
types.push(XPathParser.PLUS);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '-') {
types.push(XPathParser.MINUS);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '=') {
types.push(XPathParser.EQUALS);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '$') {
types.push(XPathParser.DOLLAR);
values.push(c);
c = s.charAt(pos++);
continue;
}
if (c == '.') {
c = s.charAt(pos++);
if (c == '.') {
types.push(XPathParser.DOUBLEDOT);
values.push("..");
c = s.charAt(pos++);
continue;