@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines • 2.94 kB
JavaScript
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.DataXml={}),e.kendo._globals.Core))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let n={id:`data.xml`,name:`XML`,category:`framework`,depends:[`core`],hidden:!0};(function(e,t){var n=window.kendo,r=Array.isArray,i=e.isPlainObject,a=e.map,o=e.each,s=e.extend,c=n.getter,l=n.Class.extend({init:function(e){var t=this,c=e.total,l=e.model,u=e.parse,d=e.errors,f=e.serialize,p=e.data;if(l){if(i(l)){var m=e.modelBase||n.data.Model;l.fields&&o(l.fields,function(e,r){i(r)&&r.field?n.isFunction(r.field)||(r=s(r,{field:t.getter(r.field)})):r={field:t.getter(r)},l.fields[e]=r});var h=l.id;if(h){var g={};g[t.xpathToMember(h,!0)]={field:t.getter(h)},l.fields=s(g,l.fields),l.id=t.xpathToMember(h)}l=m.define(l)}t.model=l}if(c&&(typeof c==`string`?(c=t.getter(c),t.total=function(e){return parseInt(c(e),10)}):typeof c==`function`&&(t.total=c)),d&&(typeof d==`string`?(d=t.getter(d),t.errors=function(e){return d(e)||null}):typeof d==`function`&&(t.errors=d)),p&&(typeof p==`string`?(p=t.xpathToMember(p),t.data=function(e){var n=t.evaluate(e,p),i;return n=r(n)?n:[n],t.model&&l.fields?(i=new t.model,a(n,function(e){if(e){var t={},n;for(n in l.fields)t[n]=i._parse(n,l.fields[n].field(e));return t}})):n}):typeof p==`function`&&(t.data=p)),typeof u==`function`){var _=t.parse;t.parse=function(e){var n=u.call(t,e);return _.call(t,n)}}typeof f==`function`&&(t.serialize=f)},total:function(e){return this.data(e).length},errors:function(e){return e?e.errors:null},serialize:function(e){return e},parseDOM:function(e){var n={},i,a,o,s,c,l,u=e.attributes,d=u.length,f;for(f=0;f<d;f++)l=u[f],n[`@`+l.nodeName]=l.nodeValue;for(a=e.firstChild;a;a=a.nextSibling)o=a.nodeType,o===3||o===4?n[`#text`]=a.nodeValue:o===1&&(i=this.parseDOM(a),s=a.nodeName,c=n[s],r(c)?c.push(i):c=c===t?i:[c,i],n[s]=c);return n},evaluate:function(e,t){for(var n=t.split(`.`),i,a,o,s,c;i=n.shift();)if(e=e[i],r(e)){for(a=[],t=n.join(`.`),c=0,o=e.length;c<o;c++)s=this.evaluate(e[c],t),s=r(s)?s:[s],a.push.apply(a,s);return a}return e},parse:function(t){var n,r,i={};return n=t.documentElement||e.parseXML(t).documentElement,r=this.parseDOM(n),i[n.nodeName]=r,i},xpathToMember:function(e,t){return e?(e=e.replace(/^\//,``).replace(/\//g,`.`),e.indexOf(`@`)>=0?e.replace(/\.?(@.*)/,t?`$1`:`["$1"]`):e.indexOf(`text()`)>=0?e.replace(/(\.?text\(\))/,t?`#text`:`["#text"]`):e):``},getter:function(e){return c(this.xpathToMember(e),!0)}});e.extend(!0,n.data,{XmlDataReader:l,readers:{xml:l}})})(window.kendo.jQuery);var r=kendo;e.__meta__=n,e.default=r});
//# sourceMappingURL=kendo.data.xml.min.js.map