-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjquery.rdfquery.debug.js
6352 lines (6041 loc) · 242 KB
/
jquery.rdfquery.debug.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
/*
* $ URIs @VERSION
*
* Copyright (c) 2008,2009 Jeni Tennison
* Licensed under the MIT (MIT-LICENSE.txt)
*
*/
/**
* @fileOverview $ URIs
* @author <a href="mailto:[email protected]">Jeni Tennison</a>
* @copyright (c) 2008,2009 Jeni Tennison
* @license MIT license (MIT-LICENSE.txt)
* @version 1.0
*/
/**
* @class
* @name jQuery
* @exports $ as jQuery
* @description rdfQuery is a <a href="http://jquery.com/">jQuery</a> plugin. The only fields and methods listed here are those that come as part of the rdfQuery library.
*/
(function ($) {
var
mem = {},
uriRegex = /^(([a-z][\-a-z0-9+\.]*):)?(\/\/([^\/?#]+))?([^?#]*)?(\?([^#]*))?(#(.*))?$/i,
docURI,
parseURI = function (u) {
var m = u.match(uriRegex);
if (m === null) {
throw "Malformed URI: " + u;
}
return {
scheme: m[1] ? m[2].toLowerCase() : undefined,
authority: m[3] ? m[4] : undefined,
path: m[5] || '',
query: m[6] ? m[7] : undefined,
fragment: m[8] ? m[9] : undefined
};
},
removeDotSegments = function (u) {
var r = '', m = [];
if (/\./.test(u)) {
while (u !== undefined && u !== '') {
if (u === '.' || u === '..') {
u = '';
} else if (/^\.\.\//.test(u)) { // starts with ../
u = u.substring(3);
} else if (/^\.\//.test(u)) { // starts with ./
u = u.substring(2);
} else if (/^\/\.(\/|$)/.test(u)) { // starts with /./ or consists of /.
u = '/' + u.substring(3);
} else if (/^\/\.\.(\/|$)/.test(u)) { // starts with /../ or consists of /..
u = '/' + u.substring(4);
r = r.replace(/\/?[^\/]+$/, '');
} else {
m = u.match(/^(\/?[^\/]*)(\/.*)?$/);
u = m[2];
r = r + m[1];
}
}
return r;
} else {
return u;
}
},
merge = function (b, r) {
if (b.authority !== '' && (b.path === undefined || b.path === '')) {
return '/' + r;
} else {
return b.path.replace(/[^\/]+$/, '') + r;
}
};
/**
* Creates a new jQuery.uri object. This should be invoked as a method rather than constructed using new.
* @class Represents a URI
* @param {String} [relative='']
* @param {String|jQuery.uri} [base] Defaults to the base URI of the page
* @returns {jQuery.uri} The new jQuery.uri object.
* @example uri = jQuery.uri('/my/file.html');
*/
$.uri = function (relative, base) {
var uri;
relative = relative || '';
if (mem[relative]) {
return mem[relative];
}
base = base || $.uri.base();
if (typeof base === 'string') {
base = $.uri.absolute(base);
}
uri = new $.uri.fn.init(relative, base);
if (mem[uri]) {
return mem[uri];
} else {
mem[uri] = uri;
return uri;
}
};
$.uri.fn = $.uri.prototype = {
/**
* The scheme used in the URI
* @type String
*/
scheme: undefined,
/**
* The authority used in the URI
* @type String
*/
authority: undefined,
/**
* The path used in the URI
* @type String
*/
path: undefined,
/**
* The query part of the URI
* @type String
*/
query: undefined,
/**
* The fragment part of the URI
* @type String
*/
fragment: undefined,
init: function (relative, base) {
var r = {};
base = base || {};
$.extend(this, parseURI(relative));
if (this.scheme === undefined) {
this.scheme = base.scheme;
if (this.authority !== undefined) {
this.path = removeDotSegments(this.path);
} else {
this.authority = base.authority;
if (this.path === '') {
this.path = base.path;
if (this.query === undefined) {
this.query = base.query;
}
} else {
if (!/^\//.test(this.path)) {
this.path = merge(base, this.path);
}
this.path = removeDotSegments(this.path);
}
}
}
if (this.scheme === undefined) {
throw "Malformed URI: URI is not an absolute URI and no base supplied: " + relative;
}
return this;
},
/**
* Resolves a relative URI relative to this URI
* @param {String} relative
* @returns jQuery.uri
*/
resolve: function (relative) {
return $.uri(relative, this);
},
/**
* Creates a relative URI giving the path from this URI to the absolute URI passed as a parameter
* @param {String|jQuery.uri} absolute
* @returns String
*/
relative: function (absolute) {
var aPath, bPath, i = 0, j, resultPath = [], result = '';
if (typeof absolute === 'string') {
absolute = $.uri(absolute, {});
}
if (absolute.scheme !== this.scheme ||
absolute.authority !== this.authority) {
return absolute.toString();
}
if (absolute.path !== this.path) {
aPath = absolute.path.split('/');
bPath = this.path.split('/');
if (aPath[1] !== bPath[1]) {
result = absolute.path;
} else {
while (aPath[i] === bPath[i]) {
i += 1;
}
j = i;
for (; i < bPath.length - 1; i += 1) {
resultPath.push('..');
}
for (; j < aPath.length; j += 1) {
resultPath.push(aPath[j]);
}
result = resultPath.join('/');
}
result = absolute.query === undefined ? result : result + '?' + absolute.query;
result = absolute.fragment === undefined ? result : result + '#' + absolute.fragment;
return result;
}
if (absolute.query !== undefined && absolute.query !== this.query) {
return '?' + absolute.query + (absolute.fragment === undefined ? '' : '#' + absolute.fragment);
}
if (absolute.fragment !== undefined && absolute.fragment !== this.fragment) {
return '#' + absolute.fragment;
}
return '';
},
/**
* Returns the URI as an absolute string
* @returns String
*/
toString: function () {
var result = '';
if (this._string) {
return this._string;
} else {
result = this.scheme === undefined ? result : (result + this.scheme + ':');
result = this.authority === undefined ? result : (result + '//' + this.authority);
result = result + this.path;
result = this.query === undefined ? result : (result + '?' + this.query);
result = this.fragment === undefined ? result : (result + '#' + this.fragment);
this._string = result;
return result;
}
}
};
$.uri.fn.init.prototype = $.uri.fn;
/**
* Creates a {@link jQuery.uri} from a known-to-be-absolute URI
* @param {String}
* @returns {jQuery.uri}
*/
$.uri.absolute = function (uri) {
return $.uri(uri, {});
};
/**
* Creates a {@link jQuery.uri} from a relative URI and an optional base URI
* @returns {jQuery.uri}
* @see jQuery.uri
*/
$.uri.resolve = function (relative, base) {
return $.uri(relative, base);
};
/**
* Creates a string giving the relative path from a base URI to an absolute URI
* @param {String} absolute
* @param {String} base
* @returns {String}
*/
$.uri.relative = function (absolute, base) {
return $.uri(base, {}).relative(absolute);
};
/**
* Returns the base URI of the page
* @returns {jQuery.uri}
*/
$.uri.base = function () {
return $(document).base();
};
/**
* Returns the base URI in scope for the first selected element
* @methodOf jQuery#
* @name jQuery#base
* @returns {jQuery.uri}
* @example baseURI = $('img').base();
*/
$.fn.base = function () {
var base = $(this).parents().andSelf().find('base').attr('href'),
doc = $(this)[0].ownerDocument || document,
docURI = $.uri.absolute(doc.location === null ? document.location.href : doc.location.href);
return base === undefined ? docURI : $.uri(base, docURI);
};
})(jQuery);
/*
* jQuery CURIE @VERSION
*
* Copyright (c) 2008,2009 Jeni Tennison
* Licensed under the MIT (MIT-LICENSE.txt)
*
* Depends:
* jquery.uri.js
*/
/**
* @fileOverview XML Namespace processing
* @author <a href="mailto:[email protected]">Jeni Tennison</a>
* @copyright (c) 2008,2009 Jeni Tennison
* @license MIT license (MIT-LICENSE.txt)
* @version 1.0
* @requires jquery.uri.js
*/
/*global jQuery */
(function ($) {
var
xmlNs = 'http://www.w3.org/XML/1998/namespace',
xmlnsNs = 'http://www.w3.org/2000/xmlns/',
xmlnsRegex = /\sxmlns(?::([^ =]+))?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,
ncNameChar = '[-A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u10000-\uEFFFF\.0-9\u00B7\u0300-\u036F\u203F-\u2040]',
ncNameStartChar = '[\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3\u4E00-\u9FA5\u3007\u3021-\u3029_]',
ncNameRegex = new RegExp('^' + ncNameStartChar + ncNameChar + '*$');
/**
* Returns the namespaces declared in the scope of the first selected element, or
* adds a namespace declaration to all selected elements. Pass in no parameters
* to return all namespaces bindings on the first selected element. If only
* the prefix parameter is specified, this method will return the namespace
* URI that is bound to the specified prefix on the first element in the selection
* If the prefix and uri parameters are both specified, this method will
* add the binding of the specified prefix and namespace URI to all elements
* in the selection.
* @methodOf jQuery#
* @name jQuery#xmlns
* @param {String} [prefix] Restricts the namespaces returned to only the namespace with the specified namespace prefix.
* @param {String|jQuery.uri} [uri] Adds a namespace declaration to the selected elements that maps the specified prefix to the specified namespace.
* @param {Object} [inherited] A map of inherited namespace bindings.
* @returns {Object|jQuery.uri|jQuery}
* @example
* // Retrieve all of the namespace bindings on the HTML document element
* var nsMap = $('html').xmlns();
* @example
* // Retrieve the namespace URI mapped to the 'dc' prefix on the HTML document element
* var dcNamespace = $('html').xmlns('dc');
* @example
* // Create a namespace declaration that binds the 'dc' prefix to the URI 'http://purl.org/dc/elements/1.1/'
* $('html').xmlns('dc', 'http://purl.org/dc/elements/1.1/');
*/
$.fn.xmlns = function (prefix, uri, inherited) {
var
elem = this.eq(0),
ns = elem.data('xmlns'),
e = elem[0], a, p, i,
decl = prefix ? 'xmlns:' + prefix : 'xmlns',
value,
tag, found = false;
if (uri === undefined) {
if (prefix === undefined) { // get the in-scope declarations on the first element
if (!ns) {
ns = {
// xml: $.uri(xmlNs)
};
if (e.attributes && e.attributes.getNamedItemNS) {
for (i = 0; i < e.attributes.length; i += 1) {
a = e.attributes[i];
if (/^xmlns(:(.+))?$/.test(a.nodeName)) {
prefix = /^xmlns(:(.+))?$/.exec(a.nodeName)[2] || '';
value = a.nodeValue;
if (prefix === '' || (value !== '' && value !== xmlNs && value !== xmlnsNs && ncNameRegex.test(prefix) && prefix !== 'xml' && prefix !== 'xmlns')) {
ns[prefix] = $.uri(a.nodeValue);
found = true;
}
}
}
} else {
tag = /<[^>]+>/.exec(e.outerHTML);
a = xmlnsRegex.exec(tag);
while (a !== null) {
prefix = a[1] || '';
value = a[2] || a[3];
if (prefix === '' || (value !== '' && value !== xmlNs && value !== xmlnsNs && ncNameRegex.test(prefix) && prefix !== 'xml' && prefix !== 'xmlns')) {
ns[prefix] = $.uri(a[2] || a[3]);
found = true;
}
a = xmlnsRegex.exec(tag);
}
xmlnsRegex.lastIndex = 0;
}
inherited = inherited || (e.parentNode.nodeType === 1 ? elem.parent().xmlns() : {});
ns = found ? $.extend({}, inherited, ns) : inherited;
elem.data('xmlns', ns);
}
return ns;
} else if (typeof prefix === 'object') { // set the prefix mappings defined in the object
for (p in prefix) {
if (typeof prefix[p] === 'string' && ncNameRegex.test(p)) {
this.xmlns(p, prefix[p]);
}
}
this.find('*').andSelf().removeData('xmlns');
return this;
} else { // get the in-scope declaration associated with this prefix on the first element
if (!ns) {
ns = elem.xmlns();
}
return ns[prefix];
}
} else { // set
this.find('*').andSelf().removeData('xmlns');
return this.attr(decl, uri);
}
};
/**
* Removes one or more XML namespace bindings from the selected elements.
* @methodOf jQuery#
* @name jQuery#removeXmlns
* @param {String|Object|String[]} prefix The prefix(es) of the XML namespace bindings that are to be removed from the selected elements.
* @returns {jQuery} The original jQuery object.
* @example
* // Remove the foaf namespace declaration from the body element:
* $('body').removeXmlns('foaf');
* @example
* // Remove the foo and bar namespace declarations from all h2 elements
* $('h2').removeXmlns(['foo', 'bar']);
* @example
* // Remove the foo and bar namespace declarations from all h2 elements
* var namespaces = { foo : 'http://www.example.org/foo', bar : 'http://www.example.org/bar' };
* $('h2').removeXmlns(namespaces);
*/
$.fn.removeXmlns = function (prefix) {
var decl, p, i;
if (typeof prefix === 'object') {
if (prefix.length === undefined) { // assume an object representing namespaces
for (p in prefix) {
if (typeof prefix[p] === 'string') {
this.removeXmlns(p);
}
}
} else { // it's an array
for (i = 0; i < prefix.length; i += 1) {
this.removeXmlns(prefix[i]);
}
}
} else {
decl = prefix ? 'xmlns:' + prefix : 'xmlns';
this.removeAttr(decl);
}
this.find('*').andSelf().removeData('xmlns');
return this;
};
$.fn.qname = function (name) {
var m, prefix, namespace;
if (name === undefined) {
if (this[0].outerHTML === undefined) {
name = this[0].nodeName.toLowerCase();
} else {
name = /<([^ >]+)/.exec(this[0].outerHTML)[1].toLowerCase();
}
}
if (name === '?xml:namespace') {
// there's a prefix on the name, but we can't get at it
throw "XMLinHTML: Unable to get the prefix to resolve the name of this element";
}
m = /^(([^:]+):)?([^:]+)$/.exec(name);
prefix = m[2] || '';
namespace = this.xmlns(prefix);
if (namespace === undefined && prefix !== '') {
throw "MalformedQName: The prefix " + prefix + " is not declared";
}
return {
namespace: namespace,
localPart: m[3],
prefix: prefix,
name: name
};
};
})(jQuery);
/*
* jQuery CURIE @VERSION
*
* Copyright (c) 2008,2009 Jeni Tennison
* Licensed under the MIT (MIT-LICENSE.txt)
*
* Depends:
* jquery.uri.js
*/
/**
* @fileOverview XML Schema datatype handling
* @author <a href="mailto:[email protected]">Jeni Tennison</a>
* @copyright (c) 2008,2009 Jeni Tennison
* @license MIT license (MIT-LICENSE.txt)
* @version 1.0
* @requires jquery.uri.js
*/
(function ($) {
var strip = function (value) {
return value.replace(/[ \t\n\r]+/, ' ').replace(/^ +/, '').replace(/ +$/, '');
};
/**
* Creates a new jQuery.typedValue object. This should be invoked as a method
* rather than constructed using new.
* @class Represents a value with an XML Schema datatype
* @param {String} value The string representation of the value
* @param {String} datatype The XML Schema datatype URI
* @returns {jQuery.typedValue}
* @example intValue = jQuery.typedValue('42', 'http://www.w3.org/2001/XMLSchema#integer');
*/
$.typedValue = function (value, datatype) {
return $.typedValue.fn.init(value, datatype);
};
$.typedValue.fn = $.typedValue.prototype = {
/**
* The string representation of the value
* @memberOf jQuery.typedValue#
*/
representation: undefined,
/**
* The value as an object. The type of the object will
* depend on the XML Schema datatype URI specified
* in the constructor. The following table lists the mappings
* currently supported:
* <table>
* <tr>
* <th>XML Schema Datatype</th>
* <th>Value type</th>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#string</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#token</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#NCName</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#boolean</td>
* <td>bool</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#decimal</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#integer</td>
* <td>int</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#int</td>
* <td>int</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#float</td>
* <td>float</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#double</td>
* <td>float</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#dateTime</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#date</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#gYear</td>
* <td>int</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#gMonthDay</td>
* <td>string</td>
* </tr>
* <tr>
* <td>http://www.w3.org/2001/XMLSchema#anyURI</td>
* <td>{@link jQuery.uri}</td>
* </tr>
* </table>
* @memberOf jQuery.typedValue#
*/
value: undefined,
/**
* The XML Schema datatype URI for the value's datatype
* @memberOf jQuery.typedValue#
*/
datatype: undefined,
init: function (value, datatype) {
var d = $.typedValue.types[datatype];
if ($.typedValue.valid(value, datatype)) {
this.representation = value;
this.datatype = datatype;
this.value = d === undefined ? strip(value) : d.value(d.strip ? strip(value) : value);
return this;
} else {
throw {
name: 'InvalidValue',
message: value + ' is not a valid ' + datatype + ' value'
};
}
}
};
$.typedValue.fn.init.prototype = $.typedValue.fn;
/**
* An object that holds the datatypes supported by the script. The properties of this object are the URIs of the datatypes, and each datatype has four properties:
* <dl>
* <dt>strip</dt>
* <dd>A boolean value that indicates whether whitespace should be stripped from the value prior to testing against the regular expression or passing to the value function.</dd>
* <dt>regex</dt>
* <dd>A regular expression that valid values of the type must match.</dd>
* <dt>validate</dt>
* <dd>Optional. A function that performs further testing on the value.</dd>
* <dt>value</dt>
* <dd>A function that returns a Javascript object equivalent for the value.</dd>
* </dl>
* You can add to this object as necessary for your own datatypes, and {@link jQuery.typedValue} and {@link jQuery.typedValue.valid} will work with them.
* @see jQuery.typedValue
* @see jQuery.typedValue.valid
*/
$.typedValue.types = {};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#string'] = {
regex: /^.*$/,
strip: false,
/** @ignore */
value: function (v) {
return v;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#token'] = {
regex: /^.*$/,
strip: true,
/** @ignore */
value: function (v) {
return strip(v);
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#NCName'] = {
regex: /^[a-z_][-\.a-z0-9]+$/i,
strip: true,
/** @ignore */
value: function (v) {
return strip(v);
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#boolean'] = {
regex: /^(?:true|false|1|0)$/,
strip: true,
/** @ignore */
value: function (v) {
return v === 'true' || v === '1';
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#decimal'] = {
regex: /^[\-\+]?(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)$/,
strip: true,
/** @ignore */
value: function (v) {
v = v.replace(/^0+/, '')
.replace(/0+$/, '');
if (v === '') {
v = '0.0';
}
if (v.substring(0, 1) === '.') {
v = '0' + v;
}
if (/\.$/.test(v)) {
v = v + '0';
} else if (!/\./.test(v)) {
v = v + '.0';
}
return v;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#integer'] = {
regex: /^[\-\+]?[0-9]+$/,
strip: true,
/** @ignore */
value: function (v) {
return parseInt(v, 10);
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#int'] = {
regex: /^[\-\+]?[0-9]+$/,
strip: true,
/** @ignore */
value: function (v) {
return parseInt(v, 10);
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#float'] = {
regex: /^(?:[\-\+]?(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)(?:[eE][\-\+]?[0-9]+)?|[\-\+]?INF|NaN)$/,
strip: true,
/** @ignore */
value: function (v) {
if (v === '-INF') {
return -1 / 0;
} else if (v === 'INF' || v === '+INF') {
return 1 / 0;
} else {
return parseFloat(v);
}
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#double'] = {
regex: $.typedValue.types['http://www.w3.org/2001/XMLSchema#float'].regex,
strip: true,
value: $.typedValue.types['http://www.w3.org/2001/XMLSchema#float'].value
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#duration'] = {
regex: /^([\-\+])?P(?:([0-9]+)Y)?(?:([0-9]+)M)?(?:([0-9]+)D)?(?:T(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+(?:\.[0-9]+)?)?S)?)$/,
/** @ignore */
validate: function (v) {
var m = this.regex.exec(v);
return m[2] || m[3] || m[4] || m[5] || m[6] || m[7];
},
strip: true,
/** @ignore */
value: function (v) {
return v;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#yearMonthDuration'] = {
regex: /^([\-\+])?P(?:([0-9]+)Y)?(?:([0-9]+)M)?$/,
/** @ignore */
validate: function (v) {
var m = this.regex.exec(v);
return m[2] || m[3];
},
strip: true,
/** @ignore */
value: function (v) {
var m = this.regex.exec(v),
years = m[2] || 0,
months = m[3] || 0;
months += years * 12;
return m[1] === '-' ? -1 * months : months;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#dateTime'] = {
regex: /^(-?[0-9]{4,})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):(([0-9]{2})(\.([0-9]+))?)((?:[\-\+]([0-9]{2}):([0-9]{2}))|Z)?$/,
/** @ignore */
validate: function (v) {
var
m = this.regex.exec(v),
year = parseInt(m[1], 10),
tz = m[10] === undefined || m[10] === 'Z' ? '+0000' : m[10].replace(/:/, ''),
date;
if (year === 0 ||
parseInt(tz, 10) < -1400 || parseInt(tz, 10) > 1400) {
return false;
}
try {
year = year < 100 ? Math.abs(year) + 1000 : year;
month = parseInt(m[2], 10);
day = parseInt(m[3], 10);
if (day > 31) {
return false;
} else if (day > 30 && !(month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12)) {
return false;
} else if (month === 2) {
if (day > 29) {
return false;
} else if (day === 29 && (year % 4 !== 0 || (year % 100 === 0 && year % 400 !== 0))) {
return false;
}
}
date = '' + year + '/' + m[2] + '/' + m[3] + ' ' + m[4] + ':' + m[5] + ':' + m[7] + ' ' + tz;
date = new Date(date);
return true;
} catch (e) {
return false;
}
},
strip: true,
/** @ignore */
value: function (v) {
return v;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#date'] = {
regex: /^(-?[0-9]{4,})-([0-9]{2})-([0-9]{2})((?:[\-\+]([0-9]{2}):([0-9]{2}))|Z)?$/,
/** @ignore */
validate: function (v) {
var
m = this.regex.exec(v),
year = parseInt(m[1], 10),
month = parseInt(m[2], 10),
day = parseInt(m[3], 10),
tz = m[10] === undefined || m[10] === 'Z' ? '+0000' : m[10].replace(/:/, '');
if (year === 0 ||
month > 12 ||
day > 31 ||
parseInt(tz, 10) < -1400 || parseInt(tz, 10) > 1400) {
return false;
} else {
return true;
}
},
strip: true,
/** @ignore */
value: function (v) {
return v;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#gYear'] = {
regex: /^-?([0-9]{4,})$/,
/** @ignore */
validate: function (v) {
var i = parseInt(v, 10);
return i !== 0;
},
strip: true,
/** @ignore */
value: function (v) {
return parseInt(v, 10);
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#gMonthDay'] = {
regex: /^--([0-9]{2})-([0-9]{2})((?:[\-\+]([0-9]{2}):([0-9]{2}))|Z)?$/,
/** @ignore */
validate: function (v) {
var
m = this.regex.exec(v),
month = parseInt(m[1], 10),
day = parseInt(m[2], 10),
tz = m[3] === undefined || m[3] === 'Z' ? '+0000' : m[3].replace(/:/, '');
if (month > 12 ||
day > 31 ||
parseInt(tz, 10) < -1400 || parseInt(tz, 10) > 1400) {
return false;
} else if (month === 2 && day > 29) {
return false;
} else if ((month === 4 || month === 6 || month === 9 || month === 11) && day > 30) {
return false;
} else {
return true;
}
},
strip: true,
/** @ignore */
value: function (v) {
return v;
}
};
$.typedValue.types['http://www.w3.org/2001/XMLSchema#anyURI'] = {
regex: /^.*$/,
strip: true,
/** @ignore */
value: function (v, options) {
var opts = $.extend({}, $.typedValue.defaults, options);
return $.uri.resolve(v, opts.base);
}
};
$.typedValue.defaults = {
base: $.uri.base(),
namespaces: {}
};
/**
* Checks whether a value is valid according to a given datatype. The datatype must be held in the {@link jQuery.typedValue.types} object.
* @param {String} value The value to validate.
* @param {String} datatype The URI for the datatype against which the value will be validated.
* @returns {boolean} True if the value is valid or the datatype is not recognised.
* @example validDate = $.typedValue.valid(date, 'http://www.w3.org/2001/XMLSchema#date');
*/
$.typedValue.valid = function (value, datatype) {
var d = $.typedValue.types[datatype];
if (d === undefined) {
return true;
} else {
value = d.strip ? strip(value) : value;
if (d.regex.test(value)) {
return d.validate === undefined ? true : d.validate(value);
} else {
return false;
}
}
};
})(jQuery);
/*
* jQuery CURIE @VERSION
*
* Copyright (c) 2008,2009 Jeni Tennison
* Licensed under the MIT (MIT-LICENSE.txt)
*
* Depends:
* jquery.uri.js
* jquery.xmlns.js
*/
/**
* @fileOverview jQuery CURIE handling
* @author <a href="mailto:[email protected]">Jeni Tennison</a>
* @copyright (c) 2008,2009 Jeni Tennison
* @license MIT license (MIT-LICENSE.txt)
* @version 1.0
* @requires jquery.uri.js
* @requires jquery.xmlns.js
*/
(function ($) {
/**
* Creates a {@link jQuery.uri} object by parsing a CURIE.
* @methodOf jQuery
* @param {String} curie The CURIE to be parsed
* @param {String} uri The URI string to be converted to a CURIE.
* @param {Object} [options] CURIE parsing options
* @param {string} [options.reservedNamespace='http://www.w3.org/1999/xhtml/vocab#'] The namespace to apply to a CURIE that has no prefix and either starts with a colon or is in the list of reserved local names
* @param {string} [options.defaultNamespace] The namespace to apply to a CURIE with no prefix which is not mapped to the reserved namespace by the rules given above.
* @param {Object} [options.namespaces] A map of namespace bindings used to map CURIE prefixes to URIs.
* @param {string[]} [options.reserved=['alternate', 'appendix', 'bookmark', 'cite', 'chapter', 'contents', 'copyright', 'first', 'glossary', 'help', 'icon', 'index', 'last', 'license', 'meta', 'next', 'p3pv1', 'prev', 'role', 'section', 'stylesheet', 'subsection', 'start', 'top', 'up']] A list of local names that will always be mapped to the URI specified by reservedNamespace.
* @param {string} [options.charcase='lower'] Specifies whether the curie's case is altered before it's interpreted. Acceptable values are:
* <dl>
* <dt>lower</dt><dd>Force the CURIE string to lower case.</dd>
* <dt>upper</dt><dd>Force the CURIE string to upper case.</dd>
* <dt>preserve</dt><dd>Preserve the original case of the CURIE. Note that this might not be possible if the CURIE has been taken from an HTML attribute value because of the case conversions performed automatically by browsers. For this reason, it's a good idea to avoid mixed-case CURIEs within RDFa.</dd>
* </dl>
* @returns {jQuery.uri} A new {@link jQuery.uri} object representing the full absolute URI specified by the CURIE.
*/
$.curie = function (curie, options) {
var
opts = $.extend({}, $.curie.defaults, options || {}),
m = /^(([^:]*):)?(.+)$/.exec(curie),
prefix = m[2],
local = m[3],
ns = opts.namespaces[prefix];
if (/^:.+/.test(curie)) { // This is the case of a CURIE like ":test"
if (opts.reservedNamespace === undefined || opts.reservedNamespace === null) {
throw "Malformed CURIE: No prefix and no default namespace for unprefixed CURIE " + curie;
} else {
ns = opts.reservedNamespace;
}
} else if (prefix) {
if (ns === undefined) {
throw "Malformed CURIE: No namespace binding for " + prefix + " in CURIE " + curie;
}
} else {
if (opts.charcase === 'lower') {
curie = curie.toLowerCase();
} else if (opts.charcase === 'upper') {
curie = curie.toUpperCase();
}
if (opts.reserved.length && $.inArray(curie, opts.reserved) >= 0) {
ns = opts.reservedNamespace;
local = curie;
} else if (opts.defaultNamespace === undefined || opts.defaultNamespace === null) {
// the default namespace is provided by the application; it's not clear whether
// the default XML namespace should be used if there's a colon but no prefix
throw "Malformed CURIE: No prefix and no default namespace for unprefixed CURIE " + curie;
} else {
ns = opts.defaultNamespace;
}
}
return $.uri(ns + local);
};
$.curie.defaults = {
namespaces: {},
reserved: [],
reservedNamespace: undefined,
defaultNamespace: undefined,
charcase: 'preserve'
};
/**
* Creates a {@link jQuery.uri} object by parsing a safe CURIE string (a CURIE
* contained within square brackets). If the input safeCurie string does not
* start with '[' and end with ']', the entire string content will be interpreted
* as a URI string.
* @methodOf jQuery
* @param {String} safeCurie The safe CURIE string to be parsed.
* @param {Object} [options] CURIE parsing options