//>>built
define("dojox/wire/ml/util",["dojo","dijit","dojox","dojo/require!dojox/xml/parser,dojox/wire/Wire"],function(f,l,g){f.provide("dojox.wire.ml.util");f.require("dojox.xml.parser");f.require("dojox.wire.Wire");g.wire.ml._getValue=function(a,b){if(a){var c=void 0;if(b&&9<=a.length&&"arguments"==a.substring(0,9))return c=a.substring(9),(new g.wire.Wire({property:c})).getValue(b);var d=a.indexOf(".");0<=d&&(c=a.substring(d+1),a=a.substring(0,d));if(d=l.byId(a)||f.byId(a)||f.getObject(a))return c?(new g.wire.Wire({object:d,
property:c})).getValue():d}};g.wire.ml._setValue=function(a,b){if(a){var c=a.indexOf(".");if(!(0>c)){var d=this._getValue(a.substring(0,c));d&&(c=a.substring(c+1),(new g.wire.Wire({object:d,property:c})).setValue(b))}}};f.declare("dojox.wire.ml.XmlElement",null,{constructor:function(a){f.isString(a)&&(a=this._getDocument().createElement(a));this.element=a},getPropertyValue:function(a){var b=void 0;if(!this.element||!a)return b;if("@"==a.charAt(0))b=a.substring(1),b=this.element.getAttribute(b);else if("text()"==
a){if(a=this.element.firstChild)b=a.nodeValue}else{for(var c=[],d=0;d<this.element.childNodes.length;d++){var e=this.element.childNodes[d];1===e.nodeType&&e.nodeName==a&&c.push(new g.wire.ml.XmlElement(e))}0<c.length&&(b=1===c.length?c[0]:c)}return b},setPropertyValue:function(a,b){var c;if(this.element&&a)if("@"==a.charAt(0)){var d=a.substring(1);b?this.element.setAttribute(d,b):this.element.removeAttribute(d)}else if("text()"==a){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);
b&&(c=this._getDocument().createTextNode(b),this.element.appendChild(c))}else{var d=null,e;for(c=this.element.childNodes.length-1;0<=c;c--)e=this.element.childNodes[c],1===e.nodeType&&e.nodeName==a&&(d||(d=e.nextSibling),this.element.removeChild(e));if(b)if(f.isArray(b))for(c in b)e=b[c],e.element&&this.element.insertBefore(e.element,d);else b instanceof g.wire.ml.XmlElement?b.element&&this.element.insertBefore(b.element,d):(e=this._getDocument().createElement(a),c=this._getDocument().createTextNode(b),
e.appendChild(c),this.element.insertBefore(e,d))}},toString:function(){var a="";if(this.element){var b=this.element.firstChild;b&&(a=b.nodeValue)}return a},toObject:function(){if(!this.element)return null;var a="",b={},c=0,d;for(d=0;d<this.element.childNodes.length;d++){var e=this.element.childNodes[d];if(1===e.nodeType){c++;var h=(new g.wire.ml.XmlElement(e)).toObject(),e=e.nodeName,k=b[e];k?f.isArray(k)?k.push(h):b[e]=[k,h]:b[e]=h}else if(3===e.nodeType||4===e.nodeType)a+=e.nodeValue}h=0;if(1===
this.element.nodeType)for(h=this.element.attributes.length,d=0;d<h;d++)e=this.element.attributes[d],b["@"+e.nodeName]=e.nodeValue;if(0===c){if(0===h)return a;b["text()"]=a}return b},_getDocument:function(){return this.element?9==this.element.nodeType?this.element:this.element.ownerDocument:g.xml.parser.parse()}})});