-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
7937 lines (7832 loc) · 332 KB
/
index.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
/*
Code from the last published version (0.0.2) of the npm package [xmla4js](https://www.npmjs.com/package/xmla4js).
Forked to modify the function `_xjs` in order to manage tags including diacritics.
Changes made:
- receive an option to normalize the xml through `xml.normalize('NFD')`
- regex not only looks for alphanumeric characters (\w) but also for character range \u0300-\u036f
*/
/*
Copyright 2009,2010,2011 Roland Bouman
contact: [email protected] ~ http://rpbouman.blogspot.com/ ~ http://code.google.com/p/xmla4js
twitter: @rolandbouman
This is xmla4js - a stand-alone javascript library for working with "XML for Analysis".
XML for Analysis (XML/A) is a vendor-neutral industry-standard protocol for OLAP services over HTTP.
Xmla4js is cross-browser and node.js compatible and enables web-browser-based analytical business intelligence applications.
Xmla4js can be loaded as a common js or amd module.
This file contains human-readable javascript source along with the YUI Doc compatible annotations.
Note: some portions of the API documentation were adopted from the original XML/A specification.
I believe that this constitutes fair use, but if you have reason to believe that the documentation
violates any copyright, or is otherwise incompatible with the LGPL license please contact me.
Include this in your web-pages for debug and development purposes only.
For production purposes, consider using the minified/obfuscated versions in the /js directory.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
* This is xmla4js - a stand-alone javascript library for working with "XML for Analysis".
* XML for Analysis (XML/A) is a vendor-neutral industry-standard protocol for OLAP services over HTTP.
* Xmla4js is cross-browser and node.js compatible and enables web-browser-based analytical business intelligence applications.
* Xmla4js can be loaded as a common js or amd module.
* @module xmla
* @title Xmla
*/
;(function (window) {
var Xmla,
_soap = 'http://schemas.xmlsoap.org/soap/',
_xmlnsSOAPenvelope = _soap + 'envelope/',
_xmlnsSOAPenvelopePrefix = 'SOAP-ENV',
_xmlnsIsSOAPenvelope =
'xmlns:' + _xmlnsSOAPenvelopePrefix + '="' + _xmlnsSOAPenvelope + '"',
_SOAPencodingStyle =
_xmlnsSOAPenvelopePrefix + ':encodingStyle="' + _soap + 'encoding/"',
_ms = 'urn:schemas-microsoft-com:',
_xmlnsXmla = _ms + 'xml-analysis',
_xmlnsIsXmla = 'xmlns="' + _xmlnsXmla + '"',
_xmlnsSQLPrefix = 'sql',
_xmlnsSQL = _ms + 'xml-sql',
_xmlnsSchema = 'http://www.w3.org/2001/XMLSchema',
_xmlnsSchemaPrefix = 'xsd',
_xmlnsSchemaInstance = 'http://www.w3.org/2001/XMLSchema-instance',
_xmlnsSchemaInstancePrefix = 'xsi',
_xmlnsRowset = _xmlnsXmla + ':rowset',
_xmlnsDataset = _xmlnsXmla + ':mddataset'
var _createXhr
if (window.XMLHttpRequest)
_createXhr = function () {
return new window.XMLHttpRequest()
}
else if (window.ActiveXObject)
_createXhr = function () {
return new window.ActiveXObject('MSXML2.XMLHTTP.3.0')
}
else if (typeof require === 'function')
_createXhr = function () {
var xhr
;(xhr = function () {
this.readyState = 0
this.status = -1
this.statusText = 'Not sent'
this.responseText = null
}).prototype = {
changeStatus: function (statusCode, readyState) {
this.status = statusCode
this.statusText = statusCode
this.readyState = readyState
if (_isFun(this.onreadystatechange)) {
this.onreadystatechange.call(this, this)
}
},
open: function (method, url, async, username, password) {
if (async !== true) {
throw 'Synchronous mode not supported in this environment.'
}
var options = require('url').parse(url)
if (options.host.length > options.hostname.length) {
//for some reason, host includes the port, this confuses http.request
//so, overwrite host with hostname (which does not include the port)
//and kill hostname so that we end up with only host.
options.host = options.hostname
delete options.hostname
}
if (!options.path && options.pathname) {
//old versions of node may not give the path, so we need to create it ourselves.
options.path = options.pathname + (options.search || '')
}
options.method = 'POST' //method;
options.headers = {}
if (username)
options.headers.Authorization =
'Basic ' +
new Buffer(username + ':' + (password || '')).toString('base64')
this.options = options
this.changeStatus(-1, 1)
},
send: function (data) {
var me = this,
options = me.options,
client
options.headers['Content-Length'] = Buffer.byteLength(data)
switch (options.protocol) {
case 'http:':
client = require('http')
if (!options.port) options.port = '80'
break
case 'https:':
client = require('https')
if (!options.port) options.port = '443'
break
default:
throw 'Unsupported protocol ' + options.protocol
}
me.responseText = ''
var request = client.request(options, function (response) {
response.setEncoding('utf8')
me.changeStatus(-1, 2)
response.on('data', function (chunk) {
me.responseText += chunk
me.changeStatus(response.statusCode, 3)
})
response.on('error', function (error) {
me.changeStatus(response.statusCode, 4)
})
response.on('end', function () {
me.changeStatus(response.statusCode, 4)
})
})
request.on('error', function (e) {
me.responseText = e
me.changeStatus(500, 4)
})
/* does not work, maybe only not in old node versions.
request.setTimeout(this.timeout, function(){
request.abort();
me.changeStatus(500, 0);
});
*/
if (data) request.write(data)
request.end()
},
setRequestHeader: function (name, value) {
this.options.headers[name] = value
},
}
return new xhr()
}
else
Xmla.Exception._newError(
'ERROR_INSTANTIATING_XMLHTTPREQUEST',
'_ajax',
null,
)._throw()
function _ajax(options) {
var xhr,
args,
headers,
header,
handlerCalled = false,
handler = function () {
handlerCalled = true
switch (xhr.readyState) {
case 0:
if (_isFun(options.aborted)) options.aborted(xhr)
break
case 4:
if (xhr.status === 200) options.complete(xhr)
else {
var err = Xmla.Exception._newError('HTTP_ERROR', '_ajax', {
request: options,
status: this.status,
statusText: this.statusText,
})
//console.log(err);
//When I have an error in HTTP, this allows better debugging
//So made an extra call instead of _newError inside func call
options.error(err)
}
break
}
}
xhr = _createXhr()
args = ['POST', options.url, options.async]
if (options.username && options.password)
args = args.concat([options.username, options.password])
xhr.open.apply(xhr, args)
//see http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute
if (
!_isUnd(options.requestTimeout) &&
(options.async || !(window && window.document))
) {
xhr.timeout = options.requestTimeout
}
xhr.onreadystatechange = handler
xhr.setRequestHeader(
'Accept',
'text/xml, application/xml, application/soap+xml',
)
xhr.setRequestHeader('Content-Type', 'text/xml')
if ((headers = options.headers))
for (header in headers) xhr.setRequestHeader(header, headers[header])
xhr.send(options.data)
if (!options.async && !handlerCalled) handler.call(xhr)
return xhr
}
function _isUnd(arg) {
return typeof arg === 'undefined'
}
function _isArr(arg) {
return arg && arg.constructor === Array
}
function _isNum(arg) {
return typeof arg === 'number'
}
function _isFun(arg) {
return typeof arg === 'function'
}
function _isStr(arg) {
return typeof arg === 'string'
}
function _isObj(arg) {
return arg && typeof arg === 'object'
}
function _xmlEncode(value) {
if (_isStr(value)) {
value = value
.replace(/\&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
}
return value
}
function _decodeXmlaTagName(tagName) {
return tagName.replace(/_x(\d\d\d\d)_/g, function (match, hex, offset) {
return String.fromCharCode(parseInt(hex, 16))
})
}
//this is here to support (partial) dom interface on top of our own document implementation
//we don't need this in the browser, it's here when running in environments without a native xhr
//where the xhr object does not offer a DOM responseXML object.
function _getElements(parent, list, criteria) {
var childNodes = parent?.childNodes
if (!childNodes) return list
for (var node, i = 0, n = childNodes.length; i < n; i++) {
node = childNodes[i]
if (criteria && criteria.call(null, node) === true) list.push(node)
_getElements(node, list, criteria)
}
}
var _getElementsByTagName = function (node, tagName) {
var func
if ('getElementsByTagName' in node) {
func = function (node, tagName) {
return node.getElementsByTagName(tagName)
}
} else {
func = function (node, tagName) {
var list = [],
criteria =
tagName === '*'
? null
: function (node) {
return (
node.nodeType === 1 &&
(node.namespaceURI === '' ? '' : node.prefix + ':') +
node.nodeName ===
tagName
)
}
_getElements(node, list, criteria)
return list
}
}
return (_getElementsByTagName = func)(node, tagName)
}
var _getElementsByTagNameNS = function (node, ns, prefix, tagName) {
var func
if ('getElementsByTagNameNS' in node) {
func = function (node, ns, prefix, tagName) {
return node.getElementsByTagNameNS(ns, tagName)
}
} else if ('getElementsByTagName' in node) {
func = function (node, ns, prefix, tagName) {
return node.getElementsByTagName((prefix ? prefix + ':' : '') + tagName)
}
} else {
func = function (node, ns, prefix, tagName) {
var list = [],
criteria
if (tagName === '*') {
criteria = function (_node) {
return _node.nodeType === 1 && _node.namespaceURI === ns
}
} else {
criteria = function (_node) {
return (
_node.nodeType === 1 &&
_node.namespaceURI === ns &&
_node.nodeName === tagName
)
}
}
_getElements(node, list, criteria)
return list
}
}
_getElementsByTagNameNS = func
return func(node, ns, prefix, tagName)
}
var _getAttributeNS = function (element, ns, prefix, attributeName) {
var func
if ('getAttributeNS' in element) {
func = function (element, ns, prefix, attributeName) {
return element.getAttributeNS(ns, attributeName)
}
} else if ('getAttribute' in element) {
func = function (element, ns, prefix, attributeName) {
return element.getAttribute(
(prefix ? prefix + ':' : '') + attributeName,
)
}
} else {
func = function (element, namespaceURI, prefix, attributeName) {
var attributes = element.attributes
if (!attributes) return null
for (var attr, i = 0, n = attributes.length; i < n; i++) {
attr = attributes[i]
if (
attr.namespaceURI === namespaceURI &&
attr.nodeName === attributeName
)
return attr.value
}
return null
}
}
return (_getAttributeNS = func)(element, ns, prefix, attributeName)
}
var _getAttribute = function (node, name) {
var func
if ('getAttribute' in node) {
func = function (node, name) {
return node.getAttribute(name)
}
} else {
func = function (node, name) {
var attributes = node?.attributes
if (!attributes) return null
for (var attr, i = 0, n = attributes.length; i < n; i++) {
attr = attributes[i]
if (attr.nodeName === name) return attr.value
}
return null
}
}
return (_getAttribute = func)(node, name)
}
function _getElementText(el) {
//on first call, we examine the properies of the argument element
//to try and find a native (and presumably optimized) method to grab
//the text value of the element.
//We then overwrite the original _getElementText
//to use the optimized one in any subsequent calls
var func
if ('textContent' in el) {
//ff, chrome
func = function (el) {
return el.textContent
}
} else if ('nodeTypedValue' in el) {
//ie8
func = function (el) {
return el.nodeTypedValue
}
} else if ('innerText' in el) {
//ie
func = function (el) {
return el.innerText
}
} else if ('normalize' in el) {
func = function (el) {
el.normalize()
if (el.firstChild) {
return el.firstChild.data
} else {
return null
}
}
} else {
//generic
func = function (el) {
var text = [],
childNode,
childNodes = el.childNodes,
i,
n = childNodes ? childNodes.length : 0
for (i = 0; i < n; i++) {
childNode = childNodes[i]
if (childNode.data !== null) text.push(childNode.data)
}
return text.length ? text.join('') : null
}
}
_getElementText = func
return func(el)
}
function _getXmlaSoapList(container, listType, items, indent) {
if (!indent) indent = ''
var n,
i,
entry,
property,
item,
msg = '\n' + indent + '<' + container + '>'
if (items) {
msg += '\n' + indent + ' <' + listType + '>'
for (property in items) {
if (items.hasOwnProperty(property)) {
item = items[property]
msg += '\n' + indent + ' <' + property + '>'
if (_isArr(item)) {
n = item.length
for (i = 0; i < n; i++) {
entry = item[i]
msg += '<Value>' + _xmlEncode(entry) + '</Value>'
}
} else {
msg += _xmlEncode(item)
}
msg += '</' + property + '>'
}
}
msg += '\n' + indent + ' </' + listType + '>'
}
msg += '\n' + indent + '</' + container + '>'
return msg
}
var _xmlRequestType = 'RequestType'
function _applyProps(object, properties, overwrite) {
if (properties && !object) {
object = {}
}
var property
for (property in properties) {
if (properties.hasOwnProperty(property)) {
if (overwrite || _isUnd(object[property])) {
object[property] = properties[property]
}
}
}
return object
}
function _xjs(xml, normalize) {
var _xml = normalize ? xml.normalize('NFD') : xml
var re =
/<(((([\u0300-\u036f\w\-\.]+):)?([\u0300-\u036f\w\-\.]+))([^>]+)?|\/((([\u0300-\u036f\w\-\.]+):)?([\u0300-\u036f\w\-\.]+))|\?(\w+)([^\?]+)?\?|(!--([^\-]|-[^\-])*--))>|([^<>]+)/gi,
match,
name,
prefix,
atts,
ePrefix,
eName,
piTarget,
text,
ns = { '': '' },
newNs,
nsUri,
doc,
parentNode,
namespaces = [],
nextParent,
node = null
doc = parentNode = {
nodeType: 9,
childNodes: [],
}
function Ns() {
namespaces.push(ns)
var _ns = new (function () {})()
_ns.constructor.prototype = ns
ns = new _ns.constructor()
node.namespaces = ns
newNs = true
}
function popNs() {
ns = namespaces.pop()
}
function unescapeEntities(text) {
return text.replace(
/&((\w+)|#(x?)([0-9a-fA-F]+));/g,
function (match, g1, g2, g3, g4, idx, str) {
if (g2) {
var v = {
lt: '<',
gt: '>',
amp: '&',
apos: "'",
quot: '"',
}[g2]
if (v) {
return v
} else {
throw 'Illegal named entity: ' + g2
}
} else {
return String.fromCharCode(parseInt(g4, g3 ? 16 : 10))
}
},
)
}
while ((match = re.exec(_xml))) {
node = null
if ((name = match[5])) {
newNs = false
node = {
offset: match.index,
parentNode: parentNode,
nodeType: 1,
nodeName: name,
}
nextParent = node
if ((atts = match[6])) {
if (atts.length && atts.substr(atts.length - 1, 1) === '/') {
nextParent = node.parentNode
if (ns === node.namespaces) popNs()
atts = atts.substr(0, atts.length - 1)
}
var attMatch, att
// 123 4 5 6 7
var attRe = /((([\w\-]+):)?([\w\-]+))\s*=\s*('([^']*)'|"([^"]*)")/g
while ((attMatch = attRe.exec(atts))) {
var pfx = attMatch[3] || '',
value = attMatch[attMatch[6] ? 6 : 7]
if (attMatch[1].indexOf('xmlns')) {
if (!node.attributes) node.attributes = []
att = {
nodeType: 2,
prefix: pfx,
nodeName: attMatch[4],
value: unescapeEntities(value),
}
nsUri = pfx === '' ? '' : ns[pfx]
if (typeof nsUri === 'undefined') {
throw 'Unrecognized namespace with prefix "' + prefix + '"'
}
att.namespaceURI = nsUri
node.attributes.push(att)
} else {
if (!newNs) Ns()
ns[attMatch[3] ? attMatch[4] : ''] = value
}
}
attRe.lastIndex = 0
}
prefix = match[4] || ''
node.prefix = prefix
nsUri = ns[prefix]
if (typeof nsUri === 'undefined') {
throw 'Unrecognized namespace with prefix "' + prefix + '"'
}
node.namespaceURI = nsUri
} else if ((eName = match[10])) {
ePrefix = match[9] || ''
if (parentNode.nodeName === eName && parentNode.prefix === ePrefix) {
nextParent = parentNode.parentNode
if (ns === parentNode.namespaces) popNs()
}
// else throw "Unclosed tag " + ePrefix + ":" + eName;
} else if ((piTarget = match[11])) {
node = {
offset: match.index,
parentNode: parentNode,
target: piTarget,
data: match[12],
nodeType: 7,
}
} else if (match[13]) {
node = {
offset: match.index,
parentNode: parentNode,
nodeType: 8,
data: match[14],
}
} else if ((text = match[15]) && !/^\s+$/.test(text)) {
node = {
offset: match.index,
parentNode: parentNode,
nodeType: 3,
data: unescapeEntities(text),
}
}
if (node) {
if (!parentNode.childNodes) parentNode.childNodes = []
parentNode.childNodes.push(node)
}
if (nextParent) parentNode = nextParent
}
return doc
}
/**
*
* The Xmla class provides a javascript API to communicate XML for Analysis (XML/A) over HTTP.
* XML/A is an industry standard protocol that allows webclients to work with OLAP servers.
* To fully understand the scope and purpose of this utility, it is highly recommended
* to read <a href="http://xmla.org/xmla1.1.doc">the XML/A specification</a>
* (MS Word format. For other formats,
* see: <a href="http://code.google.com/p/xmla4js/source/browse/#svn/trunk/doc/xmla1.1 specification">http://code.google.com/p/xmla4js/source/browse/#svn/trunk/doc/xmla1.1 specification</a>).
*
* The optional options parameter sets standard options for this Xmla instnace.
* If ommitted, a copy of the <code><a href="#property_defaultOptions">defaultOptions</code></a> will be used.
*
* @class Xmla
* @constructor
* @param options Object standard options
*/
Xmla = function (options) {
this.listeners = {}
this.listeners[Xmla.EVENT_REQUEST] = []
this.listeners[Xmla.EVENT_SUCCESS] = []
this.listeners[Xmla.EVENT_ERROR] = []
this.listeners[Xmla.EVENT_DISCOVER] = []
this.listeners[Xmla.EVENT_DISCOVER_SUCCESS] = []
this.listeners[Xmla.EVENT_DISCOVER_ERROR] = []
this.listeners[Xmla.EVENT_EXECUTE] = []
this.listeners[Xmla.EVENT_EXECUTE_SUCCESS] = []
this.listeners[Xmla.EVENT_EXECUTE_ERROR] = []
this.options = _applyProps(
_applyProps({}, Xmla.defaultOptions, true),
options,
true,
)
var listeners = this.options.listeners
if (listeners) this.addListener(listeners)
return this
}
/**
* These are the default options used for new Xmla instances in case no custom properties are set.
* It sets the following properties:
* <ul>
* <li><code>requestTimeout</code> int: 30000 - number of milliseconds before a request to the XML/A server will timeout </li>
* <li><code>async</code> boolean: false - determines whether synchronous or asynchronous communication with the XML/A server will be used.</li>
* <li><code>addFieldGetters</code> boolean: true - determines whether Xml.Rowset objects will be created with a getter method for each column.</li>
* <li><code>forceResponseXMLEmulation</code> boolean: false - determines whether to parse responseText or to use the native responseXML from the xhr object.</li>
* </ul>
*
* @property defaultOptions
* @static
* @type object
**/
Xmla.defaultOptions = {
requestTimeout: 30000, //by default, we bail out after 30 seconds
async: false, //by default, we do a synchronous request
addFieldGetters: true, //true to augment rowsets with a method to fetch a specific field.
//forceResponseXMLEmulation: true //true to use our own XML parser instead of XHR's native responseXML. Useful for testing.
forceResponseXMLEmulation: false, //true to use our own XML parser instead of XHR's native responseXML. Useful for testing.
}
/**
* Can be used as value for the method option in the options object passed to the
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server.
* Instead of explicitly setting the method yourself, consider using the <code><a href="#method_request">discover()</a></code> method.
* The <code>discover()</code> method automatically sets the method option to <code>METHOD_DISCOVER</code>.
* @property METHOD_DISCOVER
* @static
* @final
* @type string
* @default Discover
*/
Xmla.METHOD_DISCOVER = 'Discover'
/**
* Can be used as value for the method option property in the options objecct passed to the
* <code><a href="#method_request">request()</code></a> method to invoke the XML/A Execute method on the server.
* Instead of explicitly setting the method yourself, consider using the <code><a href="#method_execute">execute()</a></code> method.
* The <code>execute()</code> method automatically sets the method option to <code>METHOD_EXECUTE</code>.
* @property METHOD_EXECUTE
* @static
* @final
* @type string
* @default Discover
*/
Xmla.METHOD_EXECUTE = 'Execute'
var _xmlaDISCOVER = 'DISCOVER_'
var _xmlaMDSCHEMA = 'MDSCHEMA_'
var _xmlaDBSCHEMA = 'DBSCHEMA_'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DISCOVER_DATASOURCES</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this constant as requestType yourself, consider calling the <code><a href="#method_discoverDataSources">discoverDataSources()</a></code> method.
* The <code>discoverDataSources()</code> method passes <code>DISCOVER_DATASOURCES</code> automatically as requestType for Discover requests.
*
* @property DISCOVER_DATASOURCES
* @static
* @final
* @type string
* @default DISCOVER_DATASOURCES
*/
Xmla.DISCOVER_DATASOURCES = _xmlaDISCOVER + 'DATASOURCES'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DISCOVER_PROPERTIES</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverProperties">discoverProperties()</a></code> method.
* The <code>discoverProperties()</code> method passes <code>DISCOVER_PROPERTIES</code> automatically as requestType for Discover requests.
*
* @property DISCOVER_PROPERTIES
* @static
* @final
* @type string
* @default DISCOVER_PROPERTIES
*/
Xmla.DISCOVER_PROPERTIES = _xmlaDISCOVER + 'PROPERTIES'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DISCOVER_SCHEMA_ROWSETS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverSchemaRowsets">discoverSchemaRowsets()</a></code> method.
* The <code>discoverProperties()</code> method passes <code>DISCOVER_PROPERTIES</code> automatically as requestType for Discover requests.
*
* @property DISCOVER_SCHEMA_ROWSETS
* @static
* @final
* @type string
* @default DISCOVER_SCHEMA_ROWSETS
*/
Xmla.DISCOVER_SCHEMA_ROWSETS = _xmlaDISCOVER + 'SCHEMA_ROWSETS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DISCOVER_ENUMERATORS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverEnumerators">discoverEnumerators()</a></code> method.
* The <code>discoverSchemaRowsets()</code> method issues a request to invoke the Discover method using <code>DISCOVER_SCHEMA_ROWSETS</code> as requestType.
*
* @property DISCOVER_ENUMERATORS
* @static
* @final
* @type string
* @default DISCOVER_ENUMERATORS
*/
Xmla.DISCOVER_ENUMERATORS = _xmlaDISCOVER + 'ENUMERATORS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DISCOVER_KEYWORDS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this requestType yourself, consider calling the <code><a href="#method_discoverLiterals">discoverKeywords()</a></code> method.
* The <code>discoverKeywords()</code> method issues a request to invoke the Discover method using DISCOVER_KEYWORDS as requestType.
*
* @property DISCOVER_KEYWORDS
* @static
* @final
* @type string
* @default DISCOVER_KEYWORDS
*/
Xmla.DISCOVER_KEYWORDS = _xmlaDISCOVER + 'KEYWORDS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DISCOVER_LITERALS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverLiterals">discoverLiterals()</a></code> method.
* The <code>discoverLiterals()</code> method issues a request to invoke the Discover method using DISCOVER_LITERALS as requestType.
*
* @property DISCOVER_LITERALS
* @static
* @final
* @type string
* @default DISCOVER_LITERALS
*/
Xmla.DISCOVER_LITERALS = _xmlaDISCOVER + 'LITERALS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DBSCHEMA_CATALOGS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverDBCatalogs">discoverDBCatalogs()</a></code> method.
* The <code>discoverDBCatalogs()</code> method issues a request to invoke the Discover method using <code>DBSCHEMA_CATALOGS</code> as requestType.
*
* @property DBSCHEMA_CATALOGS
* @static
* @final
* @type string
* @default DBSCHEMA_CATALOGS
*/
Xmla.DBSCHEMA_CATALOGS = _xmlaDBSCHEMA + 'CATALOGS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DBSCHEMA_COLUMNS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverDBColumns">discoverDBColumns()</a></code> method.
* The <code>discoverDBColumns()</code> method issues a request to invoke the Discover method using <code>DBSCHEMA_COLUMNS</code> as requestType.
*
* @property DBSCHEMA_COLUMNS
* @static
* @final
* @type string
* @default DBSCHEMA_COLUMNS
*/
Xmla.DBSCHEMA_COLUMNS = _xmlaDBSCHEMA + 'COLUMNS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DBSCHEMA_PROVIDER_TYPES</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverDBProviderTypes">discoverDBProviderTypes()</a></code> method.
* The <code>discoverDBProviderTypes()</code> method issues a request to invoke the Discover method using <code>DBSCHEMA_PROVIDER_TYPES</code> as requestType.
*
* @property DBSCHEMA_PROVIDER_TYPES
* @static
* @final
* @type string
* @default DBSCHEMA_PROVIDER_TYPES
*/
Xmla.DBSCHEMA_PROVIDER_TYPES = _xmlaDBSCHEMA + 'PROVIDER_TYPES'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DBSCHEMA_SCHEMATA</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverDBSchemata">discoverDBSchemata()</a></code> method.
* The <code>discoverDBColumns()</code> method issues a request to invoke the Discover method using <code>DBSCHEMA_SCHEMATA</code> as requestType.
*
* @property DBSCHEMA_SCHEMATA
* @static
* @final
* @type string
* @default DBSCHEMA_SCHEMATA
*/
Xmla.DBSCHEMA_SCHEMATA = _xmlaDBSCHEMA + 'SCHEMATA'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DBSCHEMA_TABLES</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the <code><a href="#method_discoverDBTables">discoverDBTables()</a></code> method.
* The <code>discoverDBColumns()</code> method issues a request to invoke the Discover method using <code>DBSCHEMA_TABLES</code> as requestType.
*
* @property DBSCHEMA_TABLES
* @static
* @final
* @type string
* @default DBSCHEMA_TABLES
*/
Xmla.DBSCHEMA_TABLES = _xmlaDBSCHEMA + 'TABLES'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>DBSCHEMA_TABLES_INFO</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverDBTablesInfo">discoverDBTablesInfo()</a></code> method.
* The <code>discoverDBTablesInfo()</code> method issues a request to invoke the Discover method using <code>DBSCHEMA_TABLES_INFO</code> as requestType.
*
* @property DBSCHEMA_TABLES_INFO
* @static
* @final
* @type string
* @default <code>DBSCHEMA_TABLES_INFO</code>
*/
Xmla.DBSCHEMA_TABLES_INFO = _xmlaDBSCHEMA + 'TABLES_INFO'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the <code>MDSCHEMA_ACTIONS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverMDActions">discoverMDActions()</a></code> method.
* The <code>discoverMDActions()</code> method issues a request to invoke the Discover method using <code>MDSCHEMA_ACTIONS</code> as requestType.
*
* @property MDSCHEMA_ACTIONS
* @static
* @final
* @type string
* @default MDSCHEMA_ACTIONS
*/
Xmla.MDSCHEMA_ACTIONS = _xmlaMDSCHEMA + 'ACTIONS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the
* <code>MDSCHEMA_CUBES</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverMDCubes">discoverMDCubes()</a></code> method.
* The <code>discoverMDCubes()</code> method issues a request to invoke the Discover method using
* <code>MDSCHEMA_CUBES</code> as requestType.
*
* @property MDSCHEMA_CUBES
* @static
* @final
* @type string
* @default MDSCHEMA_CUBES
*/
Xmla.MDSCHEMA_CUBES = _xmlaMDSCHEMA + 'CUBES'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the
* <code>MDSCHEMA_DIMENSIONS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverMDDimensions">discoverMDDimensions()</a></code> method.
* The <code>discoverMDDimensions()</code> method issues a request to invoke the Discover method using
* <code>MDSCHEMA_DIMENSIONS</code> as requestType.
*
* @property MDSCHEMA_DIMENSIONS
* @static
* @final
* @type string
* @default MDSCHEMA_DIMENSIONS
*/
Xmla.MDSCHEMA_DIMENSIONS = _xmlaMDSCHEMA + 'DIMENSIONS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the
* <code>MDSCHEMA_FUNCTIONS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverMDFunctions">discoverMDFunctions()</a></code> method.
* The <code>discoverMDFunctions()</code> method issues a request to invoke the Discover method using
* <code>MDSCHEMA_FUNCTIONS</code> as requestType.
*
* @property MDSCHEMA_FUNCTIONS
* @static
* @final
* @type string
* @default MDSCHEMA_FUNCTIONS
*/
Xmla.MDSCHEMA_FUNCTIONS = _xmlaMDSCHEMA + 'FUNCTIONS'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the
* <code>MDSCHEMA_HIERARCHIES</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverMDHierarchies">discoverMDHierarchies()</a></code> method.
* The <code>discoverMDHierarchies()</code> method issues a request to invoke the Discover method using
* <code>MDSCHEMA_HIERARCHIES</code> as requestType.
*
* @property MDSCHEMA_HIERARCHIES
* @static
* @final
* @type string
* @default MDSCHEMA_HIERARCHIES
*/
Xmla.MDSCHEMA_HIERARCHIES = _xmlaMDSCHEMA + 'HIERARCHIES'
/**
* Can be used as value for the <code>requestType</code> option in the options object passed to the to
* <code><a href="#method_request">request()</a></code> method to invoke the XML/A Discover method on the server to return the
* <code>MDSCHEMA_LEVELS</code> schema rowset.
* The <code>requestType</code> option applies only to Discover requests.
* Instead of passing this <code>requestType</code> yourself, consider calling the
* <code><a href="#method_discoverMDLevels">discoverMDLevels()</a></code> method.
* The <code>discoverMDLevels()</code> method issues a request to invoke the Discover method using
* <code>MDSCHEMA_LEVELS</code> as requestType.
*
* @property MDSCHEMA_LEVELS
* @static
* @final
* @type string
* @default MDSCHEMA_LEVELS
*/
Xmla.MDSCHEMA_LEVELS = _xmlaMDSCHEMA + 'LEVELS'