dataschema-xml-min.js revision 1fad80225c335240e31e0350a65463a0bd7a9b1a
YUI.add("dataschema-xml",function(c){var b=c.Lang,a={apply:function(f,g){var d=g,e={results:[],meta:{}};if(d&&d.nodeType&&(9===d.nodeType||1===d.nodeType||11===d.nodeType)&&f){e=a._parseResults.call(this,f,d,e);e=a._parseMeta.call(this,f.metaFields,d,e);}else{e.error=new Error("XML schema parse failure");}return e;},_getLocationValue:function(l,i){var g=l.locator||l.key||l,f=i.ownerDocument||i,d,h,j=null;try{d=a._getXPathResult(g,i,f);while(h=d.iterateNext()){j=h.textContent||h.value||h.text||h.innerHTML||null;}return c.DataSchema.Base.parse.call(this,j,l);}catch(k){}return null;},_getXPathResult:function(k,f,s){if(!b.isUndefined(s.evaluate)){return s.evaluate(k,f,s.createNSResolver(f.ownerDocument?f.ownerDocument.documentElement:f.documentElement),0,null);}else{var p=[],r=k.split(/\b\/\b/),j=0,h=r.length,o,d,g,q;try{s.setProperty("SelectionLanguage","XPath");p=f.selectNodes(k);}catch(n){for(;j<h&&f;j++){o=r[j];if((o.indexOf("[")>-1)&&(o.indexOf("]")>-1)){d=o.slice(o.indexOf("[")+1,o.indexOf("]"));d--;f=f.children[d];q=true;}else{if(o.indexOf("@")>-1){d=o.substr(o.indexOf("@"));f=d?f.getAttribute(d.replace("@","")):f;}else{if(-1<o.indexOf("//")){d=f.getElementsByTagName(o.substr(2));f=d.length?d[d.length-1]:null;}else{if(h!=j+1){for(g=f.childNodes.length-1;0<=g;g-=1){if(o===f.childNodes[g].tagName){f=f.childNodes[g];g=-1;}}}}}}}if(f){if(b.isString(f)){p[0]={value:f};}else{if(q){p[0]={value:f.innerHTML};}else{p=c.Array(f.childNodes,0,true);}}}}return{index:0,iterateNext:function(){if(this.index>=this.values.length){return undefined;}var e=this.values[this.index];this.index+=1;return e;},values:p};}},_parseField:function(f,d,e){if(f.schema){d[f.key]=a._parseResults.call(this,f.schema,e,{results:[],meta:{}}).results;}else{d[f.key||f]=a._getLocationValue.call(this,f,e);}},_parseMeta:function(h,g,f){if(b.isObject(h)){var e,d=g.ownerDocument||g;for(e in h){if(h.hasOwnProperty(e)){f.meta[e]=a._getLocationValue.call(this,h[e],d);}}}return f;},_parseResult:function(e,g){var d={},f;for(f=e.length-1;0<=f;f--){a._parseField.call(this,e[f],d,g);}return d;},_parseResults:function(g,d,h){if(g.resultListLocator&&b.isArray(g.resultFields)){var m=d.ownerDocument||d,l=g.resultFields,k=[],e,n,f,j=0;if(g.resultListLocator.match(/^[:\-\w]+$/)){f=d.getElementsByTagName(g.resultListLocator);for(j=f.length-1;0<=j;j--){k[j]=a._parseResult.call(this,l,f[j]);}}else{f=a._getXPathResult(g.resultListLocator,d,m);while(e=f.iterateNext()){k[j]=a._parseResult.call(this,l,e);j+=1;}}if(k.length){h.results=k;}else{h.error=new Error("XML schema result nodes retrieval failure");}}return h;}};c.DataSchema.XML=c.mix(a,c.DataSchema.Base);},"@VERSION@",{requires:["dataschema-base"]});