(function(){u8.Base.XmlDataSource=function(t){$.extend(this,u8.Base.XmlDataSource.defaults,t);this._checkParent();if(!this.xpathPrefix.endsWith("/")){this.xpathPrefix+="/"}this.bind()};u8.Base.XmlDataSource.makeClass({name:"XmlDataSource",events:["PropertyChange"]});u8.Base.XmlDataSource.defaults={xpathPrefix:""};$.extend(u8.Base.XmlDataSource.prototype,{get:function(e){var r=this.mapping[e];if(!r){$error("No such property: "+e)}var i=$(this.xml);var a=undefined;if(typeof r=="string"){var s=i.xpath(this.xpathPrefix+r);if(s&&s[0]){a=s[0][t(s[0])]}}else{for(var n=0;n<r.length;n++){var o=r[n];s=i.xpath(this.xpathPrefix+o.xpath);if(s&&s[0]&&s[0][t(s[0])]==o.activeValue){a=o.value}}}return a},set:function(e,r){var i=this.mapping[e];if(!i){$error("No such property: "+e)}var a=$(this.xml);if(typeof i=="string"){var s=a.xpath(this.xpathPrefix+i);if(s&&s[0]){s[0][t(s[0])]=""+r}}else{for(var n=0;n<i.length;n++){var o=i[n];s=a.xpath(this.xpathPrefix+o.xpath);if(s&&s[0]){s[t(s[0])]=r==o.value?""+o.activeValue:""+o.inactiveValue}}}this.raise("PropertyChange",{propertyName:e,value:r})},getProperties:function(){var t={};for(var e in this.mapping){t[e]=this.get(e)}return t},setProperties:function(t){for(var e in t){this.set(e,t[e])}},dispose:function(){if(this._isDisposed){return}if(this._properties){this._properties.dispose();this._properties=null}this._xml=null;this.unbind()},_checkParent:function(){var t=this.parent;if(!t||!u8.tools.isInstanceOfClass(t,"Form")){return}var e=u8.Base.Widgets.Tools.closest(t.parent,"Form");if(!e){return}var r=e.getWidgetId(t);if(!r){return}var i=e.context;if(!i||!u8.tools.isInstanceOfClass(i,"XmlDataSource")){return}this.xpathPrefix=i.xpathPrefix+(i.subContexts&&i.subContexts[r]||"");this.xml=i.xml}});function t(t){if(t.nodeType==2){return"value"}else{return"textContent"}}})();