(function(A){A.xslt=function(B){var C={xml:null,xmlUrl:null,xmlCache:true,xsl:null,xslUrl:null,xslCache:true,callback:null,target:null,dataTypeXML:false,error:false};A.extend(C,B);C.async=((C.callback!=null)||(C.target!=null));C.finish=function(E){if((E.xml!=null)&&(E.xsl!=null)&&(E.error==false)){if((E.xml!==null)&&(typeof (E.xml)!="object")){E.xml=A.xslt.textToXML(E.xml)}if((E.xsl!==null)&&(typeof (E.xsl)!="object")){E.xsl=A.xslt.textToXML(E.xsl)}var D=xsltProcess(E.xml,E.xsl);if(E.callback!=null){E.callback(D)}if(E.target!=null){A(E.target).html(D)}return D}else{if(E.error){if(E.callback!=null){E.callback(false)}return false}else{return true}}};if(((C.xml==null)&&(C.xmlUrl==null))||((C.xsl==null)&&(C.xslUrl==null))){C.error=true;return C.finish(C)}if((C.xml==null)&&(C.xmlUrl!=null)&&(C.xmlCache==true)&&(A.xslt.cache.xml[C.xmlUrl])){C.xml=A.xslt.cache.xml[C.xmlUrl]}if((C.xsl==null)&&(C.xslUrl!=null)&&(C.xslCache==true)&&(A.xslt.cache.xsl[C.xslUrl])){C.xsl=A.xslt.cache.xsl[C.xslUrl]}if((C.xmlUrl!=null)&&(C.xml==null)){A.ajax({url:C.xmlUrl,dataType:C.dataTypeXML?"xml":"html",error:function(){C.error=true;C.finish(C)},success:function(D){C.xml=D;if(C.xmlCache){A.xslt.cache.xml[C.xmlUrl]=C.dataTypeXML?D:A.xslt.textToXML(D)}C.finish(C)},async:C.async})}if((C.xslUrl!=null)&&(C.xsl==null)){A.ajax({url:C.xslUrl,dataType:C.dataTypeXML?"xml":"html",error:function(){C.error=true;C.finish(C)},success:function(D){C.xsl=D;if(C.xslCache){A.xslt.cache.xsl[C.xslUrl]=C.dataTypeXML?D:A.xslt.textToXML(D)}C.finish(C)},async:C.async})}return C.finish(C)};A.extend(A.xslt,{version:{plugin:0.7,ajaxslt:0.7},textToXML:function(B){return xmlParse(B)},xmlToText:function(B){return xmlText(B)},cache:{xml:{},xsl:{}}});A.fn.xslt=function(B){B.target=this;A.xslt(B);return this}})(jQuery);function xpathLog(A){}function xsltLog(A){}function xsltLogXml(A){}function assert(A){if(!A){throw"Assertion failed"}}function stringSplit(C,E){var B=C.indexOf(E);if(B==-1){return[C]}var D=[];D.push(C.substr(0,B));while(B!=-1){var A=C.indexOf(E,B+1);if(A!=-1){D.push(C.substr(B+1,A-B-1))}else{D.push(C.substr(B+1))}B=A}return D}function xmlImportNode(G,B){if(B.nodeType==DOM_TEXT_NODE){return domCreateTextNode(G,B.nodeValue)}else{if(B.nodeType==DOM_CDATA_SECTION_NODE){return domCreateCDATASection(G,B.nodeValue)}else{if(B.nodeType==DOM_ELEMENT_NODE){var I=domCreateElement(G,B.nodeName);for(var C=0;C<B.attributes.length;++C){var D=B.attributes[C];var A=D.nodeName;var H=D.nodeValue;domSetAttribute(I,A,H)}for(var E=B.firstChild;E;E=E.nextSibling){var F=arguments.callee(G,E);domAppendChild(I,F)}return I}else{return domCreateComment(G,B.nodeName)}}}}function Set(){this.keys=[]}Set.prototype.size=function(){return this.keys.length};Set.prototype.add=function(B,A){var C=A||1;if(!this.contains(B)){this[":"+B]=C;this.keys.push(B)}};Set.prototype.set=function(B,A){var C=A||1;if(!this.contains(B)){this[":"+B]=C;this.keys.push(B)}else{this[":"+B]=C}};Set.prototype.inc=function(A){if(!this.contains(A)){this[":"+A]=1;this.keys.push(A)}else{this[":"+A]++}};Set.prototype.get=function(A){if(this.contains(A)){return this[":"+A]}else{var B;return B}};Set.prototype.remove=function(A){if(this.contains(A)){delete this[":"+A];removeFromArray(this.keys,A,true)}};Set.prototype.contains=function(A){return typeof this[":"+A]!="undefined"};Set.prototype.items=function(){var D=[];for(var C=0;C<this.keys.length;++C){var B=this.keys[C];var A=this[":"+B];D.push(A)}return D};Set.prototype.map=function(C){for(var B=0;B<this.keys.length;++B){var A=this.keys[B];C.call(this,A,this[":"+A])}};Set.prototype.clear=function(){for(var A=0;A<this.keys.length;++A){delete this[":"+this.keys[A]]}this.keys.length=0};function mapExec(C,B){for(var A=0;A<C.length;++A){B.call(this,C[A],A)}}function mapExpr(D,C){var A=[];for(var B=0;B<D.length;++B){A.push(C(D[B]))}return A}function reverseInplace(D){for(var A=0;A<D.length/2;++A){var C=D[A];var B=D.length-A-1;D[A]=D[B];D[B]=C}}function removeFromArray(E,C,D){var A=0;for(var B=0;B<E.length;++B){if(E[B]===C||(D&&E[B]==C)){E.splice(B--,1);A++}}return A}function copyArray(C,B){for(var A=0;A<B.length;++A){C.push(B[A])}}function xmlValue(C){if(!C){return""}var A="";if(C.nodeType==DOM_TEXT_NODE||C.nodeType==DOM_CDATA_SECTION_NODE||C.nodeType==DOM_ATTRIBUTE_NODE){A+=C.nodeValue}else{if(C.nodeType==DOM_ELEMENT_NODE||C.nodeType==DOM_DOCUMENT_NODE||C.nodeType==DOM_DOCUMENT_FRAGMENT_NODE){for(var B=0;B<C.childNodes.length;++B){A+=arguments.callee(C.childNodes[B])}}}return A}function xmlText(C,A){var B=[];xmlTextR(C,B,A);return B.join("")}function xmlTextR(D,B,E){if(D.nodeType==DOM_TEXT_NODE){B.push(xmlEscapeText(D.nodeValue))}else{if(D.nodeType==DOM_CDATA_SECTION_NODE){if(E){B.push(D.nodeValue)}else{B.push("<![CDATA["+D.nodeValue+"]]>")}}else{if(D.nodeType==DOM_COMMENT_NODE){B.push("<!--"+D.nodeValue+"-->")}else{if(D.nodeType==DOM_ELEMENT_NODE){B.push("<"+xmlFullNodeName(D));for(var C=0;C<D.attributes.length;++C){var A=D.attributes[C];if(A&&A.nodeName&&A.nodeValue){B.push(" "+xmlFullNodeName(A)+'="'+xmlEscapeAttr(A.nodeValue)+'"')}}if(D.childNodes.length==0){B.push("/>")}else{B.push(">");for(var C=0;C<D.childNodes.length;++C){arguments.callee(D.childNodes[C],B,E)}B.push("</"+xmlFullNodeName(D)+">")}}else{if(D.nodeType==DOM_DOCUMENT_NODE||D.nodeType==DOM_DOCUMENT_FRAGMENT_NODE){for(var C=0;C<D.childNodes.length;++C){arguments.callee(D.childNodes[C],B,E)}}}}}}}function xmlFullNodeName(A){if(A.prefix&&A.nodeName.indexOf(A.prefix+":")!=0){return A.prefix+":"+A.nodeName}else{return A.nodeName}}function xmlEscapeText(A){return(""+A).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xmlEscapeAttr(A){return xmlEscapeText(A).replace(/\"/g,"&quot;")}function xmlEscapeTags(A){return A.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xmlOwnerDocument(A){if(A.nodeType==DOM_DOCUMENT_NODE){return A}else{return A.ownerDocument}}function domGetAttribute(B,A){return B.getAttribute(A)}function domSetAttribute(B,A,C){return B.setAttribute(A,C)}function domRemoveAttribute(B,A){return B.removeAttribute(A)}function domAppendChild(A,B){return A.appendChild(B)}function domRemoveChild(A,B){return A.removeChild(B)}function domReplaceChild(C,A,B){return C.replaceChild(A,B)}function domInsertBefore(C,A,B){return C.insertBefore(A,B)}function domRemoveNode(A){return domRemoveChild(A.parentNode,A)}function domCreateTextNode(A,B){return A.createTextNode(B)}function domCreateElement(B,A){return B.createElement(A)}function domCreateAttribute(B,A){return B.createAttribute(A)}function domCreateCDATASection(B,A){return B.createCDATASection(A)}function domCreateComment(A,B){return A.createComment(B)}function domCreateDocumentFragment(A){return A.createDocumentFragment()}function domGetElementById(A,B){return A.getElementById(B)}function windowSetInterval(C,A,B){return C.setInterval(A,B)}function windowClearInterval(A,B){return A.clearInterval(B)}var REGEXP_UNICODE=function(){var B=[" ","\u0120",-1,"!","\u0120",-1,"\u0120","\u0120",0,"\u0121","\u0120",-1,"\u0121","\u0120|\u0121",0,"\u0122","\u0120|\u0121",-1,"\u0120","[\u0120]",0,"\u0121","[\u0120]",-1,"\u0121","[\u0120\u0121]",0,"\u0122","[\u0120\u0121]",-1,"\u0121","[\u0120-\u0121]",0,"\u0122","[\u0120-\u0121]",-1];for(var A=0;A<B.length;A+=3){if(B[A].search(new RegExp(B[A+1]))!=B[A+2]){return false}}return true}();var XML_S="[ \t\r\n]+";var XML_EQ="("+XML_S+")?=("+XML_S+")?";var XML_CHAR_REF="&#[0-9]+;|&#x[0-9a-fA-F]+;";var XML10_VERSION_INFO=XML_S+"version"+XML_EQ+"(\"1\\.0\"|'1\\.0')";var XML10_BASE_CHAR=(REGEXP_UNICODE)?"\u0041-\u005a\u0061-\u007a\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3":"A-Za-z";var XML10_IDEOGRAPHIC=(REGEXP_UNICODE)?"\u4e00-\u9fa5\u3007\u3021-\u3029":"";var XML10_COMBINING_CHAR=(REGEXP_UNICODE)?"\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a":"";var XML10_DIGIT=(REGEXP_UNICODE)?"\u0030-\u0039\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29":"0-9";var XML10_EXTENDER=(REGEXP_UNICODE)?"\u00b7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035\u309d-\u309e\u30fc-\u30fe":"";var XML10_LETTER=XML10_BASE_CHAR+XML10_IDEOGRAPHIC;var XML10_NAME_CHAR=XML10_LETTER+XML10_DIGIT+"\\._:"+XML10_COMBINING_CHAR+XML10_EXTENDER+"-";var XML10_NAME="["+XML10_LETTER+"_:]["+XML10_NAME_CHAR+"]*";var XML10_ENTITY_REF="&"+XML10_NAME+";";var XML10_REFERENCE=XML10_ENTITY_REF+"|"+XML_CHAR_REF;var XML10_ATT_VALUE='"(([^<&"]|'+XML10_REFERENCE+")*)\"|'(([^<&']|"+XML10_REFERENCE+")*)'";var XML10_ATTRIBUTE="("+XML10_NAME+")"+XML_EQ+"("+XML10_ATT_VALUE+")";var XML11_VERSION_INFO=XML_S+"version"+XML_EQ+"(\"1\\.1\"|'1\\.1')";var XML11_NAME_START_CHAR=(REGEXP_UNICODE)?":A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd":":A-Z_a-z";var XML11_NAME_CHAR=XML11_NAME_START_CHAR+((REGEXP_UNICODE)?"\\.0-9\u00b7\u0300-\u036f\u203f-\u2040-":"\\.0-9-");var XML11_NAME="["+XML11_NAME_START_CHAR+"]["+XML11_NAME_CHAR+"]*";var XML11_ENTITY_REF="&"+XML11_NAME+";";var XML11_REFERENCE=XML11_ENTITY_REF+"|"+XML_CHAR_REF;var XML11_ATT_VALUE='"(([^<&"]|'+XML11_REFERENCE+")*)\"|'(([^<&']|"+XML11_REFERENCE+")*)'";var XML11_ATTRIBUTE="("+XML11_NAME+")"+XML_EQ+"("+XML11_ATT_VALUE+")";var XML_NC_NAME_CHAR=XML10_LETTER+XML10_DIGIT+"\\._"+XML10_COMBINING_CHAR+XML10_EXTENDER+"-";var XML_NC_NAME="["+XML10_LETTER+"_]["+XML_NC_NAME_CHAR+"]*";function xmlResolveEntities(I){var B=stringSplit(I,"&");var F=B[0];for(var C=1;C<B.length;++C){var D=B[C].indexOf(";");if(D==-1){F+=B[C];continue}var G=B[C].substring(0,D);var E=B[C].substring(D+1);var A;switch(G){case"lt":A="<";break;case"gt":A=">";break;case"amp":A="&";break;case"quot":A='"';break;case"apos":A="'";break;case"nbsp":A=String.fromCharCode(160);break;default:var H=domCreateElement(window.document,"span");H.innerHTML="&"+G+"; ";A=H.childNodes[0].nodeValue.charAt(0)}F+=A+E}return F}var XML10_TAGNAME_REGEXP=new RegExp("^("+XML10_NAME+")");var XML10_ATTRIBUTE_REGEXP=new RegExp(XML10_ATTRIBUTE,"g");var XML11_TAGNAME_REGEXP=new RegExp("^("+XML11_NAME+")");var XML11_ATTRIBUTE_REGEXP=new RegExp(XML11_ATTRIBUTE,"g");function xmlParse(C){var I=/\/$/;var R;var H;if(C.match(/^<\?xml/)){if(C.search(new RegExp(XML10_VERSION_INFO))==5){R=XML10_TAGNAME_REGEXP;H=XML10_ATTRIBUTE_REGEXP}else{if(C.search(new RegExp(XML11_VERSION_INFO))==5){R=XML11_TAGNAME_REGEXP;H=XML11_ATTRIBUTE_REGEXP}else{alert("VersionInfo is missing, or unknown version number.")}}}else{R=XML10_TAGNAME_REGEXP;H=XML10_ATTRIBUTE_REGEXP}var A=new XDocument();var P=A;var G=[];var K=P;G.push(K);var B="";var L=stringSplit(C,"<");for(var Q=1;Q<L.length;++Q){var F=stringSplit(L[Q],">");var V=F[0];var M=xmlResolveEntities(F[1]||"");if(B){var D=L[Q].indexOf(B);if(D!=-1){var T=L[Q].substring(0,D);K.nodeValue+="<"+T;G.pop();K=G[G.length-1];M=L[Q].substring(D+B.length);B=""}else{K.nodeValue+="<"+L[Q];M=null}}else{if(V.indexOf("![CDATA[")==0){var E="![CDATA[".length;var D=L[Q].indexOf("]]>");if(D!=-1){var T=L[Q].substring(E,D);var O=domCreateCDATASection(A,T);domAppendChild(K,O)}else{var T=L[Q].substring(E);M=null;var O=domCreateCDATASection(A,T);domAppendChild(K,O);K=O;G.push(O);B="]]>"}}else{if(V.indexOf("!--")==0){var E="!--".length;var D=L[Q].indexOf("-->");if(D!=-1){var T=L[Q].substring(E,D);var O=domCreateComment(A,T);domAppendChild(K,O)}else{var T=L[Q].substring(E);M=null;var O=domCreateComment(A,T);domAppendChild(K,O);K=O;G.push(O);B="-->"}}else{if(V.charAt(0)=="/"){G.pop();K=G[G.length-1]}else{if(V.charAt(0)=="?"){}else{if(V.charAt(0)=="!"){}else{var J=V.match(I);var S=R.exec(V)[1];var O=domCreateElement(A,S);var N;while(N=H.exec(V)){var U=xmlResolveEntities(N[5]||N[7]||"");domSetAttribute(O,N[1],U)}domAppendChild(K,O);if(!J){K=O;G.push(O)}}}}}}}if(M&&K!=P){domAppendChild(K,domCreateTextNode(A,M))}}return P}var DOM_ELEMENT_NODE=1;var DOM_ATTRIBUTE_NODE=2;var DOM_TEXT_NODE=3;var DOM_CDATA_SECTION_NODE=4;var DOM_ENTITY_REFERENCE_NODE=5;var DOM_ENTITY_NODE=6;var DOM_PROCESSING_INSTRUCTION_NODE=7;var DOM_COMMENT_NODE=8;var DOM_DOCUMENT_NODE=9;var DOM_DOCUMENT_TYPE_NODE=10;var DOM_DOCUMENT_FRAGMENT_NODE=11;var DOM_NOTATION_NODE=12;function domTraverseElements(B,C,D){var A;if(C){A=C.call(null,B);if(typeof A=="boolean"&&!A){return false}}for(var E=B.firstChild;E;E=E.nextSibling){if(E.nodeType==DOM_ELEMENT_NODE){A=arguments.callee.call(this,E,C,D);if(typeof A=="boolean"&&!A){return false}}}if(D){A=D.call(null,B);if(typeof A=="boolean"&&!A){return false}}}function XNode(C,B,A,D){this.attributes=[];this.childNodes=[];XNode.init.call(this,C,B,A,D)}XNode.init=function(C,B,D,A){this.nodeType=C-0;this.nodeName=""+B;this.nodeValue=""+D;this.ownerDocument=A;this.firstChild=null;this.lastChild=null;this.nextSibling=null;this.previousSibling=null;this.parentNode=null};XNode.unused_=[];XNode.recycle=function(B){if(!B){return }if(B.constructor==XDocument){XNode.recycle(B.documentElement);return }if(B.constructor!=this){return }XNode.unused_.push(B);for(var A=0;A<B.attributes.length;++A){XNode.recycle(B.attributes[A])}for(var C=0;C<B.childNodes.length;++C){XNode.recycle(B.childNodes[C])}B.attributes.length=0;B.childNodes.length=0;XNode.init.call(B,0,"","",null)};XNode.create=function(C,B,E,A){if(XNode.unused_.length>0){var D=XNode.unused_.pop();XNode.init.call(D,C,B,E,A);return D}else{return new XNode(C,B,E,A)}};XNode.prototype.appendChild=function(A){if(this.childNodes.length==0){this.firstChild=A}A.previousSibling=this.lastChild;A.nextSibling=null;if(this.lastChild){this.lastChild.nextSibling=A}A.parentNode=this;this.lastChild=A;this.childNodes.push(A)};XNode.prototype.replaceChild=function(B,D){if(D==B){return }for(var A=0;A<this.childNodes.length;++A){if(this.childNodes[A]==D){this.childNodes[A]=B;var C=D.parentNode;D.parentNode=null;B.parentNode=C;C=D.previousSibling;D.previousSibling=null;B.previousSibling=C;if(B.previousSibling){B.previousSibling.nextSibling=B}C=D.nextSibling;D.nextSibling=null;B.nextSibling=C;if(B.nextSibling){B.nextSibling.previousSibling=B}if(this.firstChild==D){this.firstChild=B}if(this.lastChild==D){this.lastChild=B}break}}};XNode.prototype.insertBefore=function(B,C){if(C==B){return }if(C.parentNode!=this){return }if(B.parentNode){B.parentNode.removeChild(B)}var E=[];for(var A=0;A<this.childNodes.length;++A){var D=this.childNodes[A];if(D==C){E.push(B);B.parentNode=this;B.previousSibling=C.previousSibling;C.previousSibling=B;if(B.previousSibling){B.previousSibling.nextSibling=B}B.nextSibling=C;if(this.firstChild==C){this.firstChild=B}}E.push(D)}this.childNodes=E};XNode.prototype.removeChild=function(B){var D=[];for(var A=0;A<this.childNodes.length;++A){var C=this.childNodes[A];if(C!=B){D.push(C)}else{if(C.previousSibling){C.previousSibling.nextSibling=C.nextSibling}if(C.nextSibling){C.nextSibling.previousSibling=C.previousSibling}if(this.firstChild==C){this.firstChild=C.nextSibling}if(this.lastChild==C){this.lastChild=C.previousSibling}}}this.childNodes=D};XNode.prototype.hasAttributes=function(){return this.attributes.length>0};XNode.prototype.setAttribute=function(A,C){for(var B=0;B<this.attributes.length;++B){if(this.attributes[B].nodeName==A){this.attributes[B].nodeValue=""+C;return }}this.attributes.push(XNode.create(DOM_ATTRIBUTE_NODE,A,C,this))};XNode.prototype.getAttribute=function(A){for(var B=0;B<this.attributes.length;++B){if(this.attributes[B].nodeName==A){return this.attributes[B].nodeValue}}return null};XNode.prototype.removeAttribute=function(B){var A=[];for(var C=0;C<this.attributes.length;++C){if(this.attributes[C].nodeName!=B){A.push(this.attributes[C])}}this.attributes=A};XNode.prototype.getElementsByTagName=function(B){var A=[];domTraverseElements(this,function(C){if(C.nodeName==B){A.push(C)}},null);return A};XNode.prototype.getElementById=function(B){var A=null;domTraverseElements(this,function(C){if(C.getAttribute("id")==B){A=C;return false}},null);return A};function XDocument(){XNode.call(this,DOM_DOCUMENT_NODE,"#document",null,null);this.documentElement=null}XDocument.prototype=new XNode(DOM_DOCUMENT_NODE,"#document");XDocument.prototype.clear=function(){XNode.recycle(this.documentElement);this.documentElement=null};XDocument.prototype.appendChild=function(A){XNode.prototype.appendChild.call(this,A);this.documentElement=this.childNodes[0]};XDocument.prototype.createElement=function(A){return XNode.create(DOM_ELEMENT_NODE,A,null,this)};XDocument.prototype.createDocumentFragment=function(){return XNode.create(DOM_DOCUMENT_FRAGMENT_NODE,"#document-fragment",null,this)};XDocument.prototype.createTextNode=function(A){return XNode.create(DOM_TEXT_NODE,"#text",A,this)};XDocument.prototype.createAttribute=function(A){return XNode.create(DOM_ATTRIBUTE_NODE,A,null,this)};XDocument.prototype.createComment=function(A){return XNode.create(DOM_COMMENT_NODE,"#comment",A,this)};XDocument.prototype.createCDATASection=function(A){return XNode.create(DOM_CDATA_SECTION_NODE,"#cdata-section",A,this)};function xpathParse(M){xpathLog("parse "+M);xpathParseInit();var A=xpathCacheLookup(M);if(A){xpathLog(" ... cached");return A}if(M.match(/^(\$|@)?\w+$/i)){var I=makeSimpleExpr(M);xpathParseCache[M]=I;xpathLog(" ... simple");return I}if(M.match(/^\w+(\/\w+)*$/i)){var I=makeSimpleExpr2(M);xpathParseCache[M]=I;xpathLog(" ... simple 2");return I}var J=M;var L=[];var B=null;var G=null;var C=false;var H=0;var F=0;var O=0;while(!C){H++;M=M.replace(/^\s*/,"");G=B;B=null;var K=null;var E="";for(var D=0;D<xpathTokenRules.length;++D){var N=xpathTokenRules[D].re.exec(M);F++;if(N&&N.length>0&&N[0].length>E.length){K=xpathTokenRules[D];E=N[0];break}}if(K&&(K==TOK_DIV||K==TOK_MOD||K==TOK_AND||K==TOK_OR)&&(!G||G.tag==TOK_AT||G.tag==TOK_DSLASH||G.tag==TOK_SLASH||G.tag==TOK_AXIS||G.tag==TOK_DOLLAR)){K=TOK_QNAME}if(K){M=M.substr(E.length);xpathLog("token: "+E+" -- "+K.label);B={tag:K,match:E,prec:K.prec?K.prec:0,expr:makeTokenExpr(E)}}else{xpathLog("DONE");C=true}while(xpathReduce(L,B)){O++;xpathLog("stack: "+stackToString(L))}}xpathLog("stack: "+stackToString(L));if(L.length!=1){throw"XPath parse error "+J+":\n"+stackToString(L)}var N=L[0].expr;xpathParseCache[J]=N;xpathLog("XPath parse: "+H+" / "+F+" / "+O);return N}var xpathParseCache={};function xpathCacheLookup(A){return xpathParseCache[A]}function xpathReduce(H,A){var E=null;if(H.length>0){var F=H[H.length-1];var I=xpathRules[F.tag.key];if(I){for(var B=0;B<I.length;++B){var G=I[B];var C=xpathMatchStack(H,G[1]);if(C.length){E={tag:G[0],rule:G,match:C};E.prec=xpathGrammarPrecedence(E);break}}}}var D;if(E&&(!A||E.prec>A.prec||(A.tag.left&&E.prec>=A.prec))){for(var B=0;B<E.match.matchlength;++B){H.pop()}xpathLog("reduce "+E.tag.label+" "+E.prec+" ahead "+(A?A.tag.label+" "+A.prec+(A.tag.left?" left":""):" none "));var J=mapExpr(E.match,function(K){return K.expr});E.expr=E.rule[3].apply(null,J);H.push(E);D=true}else{if(A){xpathLog("shift "+A.tag.label+" "+A.prec+(A.tag.left?" left":"")+" over "+(E?E.tag.label+" "+E.prec:" none"));H.push(A)}D=false}return D}function xpathMatchStack(H,G){var D=H.length;var F=G.length;var B,I;var E=[];E.matchlength=0;var C=0;for(B=F-1,I=D-1;B>=0&&I>=0;--B,I-=C){C=0;var A=[];if(G[B]==Q_MM){B-=1;E.push(A);while(I-C>=0&&H[I-C].tag==G[B]){A.push(H[I-C]);C+=1;E.matchlength+=1}}else{if(G[B]==Q_01){B-=1;E.push(A);while(I-C>=0&&C<2&&H[I-C].tag==G[B]){A.push(H[I-C]);C+=1;E.matchlength+=1}}else{if(G[B]==Q_1M){B-=1;E.push(A);if(H[I].tag==G[B]){while(I-C>=0&&H[I-C].tag==G[B]){A.push(H[I-C]);C+=1;E.matchlength+=1}}else{return[]}}else{if(H[I].tag==G[B]){E.push(H[I]);C+=1;E.matchlength+=1}else{return[]}}}}reverseInplace(A);A.expr=mapExpr(A,function(J){return J.expr})}reverseInplace(E);if(B==-1){return E}else{return[]}}function xpathTokenPrecedence(A){return A.prec||2}function xpathGrammarPrecedence(E){var B=0;if(E.rule){if(E.rule.length>=3&&E.rule[2]>=0){B=E.rule[2]}else{for(var C=0;C<E.rule[1].length;++C){var D=xpathTokenPrecedence(E.rule[1][C]);B=Math.max(B,D)}}}else{if(E.tag){B=xpathTokenPrecedence(E.tag)}else{if(E.length){for(var A=0;A<E.length;++A){var D=xpathGrammarPrecedence(E[A]);B=Math.max(B,D)}}}}return B}function stackToString(A){var B="";for(var C=0;C<A.length;++C){if(B){B+="\n"}B+=A[C].tag.label}return B}function ExprContext(C,A,D,B){this.node=C;this.position=A||0;this.nodelist=D||[C];this.variables={};this.parent=B||null;if(B){this.root=B.root}else{if(this.node.nodeType==DOM_DOCUMENT_NODE){this.root=C}else{this.root=C.ownerDocument}}}ExprContext.prototype.clone=function(C,A,B){return new ExprContext(C||this.node,typeof A!="undefined"?A:this.position,B||this.nodelist,this)};ExprContext.prototype.setVariable=function(A,B){this.variables[A]=B};ExprContext.prototype.getVariable=function(A){if(typeof this.variables[A]!="undefined"){return this.variables[A]}else{if(this.parent){return this.parent.getVariable(A)}else{return null}}};ExprContext.prototype.setNode=function(A){this.node=this.nodelist[A];this.position=A};ExprContext.prototype.contextSize=function(){return this.nodelist.length};function StringValue(A){this.value=A;this.type="string"}StringValue.prototype.stringValue=function(){return this.value};StringValue.prototype.booleanValue=function(){return this.value.length>0};StringValue.prototype.numberValue=function(){return this.value-0};StringValue.prototype.nodeSetValue=function(){throw this};function BooleanValue(A){this.value=A;this.type="boolean"}BooleanValue.prototype.stringValue=function(){return""+this.value};BooleanValue.prototype.booleanValue=function(){return this.value};BooleanValue.prototype.numberValue=function(){return this.value?1:0};BooleanValue.prototype.nodeSetValue=function(){throw this};function NumberValue(A){this.value=A;this.type="number"}NumberValue.prototype.stringValue=function(){return""+this.value};NumberValue.prototype.booleanValue=function(){return !!this.value};NumberValue.prototype.numberValue=function(){return this.value-0};NumberValue.prototype.nodeSetValue=function(){throw this};function NodeSetValue(A){this.value=A;this.type="node-set"}NodeSetValue.prototype.stringValue=function(){if(this.value.length==0){return""}else{return xmlValue(this.value[0])}};NodeSetValue.prototype.booleanValue=function(){return this.value.length>0};NodeSetValue.prototype.numberValue=function(){return this.stringValue()-0};NodeSetValue.prototype.nodeSetValue=function(){return this.value};function TokenExpr(A){this.value=A}TokenExpr.prototype.evaluate=function(){return new StringValue(this.value)};function LocationExpr(){this.absolute=false;this.steps=[]}LocationExpr.prototype.appendStep=function(A){this.steps.push(A)};LocationExpr.prototype.prependStep=function(C){var A=this.steps;this.steps=[C];for(var B=0;B<A.length;++B){this.steps.push(A[B])}};LocationExpr.prototype.evaluate=function(A){var C;if(this.absolute){C=A.root}else{C=A.node}var B=[];xPathStep(B,this.steps,0,C,A);return new NodeSetValue(B)};function xPathStep(A,E,B,F,H){var I=E[B];var D=H.clone(F);var G=I.evaluate(D).nodeSetValue();for(var C=0;C<G.length;++C){if(B==E.length-1){A.push(G[C])}else{xPathStep(A,E,B+1,G[C],H)}}}function StepExpr(B,C,A){this.axis=B;this.nodetest=C;this.predicate=A||[]}StepExpr.prototype.appendPredicate=function(A){this.predicate.push(A)};StepExpr.prototype.evaluate=function(A){var C=A.node;var F=[];if(this.axis==xpathAxis.ANCESTOR_OR_SELF){F.push(C);for(var H=C.parentNode;H;H=H.parentNode){F.push(H)}}else{if(this.axis==xpathAxis.ANCESTOR){for(var H=C.parentNode;H;H=H.parentNode){F.push(H)}}else{if(this.axis==xpathAxis.ATTRIBUTE){copyArray(F,C.attributes)}else{if(this.axis==xpathAxis.CHILD){copyArray(F,C.childNodes)}else{if(this.axis==xpathAxis.DESCENDANT_OR_SELF){F.push(C);xpathCollectDescendants(F,C)}else{if(this.axis==xpathAxis.DESCENDANT){xpathCollectDescendants(F,C)}else{if(this.axis==xpathAxis.FOLLOWING){for(var H=C;H;H=H.parentNode){for(var G=H.nextSibling;G;G=G.nextSibling){F.push(G);xpathCollectDescendants(F,G)}}}else{if(this.axis==xpathAxis.FOLLOWING_SIBLING){for(var H=C.nextSibling;H;H=H.nextSibling){F.push(H)}}else{if(this.axis==xpathAxis.NAMESPACE){alert("not implemented: axis namespace")}else{if(this.axis==xpathAxis.PARENT){if(C.parentNode){F.push(C.parentNode)}}else{if(this.axis==xpathAxis.PRECEDING){for(var H=C;H;H=H.parentNode){for(var G=H.previousSibling;G;G=G.previousSibling){F.push(G);xpathCollectDescendantsReverse(F,G)}}}else{if(this.axis==xpathAxis.PRECEDING_SIBLING){for(var H=C.previousSibling;H;H=H.previousSibling){F.push(H)}}else{if(this.axis==xpathAxis.SELF){F.push(C)}else{throw"ERROR -- NO SUCH AXIS: "+this.axis}}}}}}}}}}}}}var B=F;F=[];for(var D=0;D<B.length;++D){var H=B[D];if(this.nodetest.evaluate(A.clone(H,D,B)).booleanValue()){F.push(H)}}for(var D=0;D<this.predicate.length;++D){var B=F;F=[];for(var E=0;E<B.length;++E){var H=B[E];if(this.predicate[D].evaluate(A.clone(H,E,B)).booleanValue()){F.push(H)}}}return new NodeSetValue(F)};function NodeTestAny(){this.value=new BooleanValue(true)}NodeTestAny.prototype.evaluate=function(A){return this.value};function NodeTestElementOrAttribute(){}NodeTestElementOrAttribute.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_ELEMENT_NODE||A.node.nodeType==DOM_ATTRIBUTE_NODE)};function NodeTestText(){}NodeTestText.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_TEXT_NODE)};function NodeTestComment(){}NodeTestComment.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_COMMENT_NODE)};function NodeTestPI(A){this.target=A}NodeTestPI.prototype.evaluate=function(A){return new BooleanValue(A.node.nodeType==DOM_PROCESSING_INSTRUCTION_NODE&&(!this.target||A.node.nodeName==this.target))};function NodeTestNC(A){this.regex=new RegExp("^"+A+":");this.nsprefix=A}NodeTestNC.prototype.evaluate=function(A){var B=A.node;return new BooleanValue(this.regex.match(B.nodeName))};function NodeTestName(A){this.name=A}NodeTestName.prototype.evaluate=function(A){var B=A.node;return new BooleanValue(B.nodeName==this.name)};function PredicateExpr(A){this.expr=A}PredicateExpr.prototype.evaluate=function(A){var B=this.expr.evaluate(A);if(B.type=="number"){return new BooleanValue(A.position==B.numberValue()-1)}else{return new BooleanValue(B.booleanValue())}};function FunctionCallExpr(A){this.name=A;this.args=[]}FunctionCallExpr.prototype.appendArg=function(A){this.args.push(A)};FunctionCallExpr.prototype.evaluate=function(A){var B=""+this.name.value;var C=this.xpathfunctions[B];if(C){return C.call(this,A)}else{xpathLog("XPath NO SUCH FUNCTION "+B);return new BooleanValue(false)}};FunctionCallExpr.prototype.xpathfunctions={"last":function(A){assert(this.args.length==0);return new NumberValue(A.contextSize())},"position":function(A){assert(this.args.length==0);return new NumberValue(A.position+1)},"count":function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A);return new NumberValue(B.nodeSetValue().length)},"id":function(J){assert(this.args.length==1);var E=this.args[0].evaluate(J);var F=[];var A;if(E.type=="node-set"){A=[];var B=E.nodeSetValue();for(var D=0;D<B.length;++D){var H=xmlValue(B[D]).split(/\s+/);for(var I=0;I<H.length;++I){A.push(H[I])}}}else{A=E.stringValue().split(/\s+/)}var G=J.node.ownerDocument;for(var D=0;D<A.length;++D){var C=G.getElementById(A[D]);if(C){F.push(C)}}return new NodeSetValue(F)},"local-name":function(A){alert("not implmented yet: XPath function local-name()")},"namespace-uri":function(A){alert("not implmented yet: XPath function namespace-uri()")},"name":function(A){assert(this.args.length==1||this.args.length==0);var B;if(this.args.length==0){B=[A.node]}else{B=this.args[0].evaluate(A).nodeSetValue()}if(B.length==0){return new StringValue("")}else{return new StringValue(B[0].nodeName)}},"string":function(A){assert(this.args.length==1||this.args.length==0);if(this.args.length==0){return new StringValue(new NodeSetValue([A.node]).stringValue())}else{return new StringValue(this.args[0].evaluate(A).stringValue())}},"concat":function(A){var B="";for(var C=0;C<this.args.length;++C){B+=this.args[C].evaluate(A).stringValue()}return new StringValue(B)},"starts-with":function(A){assert(this.args.length==2);var C=this.args[0].evaluate(A).stringValue();var B=this.args[1].evaluate(A).stringValue();return new BooleanValue(C.indexOf(B)==0)},"contains":function(A){assert(this.args.length==2);var C=this.args[0].evaluate(A).stringValue();var B=this.args[1].evaluate(A).stringValue();return new BooleanValue(C.indexOf(B)!=-1)},"substring-before":function(A){assert(this.args.length==2);var E=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).stringValue();var C=E.indexOf(D);var B;if(C==-1){B=""}else{B=E.substr(0,C)}return new StringValue(B)},"substring-after":function(A){assert(this.args.length==2);var E=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).stringValue();var C=E.indexOf(D);var B;if(C==-1){B=""}else{B=E.substr(C+D.length)}return new StringValue(B)},"substring":function(A){assert(this.args.length==2||this.args.length==3);var F=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).numberValue();var C;if(this.args.length==2){var G=Math.max(0,Math.round(D)-1);C=F.substr(G)}else{var B=this.args[2].evaluate(A).numberValue();var H=Math.round(D)-1;var G=Math.max(0,H);var E=Math.round(B)-Math.max(0,-H);C=F.substr(G,E)}return new StringValue(C)},"string-length":function(A){var B;if(this.args.length>0){B=this.args[0].evaluate(A).stringValue()}else{B=new NodeSetValue([A.node]).stringValue()}return new NumberValue(B.length)},"normalize-space":function(A){var B;if(this.args.length>0){B=this.args[0].evaluate(A).stringValue()}else{B=new NodeSetValue([A.node]).stringValue()}B=B.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");return new StringValue(B)},"translate":function(A){assert(this.args.length==3);var E=this.args[0].evaluate(A).stringValue();var D=this.args[1].evaluate(A).stringValue();var B=this.args[2].evaluate(A).stringValue();for(var C=0;C<D.length;++C){E=E.replace(new RegExp(D.charAt(C),"g"),B.charAt(C))}return new StringValue(E)},"boolean":function(A){assert(this.args.length==1);return new BooleanValue(this.args[0].evaluate(A).booleanValue())},"not":function(A){assert(this.args.length==1);var B=!this.args[0].evaluate(A).booleanValue();return new BooleanValue(B)},"true":function(A){assert(this.args.length==0);return new BooleanValue(true)},"false":function(A){assert(this.args.length==0);return new BooleanValue(false)},"lang":function(A){assert(this.args.length==1);var C=this.args[0].evaluate(A).stringValue();var E;var D=A.node;while(D&&D!=D.parentNode){E=D.getAttribute("xml:lang");if(E){break}D=D.parentNode}if(!E){return new BooleanValue(false)}else{var B=new RegExp("^"+C+"$","i");return new BooleanValue(E.match(B)||E.replace(/_.*$/,"").match(B))}},"number":function(A){assert(this.args.length==1||this.args.length==0);if(this.args.length==1){return new NumberValue(this.args[0].evaluate(A).numberValue())}else{return new NumberValue(new NodeSetValue([A.node]).numberValue())}},"sum":function(A){assert(this.args.length==1);var D=this.args[0].evaluate(A).nodeSetValue();var C=0;for(var B=0;B<D.length;++B){C+=xmlValue(D[B])-0}return new NumberValue(C)},"floor":function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A).numberValue();return new NumberValue(Math.floor(B))},"ceiling":function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A).numberValue();return new NumberValue(Math.ceil(B))},"round":function(A){assert(this.args.length==1);var B=this.args[0].evaluate(A).numberValue();return new NumberValue(Math.round(B))},"ext-join":function(A){assert(this.args.length==2);var B=this.args[0].evaluate(A).nodeSetValue();var E=this.args[1].evaluate(A).stringValue();var C="";for(var D=0;D<B.length;++D){if(C){C+=E}C+=xmlValue(B[D])}return new StringValue(C)},"ext-if":function(A){assert(this.args.length==3);if(this.args[0].evaluate(A).booleanValue()){return this.args[1].evaluate(A)}else{return this.args[2].evaluate(A)}},"ext-cardinal":function(A){assert(this.args.length>=1);var D=this.args[0].evaluate(A).numberValue();var B=[];for(var C=0;C<D;++C){B.push(A.node)}return new NodeSetValue(B)}};function UnionExpr(B,A){this.expr1=B;this.expr2=A}UnionExpr.prototype.evaluate=function(C){var B=this.expr1.evaluate(C).nodeSetValue();var A=this.expr2.evaluate(C).nodeSetValue();var F=B.length;for(var D=0;D<A.length;++D){var H=A[D];var G=false;for(var E=0;E<F;++E){if(B[E]==H){G=true;E=F}}if(!G){B.push(H)}}return new NodeSetValue(B)};function PathExpr(B,A){this.filter=B;this.rel=A}PathExpr.prototype.evaluate=function(B){var D=this.filter.evaluate(B).nodeSetValue();var A=[];for(var E=0;E<D.length;++E){var C=this.rel.evaluate(B.clone(D[E],E,D)).nodeSetValue();for(var F=0;F<C.length;++F){A.push(C[F])}}return new NodeSetValue(A)};function FilterExpr(B,A){this.expr=B;this.predicate=A}FilterExpr.prototype.evaluate=function(A){var C=this.expr.evaluate(A).nodeSetValue();for(var E=0;E<this.predicate.length;++E){var B=C;C=[];for(var D=0;D<B.length;++D){var F=B[D];if(this.predicate[E].evaluate(A.clone(F,D,B)).booleanValue()){C.push(F)}}}return new NodeSetValue(C)};function UnaryMinusExpr(A){this.expr=A}UnaryMinusExpr.prototype.evaluate=function(A){return new NumberValue(-this.expr.evaluate(A).numberValue())};function BinaryExpr(B,C,A){this.expr1=B;this.expr2=A;this.op=C}BinaryExpr.prototype.evaluate=function(A){var B;switch(this.op.value){case"or":B=new BooleanValue(this.expr1.evaluate(A).booleanValue()||this.expr2.evaluate(A).booleanValue());break;case"and":B=new BooleanValue(this.expr1.evaluate(A).booleanValue()&&this.expr2.evaluate(A).booleanValue());break;case"+":B=new NumberValue(this.expr1.evaluate(A).numberValue()+this.expr2.evaluate(A).numberValue());break;case"-":B=new NumberValue(this.expr1.evaluate(A).numberValue()-this.expr2.evaluate(A).numberValue());break;case"*":B=new NumberValue(this.expr1.evaluate(A).numberValue()*this.expr2.evaluate(A).numberValue());break;case"mod":B=new NumberValue(this.expr1.evaluate(A).numberValue()%this.expr2.evaluate(A).numberValue());break;case"div":B=new NumberValue(this.expr1.evaluate(A).numberValue()/this.expr2.evaluate(A).numberValue());break;case"=":B=this.compare(A,function(D,C){return D==C});break;case"!=":B=this.compare(A,function(D,C){return D!=C});break;case"<":B=this.compare(A,function(D,C){return D<C});break;case"<=":B=this.compare(A,function(D,C){return D<=C});break;case">":B=this.compare(A,function(D,C){return D>C});break;case">=":B=this.compare(A,function(D,C){return D>=C});break;default:alert("BinaryExpr.evaluate: "+this.op.value)}return B};BinaryExpr.prototype.compare=function(L,H){var J=this.expr1.evaluate(L);var I=this.expr2.evaluate(L);var G;if(J.type=="node-set"&&I.type=="node-set"){var F=J.nodeSetValue();var E=I.nodeSetValue();G=false;for(var C=0;C<F.length;++C){for(var B=0;B<E.length;++B){if(H(xmlValue(F[C]),xmlValue(E[B]))){G=true;B=E.length;C=F.length}}}}else{if(J.type=="node-set"||I.type=="node-set"){if(J.type=="number"){var M=J.numberValue();var A=I.nodeSetValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D])-0;if(H(M,K)){G=true;break}}}else{if(I.type=="number"){var A=J.nodeSetValue();var M=I.numberValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D])-0;if(H(K,M)){G=true;break}}}else{if(J.type=="string"){var M=J.stringValue();var A=I.nodeSetValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D]);if(H(M,K)){G=true;break}}}else{if(I.type=="string"){var A=J.nodeSetValue();var M=I.stringValue();G=false;for(var D=0;D<A.length;++D){var K=xmlValue(A[D]);if(H(K,M)){G=true;break}}}else{G=H(J.booleanValue(),I.booleanValue())}}}}}else{if(J.type=="boolean"||I.type=="boolean"){G=H(J.booleanValue(),I.booleanValue())}else{if(J.type=="number"||I.type=="number"){G=H(J.numberValue(),I.numberValue())}else{G=H(J.stringValue(),I.stringValue())}}}}return new BooleanValue(G)};function LiteralExpr(A){this.value=A}LiteralExpr.prototype.evaluate=function(A){return new StringValue(this.value)};function NumberExpr(A){this.value=A}NumberExpr.prototype.evaluate=function(A){return new NumberValue(this.value)};function VariableExpr(A){this.name=A}VariableExpr.prototype.evaluate=function(A){return A.getVariable(this.name)};function makeTokenExpr(A){return new TokenExpr(A)}function passExpr(A){return A}function makeLocationExpr1(B,A){A.absolute=true;return A}function makeLocationExpr2(B,A){A.absolute=true;A.prependStep(makeAbbrevStep(B.value));return A}function makeLocationExpr3(B){var A=new LocationExpr();A.appendStep(makeAbbrevStep("."));A.absolute=true;return A}function makeLocationExpr4(B){var A=new LocationExpr();A.absolute=true;A.appendStep(makeAbbrevStep(B.value));return A}function makeLocationExpr5(B){var A=new LocationExpr();A.appendStep(B);return A}function makeLocationExpr6(A,B,C){A.appendStep(C);return A}function makeLocationExpr7(A,B,C){A.appendStep(makeAbbrevStep(B.value));return A}function makeStepExpr1(A){return makeAbbrevStep(A.value)}function makeStepExpr2(A){return makeAbbrevStep(A.value)}function makeStepExpr3(A,B,C){return new StepExpr(A.value,C)}function makeStepExpr4(A,B){return new StepExpr("attribute",B)}function makeStepExpr5(A){return new StepExpr("child",A)}function makeStepExpr6(B,A){B.appendPredicate(A);return B}function makeAbbrevStep(A){switch(A){case"//":return new StepExpr("descendant-or-self",new NodeTestAny);case".":return new StepExpr("self",new NodeTestAny);case"..":return new StepExpr("parent",new NodeTestAny)}}function makeNodeTestExpr1(A){return new NodeTestElementOrAttribute}function makeNodeTestExpr2(A,B,C){return new NodeTestNC(A.value)}function makeNodeTestExpr3(A){return new NodeTestName(A.value)}function makeNodeTestExpr4(C,A){var B=C.value.replace(/\s*\($/,"");switch(B){case"node":return new NodeTestAny;case"text":return new NodeTestText;case"comment":return new NodeTestComment;case"processing-instruction":return new NodeTestPI("")}}function makeNodeTestExpr5(D,C,A){var B=D.replace(/\s*\($/,"");if(B!="processing-instruction"){throw B}return new NodeTestPI(C.value)}function makePredicateExpr(C,B,A){return new PredicateExpr(B)}function makePrimaryExpr(C,B,A){return B}function makeFunctionCallExpr1(B,C,A){return new FunctionCallExpr(B)}function makeFunctionCallExpr2(E,G,D,C,A){var B=new FunctionCallExpr(E);B.appendArg(D);for(var F=0;F<C.length;++F){B.appendArg(C[F])}return B}function makeArgumentExpr(A,B){return B}function makeUnionExpr(C,A,B){return new UnionExpr(C,B)}function makePathExpr1(C,B,A){return new PathExpr(C,A)}function makePathExpr2(C,B,A){A.prependStep(makeAbbrevStep(B.value));return new PathExpr(C,A)}function makeFilterExpr(B,A){if(A.length>0){return new FilterExpr(B,A)}else{return B}}function makeUnaryMinusExpr(A,B){return new UnaryMinusExpr(B)}function makeBinaryExpr(B,C,A){return new BinaryExpr(B,C,A)}function makeLiteralExpr(A){var B=A.value.substring(1,A.value.length-1);return new LiteralExpr(B)}function makeNumberExpr(A){return new NumberExpr(A.value)}function makeVariableReference(A,B){return new VariableExpr(B.value)}function makeSimpleExpr(C){if(C.charAt(0)=="$"){return new VariableExpr(C.substr(1))}else{if(C.charAt(0)=="@"){var B=new NodeTestName(C.substr(1));var A=new StepExpr("attribute",B);var D=new LocationExpr();D.appendStep(A);return D}else{if(C.match(/^[0-9]+$/)){return new NumberExpr(C)}else{var B=new NodeTestName(C);var A=new StepExpr("child",B);var D=new LocationExpr();D.appendStep(A);return D}}}}function makeSimpleExpr2(E){var C=stringSplit(E,"/");var F=new LocationExpr();for(var D=0;D<C.length;++D){var B=new NodeTestName(C[D]);var A=new StepExpr("child",B);F.appendStep(A)}return F}var xpathAxis={ANCESTOR_OR_SELF:"ancestor-or-self",ANCESTOR:"ancestor",ATTRIBUTE:"attribute",CHILD:"child",DESCENDANT_OR_SELF:"descendant-or-self",DESCENDANT:"descendant",FOLLOWING_SIBLING:"following-sibling",FOLLOWING:"following",NAMESPACE:"namespace",PARENT:"parent",PRECEDING_SIBLING:"preceding-sibling",PRECEDING:"preceding",SELF:"self"};var xpathAxesRe=[xpathAxis.ANCESTOR_OR_SELF,xpathAxis.ANCESTOR,xpathAxis.ATTRIBUTE,xpathAxis.CHILD,xpathAxis.DESCENDANT_OR_SELF,xpathAxis.DESCENDANT,xpathAxis.FOLLOWING_SIBLING,xpathAxis.FOLLOWING,xpathAxis.NAMESPACE,xpathAxis.PARENT,xpathAxis.PRECEDING_SIBLING,xpathAxis.PRECEDING,xpathAxis.SELF].join("|");var TOK_PIPE={label:"|",prec:17,re:new RegExp("^\\|")};var TOK_DSLASH={label:"//",prec:19,re:new RegExp("^//")};var TOK_SLASH={label:"/",prec:30,re:new RegExp("^/")};var TOK_AXIS={label:"::",prec:20,re:new RegExp("^::")};var TOK_COLON={label:":",prec:1000,re:new RegExp("^:")};var TOK_AXISNAME={label:"[axis]",re:new RegExp("^("+xpathAxesRe+")")};var TOK_PARENO={label:"(",prec:34,re:new RegExp("^\\(")};var TOK_PARENC={label:")",re:new RegExp("^\\)")};var TOK_DDOT={label:"..",prec:34,re:new RegExp("^\\.\\.")};var TOK_DOT={label:".",prec:34,re:new RegExp("^\\.")};var TOK_AT={label:"@",prec:34,re:new RegExp("^@")};var TOK_COMMA={label:",",re:new RegExp("^,")};var TOK_OR={label:"or",prec:10,re:new RegExp("^or\\b")};var TOK_AND={label:"and",prec:11,re:new RegExp("^and\\b")};var TOK_EQ={label:"=",prec:12,re:new RegExp("^=")};var TOK_NEQ={label:"!=",prec:12,re:new RegExp("^!=")};var TOK_GE={label:">=",prec:13,re:new RegExp("^>=")};var TOK_GT={label:">",prec:13,re:new RegExp("^>")};var TOK_LE={label:"<=",prec:13,re:new RegExp("^<=")};var TOK_LT={label:"<",prec:13,re:new RegExp("^<")};var TOK_PLUS={label:"+",prec:14,re:new RegExp("^\\+"),left:true};var TOK_MINUS={label:"-",prec:14,re:new RegExp("^\\-"),left:true};var TOK_DIV={label:"div",prec:15,re:new RegExp("^div\\b"),left:true};var TOK_MOD={label:"mod",prec:15,re:new RegExp("^mod\\b"),left:true};var TOK_BRACKO={label:"[",prec:32,re:new RegExp("^\\[")};var TOK_BRACKC={label:"]",re:new RegExp("^\\]")};var TOK_DOLLAR={label:"$",re:new RegExp("^\\$")};var TOK_NCNAME={label:"[ncname]",re:new RegExp("^"+XML_NC_NAME)};var TOK_ASTERISK={label:"*",prec:15,re:new RegExp("^\\*"),left:true};var TOK_LITERALQ={label:"[litq]",prec:20,re:new RegExp("^'[^\\']*'")};var TOK_LITERALQQ={label:"[litqq]",prec:20,re:new RegExp('^"[^\\"]*"')};var TOK_NUMBER={label:"[number]",prec:35,re:new RegExp("^\\d+(\\.\\d*)?")};var TOK_QNAME={label:"[qname]",re:new RegExp("^("+XML_NC_NAME+":)?"+XML_NC_NAME)};var TOK_NODEO={label:"[nodetest-start]",re:new RegExp("^(processing-instruction|comment|text|node)\\(")};var xpathTokenRules=[TOK_DSLASH,TOK_SLASH,TOK_DDOT,TOK_DOT,TOK_AXIS,TOK_COLON,TOK_AXISNAME,TOK_NODEO,TOK_PARENO,TOK_PARENC,TOK_BRACKO,TOK_BRACKC,TOK_AT,TOK_COMMA,TOK_OR,TOK_AND,TOK_NEQ,TOK_EQ,TOK_GE,TOK_GT,TOK_LE,TOK_LT,TOK_PLUS,TOK_MINUS,TOK_ASTERISK,TOK_PIPE,TOK_MOD,TOK_DIV,TOK_LITERALQ,TOK_LITERALQQ,TOK_NUMBER,TOK_QNAME,TOK_NCNAME,TOK_DOLLAR];var XPathLocationPath={label:"LocationPath"};var XPathRelativeLocationPath={label:"RelativeLocationPath"};var XPathAbsoluteLocationPath={label:"AbsoluteLocationPath"};var XPathStep={label:"Step"};var XPathNodeTest={label:"NodeTest"};var XPathPredicate={label:"Predicate"};var XPathLiteral={label:"Literal"};var XPathExpr={label:"Expr"};var XPathPrimaryExpr={label:"PrimaryExpr"};var XPathVariableReference={label:"Variablereference"};var XPathNumber={label:"Number"};var XPathFunctionCall={label:"FunctionCall"};var XPathArgumentRemainder={label:"ArgumentRemainder"};var XPathPathExpr={label:"PathExpr"};var XPathUnionExpr={label:"UnionExpr"};var XPathFilterExpr={label:"FilterExpr"};var XPathDigits={label:"Digits"};var xpathNonTerminals=[XPathLocationPath,XPathRelativeLocationPath,XPathAbsoluteLocationPath,XPathStep,XPathNodeTest,XPathPredicate,XPathLiteral,XPathExpr,XPathPrimaryExpr,XPathVariableReference,XPathNumber,XPathFunctionCall,XPathArgumentRemainder,XPathPathExpr,XPathUnionExpr,XPathFilterExpr,XPathDigits];var Q_01={label:"?"};var Q_MM={label:"*"};var Q_1M={label:"+"};var ASSOC_LEFT=true;var xpathGrammarRules=[[XPathLocationPath,[XPathRelativeLocationPath],18,passExpr],[XPathLocationPath,[XPathAbsoluteLocationPath],18,passExpr],[XPathAbsoluteLocationPath,[TOK_SLASH,XPathRelativeLocationPath],18,makeLocationExpr1],[XPathAbsoluteLocationPath,[TOK_DSLASH,XPathRelativeLocationPath],18,makeLocationExpr2],[XPathAbsoluteLocationPath,[TOK_SLASH],0,makeLocationExpr3],[XPathAbsoluteLocationPath,[TOK_DSLASH],0,makeLocationExpr4],[XPathRelativeLocationPath,[XPathStep],31,makeLocationExpr5],[XPathRelativeLocationPath,[XPathRelativeLocationPath,TOK_SLASH,XPathStep],31,makeLocationExpr6],[XPathRelativeLocationPath,[XPathRelativeLocationPath,TOK_DSLASH,XPathStep],31,makeLocationExpr7],[XPathStep,[TOK_DOT],33,makeStepExpr1],[XPathStep,[TOK_DDOT],33,makeStepExpr2],[XPathStep,[TOK_AXISNAME,TOK_AXIS,XPathNodeTest],33,makeStepExpr3],[XPathStep,[TOK_AT,XPathNodeTest],33,makeStepExpr4],[XPathStep,[XPathNodeTest],33,makeStepExpr5],[XPathStep,[XPathStep,XPathPredicate],33,makeStepExpr6],[XPathNodeTest,[TOK_ASTERISK],33,makeNodeTestExpr1],[XPathNodeTest,[TOK_NCNAME,TOK_COLON,TOK_ASTERISK],33,makeNodeTestExpr2],[XPathNodeTest,[TOK_QNAME],33,makeNodeTestExpr3],[XPathNodeTest,[TOK_NODEO,TOK_PARENC],33,makeNodeTestExpr4],[XPathNodeTest,[TOK_NODEO,XPathLiteral,TOK_PARENC],33,makeNodeTestExpr5],[XPathPredicate,[TOK_BRACKO,XPathExpr,TOK_BRACKC],33,makePredicateExpr],[XPathPrimaryExpr,[XPathVariableReference],33,passExpr],[XPathPrimaryExpr,[TOK_PARENO,XPathExpr,TOK_PARENC],33,makePrimaryExpr],[XPathPrimaryExpr,[XPathLiteral],30,passExpr],[XPathPrimaryExpr,[XPathNumber],30,passExpr],[XPathPrimaryExpr,[XPathFunctionCall],30,passExpr],[XPathFunctionCall,[TOK_QNAME,TOK_PARENO,TOK_PARENC],-1,makeFunctionCallExpr1],[XPathFunctionCall,[TOK_QNAME,TOK_PARENO,XPathExpr,XPathArgumentRemainder,Q_MM,TOK_PARENC],-1,makeFunctionCallExpr2],[XPathArgumentRemainder,[TOK_COMMA,XPathExpr],-1,makeArgumentExpr],[XPathUnionExpr,[XPathPathExpr],20,passExpr],[XPathUnionExpr,[XPathUnionExpr,TOK_PIPE,XPathPathExpr],20,makeUnionExpr],[XPathPathExpr,[XPathLocationPath],20,passExpr],[XPathPathExpr,[XPathFilterExpr],19,passExpr],[XPathPathExpr,[XPathFilterExpr,TOK_SLASH,XPathRelativeLocationPath],20,makePathExpr1],[XPathPathExpr,[XPathFilterExpr,TOK_DSLASH,XPathRelativeLocationPath],20,makePathExpr2],[XPathFilterExpr,[XPathPrimaryExpr,XPathPredicate,Q_MM],20,makeFilterExpr],[XPathExpr,[XPathPrimaryExpr],16,passExpr],[XPathExpr,[XPathUnionExpr],16,passExpr],[XPathExpr,[TOK_MINUS,XPathExpr],-1,makeUnaryMinusExpr],[XPathExpr,[XPathExpr,TOK_OR,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_AND,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_EQ,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_NEQ,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_LT,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_LE,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_GT,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_GE,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_PLUS,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_MINUS,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_ASTERISK,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_DIV,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_MOD,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathLiteral,[TOK_LITERALQ],-1,makeLiteralExpr],[XPathLiteral,[TOK_LITERALQQ],-1,makeLiteralExpr],[XPathNumber,[TOK_NUMBER],-1,makeNumberExpr],[XPathVariableReference,[TOK_DOLLAR,TOK_QNAME],200,makeVariableReference]];var xpathRules=[];function xpathParseInit(){if(xpathRules.length){return }xpathGrammarRules.sort(function(I,H){var K=I[1].length;var J=H[1].length;if(K<J){return 1}else{if(K>J){return -1}else{return 0}}});var A=1;for(var C=0;C<xpathNonTerminals.length;++C){xpathNonTerminals[C].key=A++}for(C=0;C<xpathTokenRules.length;++C){xpathTokenRules[C].key=A++}xpathLog("XPath parse INIT: "+A+" rules");function E(J,H,I){if(!J[H]){J[H]=[]}J[H].push(I)}for(C=0;C<xpathGrammarRules.length;++C){var G=xpathGrammarRules[C];var F=G[1];for(var B=F.length-1;B>=0;--B){if(F[B]==Q_1M){E(xpathRules,F[B-1].key,G);break}else{if(F[B]==Q_MM||F[B]==Q_01){E(xpathRules,F[B-1].key,G);--B}else{E(xpathRules,F[B].key,G);break}}}}xpathLog("XPath parse INIT: "+xpathRules.length+" rule bins");var D=0;mapExec(xpathRules,function(H){if(H){D+=H.length}});xpathLog("XPath parse INIT: "+(D/xpathRules.length)+" average bin size")}function xpathCollectDescendants(B,A){for(var C=A.firstChild;C;C=C.nextSibling){B.push(C);arguments.callee(B,C)}}function xpathCollectDescendantsReverse(B,A){for(var C=A.lastChild;C;C=C.previousSibling){B.push(C);arguments.callee(B,C)}}function xpathDomEval(C,B){var D=xpathParse(C);var A=D.evaluate(new ExprContext(B));return A}function xpathSort(H,F){if(F.length==0){return }var L=[];for(var G=0;G<H.contextSize();++G){var C=H.nodelist[G];var D={node:C,key:[]};var B=H.clone(C,0,[C]);for(var E=0;E<F.length;++E){var K=F[E];var J=K.expr.evaluate(B);var I;if(K.type=="text"){I=J.stringValue()}else{if(K.type=="number"){I=J.numberValue()}}D.key.push({value:I,order:K.order})}D.key.push({value:G,order:"ascending"});L.push(D)}L.sort(xpathSortByKey);var A=[];for(var G=0;G<L.length;++G){A.push(L[G].node)}H.nodelist=A;H.setNode(0)}function xpathSortByKey(D,C){for(var A=0;A<D.key.length;++A){var B=D.key[A].order=="descending"?-1:1;if(D.key[A].value>C.key[A].value){return +1*B}else{if(D.key[A].value<C.key[A].value){return -1*B}}}return 0}function xpathEval(A,C){var D=xpathParse(A);var B=D.evaluate(C);return B}function xsltProcess(D,C){var A=domCreateDocumentFragment(new XDocument);xsltProcessContext(new ExprContext(D),C,A);var B=xmlText(A);return B}function xsltProcessContext(I,W,H){var A=xmlOwnerDocument(H);var S=W.nodeName.split(/:/);if(S.length==1||S[0]!="xsl"){xsltPassThrough(I,W,H,A)}else{switch(S[1]){case"apply-imports":alert("not implemented: "+S[1]);break;case"apply-templates":var M=xmlGetAttribute(W,"select");var N;if(M){N=xpathEval(M,I).nodeSetValue()}else{N=I.node.childNodes}var G=I.clone(N[0],0,N);xsltWithParam(G,W);xsltSort(G,W);var K=xmlGetAttribute(W,"mode");var L=W.ownerDocument.documentElement;var C=[];for(var R=0;R<L.childNodes.length;++R){var V=L.childNodes[R];if(V.nodeType==DOM_ELEMENT_NODE&&V.nodeName=="xsl:template"&&V.getAttribute("mode")==K){C.push(V)}}for(var Q=0;Q<G.contextSize();++Q){var D=G.nodelist[Q];for(var R=0;R<C.length;++R){xsltProcessContext(G.clone(D,Q),C[R],H)}}break;case"attribute":var X=xmlGetAttribute(W,"name");var Y=xsltAttributeValue(X,I);var P=domCreateDocumentFragment(A);xsltChildNodes(I,W,P);var O=xmlValue(P);domSetAttribute(H,Y,O);break;case"attribute-set":alert("not implemented: "+S[1]);break;case"call-template":var Y=xmlGetAttribute(W,"name");var L=W.ownerDocument.documentElement;var E=I.clone();xsltWithParam(E,W);for(var R=0;R<L.childNodes.length;++R){var V=L.childNodes[R];if(V.nodeType==DOM_ELEMENT_NODE&&V.nodeName=="xsl:template"&&domGetAttribute(V,"name")==Y){xsltChildNodes(E,V,H);break}}break;case"choose":xsltChoose(I,W,H);break;case"comment":var P=domCreateDocumentFragment(A);xsltChildNodes(I,W,P);var B=xmlValue(P);var U=domCreateComment(A,B);H.appendChild(U);break;case"copy":var P=xsltCopy(H,I.node,A);if(P){xsltChildNodes(I,W,P)}break;case"copy-of":var M=xmlGetAttribute(W,"select");var O=xpathEval(M,I);if(O.type=="node-set"){var N=O.nodeSetValue();for(var R=0;R<N.length;++R){xsltCopyOf(H,N[R],A)}}else{var P=domCreateTextNode(A,O.stringValue());domAppendChild(H,P)}break;case"decimal-format":alert("not implemented: "+S[1]);break;case"element":var X=xmlGetAttribute(W,"name");var Y=xsltAttributeValue(X,I);var P=domCreateElement(A,Y);domAppendChild(H,P);xsltChildNodes(I,W,P);break;case"fallback":alert("not implemented: "+S[1]);break;case"for-each":xsltForEach(I,W,H);break;case"if":var T=xmlGetAttribute(W,"test");if(xpathEval(T,I).booleanValue()){xsltChildNodes(I,W,H)}break;case"import":alert("not implemented: "+S[1]);break;case"include":alert("not implemented: "+S[1]);break;case"key":alert("not implemented: "+S[1]);break;case"message":alert("not implemented: "+S[1]);break;case"namespace-alias":alert("not implemented: "+S[1]);break;case"number":alert("not implemented: "+S[1]);break;case"otherwise":alert("error if here: "+S[1]);break;case"output":break;case"preserve-space":alert("not implemented: "+S[1]);break;case"processing-instruction":alert("not implemented: "+S[1]);break;case"sort":break;case"strip-space":alert("not implemented: "+S[1]);break;case"stylesheet":case"transform":xsltChildNodes(I,W,H);break;case"template":var F=xmlGetAttribute(W,"match");if(F&&xsltMatch(F,I)){xsltChildNodes(I,W,H)}break;case"text":var J=xmlValue(W);var P=domCreateTextNode(A,J);H.appendChild(P);break;case"value-of":var M=xmlGetAttribute(W,"select");var O=xpathEval(M,I).stringValue();var P=domCreateTextNode(A,O);H.appendChild(P);break;case"param":xsltVariable(I,W,false);break;case"variable":xsltVariable(I,W,true);break;case"when":alert("error if here: "+S[1]);break;case"with-param":alert("error if here: "+S[1]);break;default:alert("error if here: "+S[1]);break}}}function xsltWithParam(A,C){for(var B=0;B<C.childNodes.length;++B){var D=C.childNodes[B];if(D.nodeType==DOM_ELEMENT_NODE&&D.nodeName=="xsl:with-param"){xsltVariable(A,D,true)}}}function xsltSort(F,I){var B=[];for(var C=0;C<I.childNodes.length;++C){var D=I.childNodes[C];if(D.nodeType==DOM_ELEMENT_NODE&&D.nodeName=="xsl:sort"){var G=xmlGetAttribute(D,"select");var H=xpathParse(G);var E=xmlGetAttribute(D,"data-type")||"text";var A=xmlGetAttribute(D,"order")||"ascending";B.push({expr:H,type:E,order:A})}}xpathSort(F,B)}function xsltVariable(C,F,E){var D=xmlGetAttribute(F,"name");var A=xmlGetAttribute(F,"select");var G;if(F.childNodes.length>0){var B=domCreateDocumentFragment(F.ownerDocument);xsltChildNodes(C,F,B);G=new NodeSetValue([B])}else{if(A){G=xpathEval(A,C)}else{G=new StringValue("")}}if(E||!C.getVariable(D)){C.setVariable(D,G)}}function xsltChoose(B,E,A){for(var D=0;D<E.childNodes.length;++D){var C=E.childNodes[D];if(C.nodeType!=DOM_ELEMENT_NODE){continue}else{if(C.nodeName=="xsl:when"){var F=xmlGetAttribute(C,"test");if(xpathEval(F,B).booleanValue()){xsltChildNodes(B,C,A);break}}else{if(C.nodeName=="xsl:otherwise"){xsltChildNodes(B,C,A);break}}}}}function xsltForEach(E,H,D){var A=xmlGetAttribute(H,"select");var C=xpathEval(A,E).nodeSetValue();var B=E.clone(C[0],0,C);xsltSort(B,H);for(var G=0;G<B.contextSize();++G){var F=B.nodelist[G];xsltChildNodes(B.clone(F,G),H,D)}}function xsltChildNodes(B,E,A){var D=B.clone();for(var C=0;C<E.childNodes.length;++C){xsltProcessContext(D,E.childNodes[C],A)}}function xsltPassThrough(E,H,B,I){if(H.nodeType==DOM_TEXT_NODE){if(xsltPassText(H)){var C=domCreateTextNode(I,H.nodeValue);domAppendChild(B,C)}}else{if(H.nodeType==DOM_ELEMENT_NODE){var C=domCreateElement(I,H.nodeName);for(var D=0;D<H.attributes.length;++D){var F=H.attributes[D];if(F){var A=F.nodeName;var G=xsltAttributeValue(F.nodeValue,E);domSetAttribute(C,A,G)}}domAppendChild(B,C);xsltChildNodes(E,H,C)}else{xsltChildNodes(E,H,B)}}}function xsltPassText(B){if(!B.nodeValue.match(/^\s*$/)){return true}var A=B.parentNode;if(A.nodeName=="xsl:text"){return true}while(A&&A.nodeType==DOM_ELEMENT_NODE){var C=domGetAttribute(A,"xml:space");if(C){if(C=="default"){return false}else{if(C=="preserve"){return true}}}A=A.parentNode}return false}function xsltAttributeValue(E,C){var F=stringSplit(E,"{");if(F.length==1){return E}var A="";for(var B=0;B<F.length;++B){var D=stringSplit(F[B],"}");if(D.length!=2){A+=F[B];continue}var G=xpathEval(D[0],C).stringValue();A+=G+D[1]}return A}function xmlGetAttribute(B,A){var C=domGetAttribute(B,A);if(C){return xmlResolveEntities(C)}else{return C}}function xsltCopyOf(E,D,C){if(D.nodeType==DOM_DOCUMENT_FRAGMENT_NODE||D.nodeType==DOM_DOCUMENT_NODE){for(var A=0;A<D.childNodes.length;++A){arguments.callee(E,D.childNodes[A],C)}}else{var B=xsltCopy(E,D,C);if(B){for(var A=0;A<D.attributes.length;++A){arguments.callee(B,D.attributes[A],C)}for(var A=0;A<D.childNodes.length;++A){arguments.callee(B,D.childNodes[A],C)}}}}function xsltCopy(D,C,B){if(C.nodeType==DOM_ELEMENT_NODE){var A=domCreateElement(B,C.nodeName);domAppendChild(D,A);return A}if(C.nodeType==DOM_TEXT_NODE){var A=domCreateTextNode(B,C.nodeValue);domAppendChild(D,A)}else{if(C.nodeType==DOM_CDATA_SECTION_NODE){var A=domCreateCDATASection(B,C.nodeValue);domAppendChild(D,A)}else{if(C.nodeType==DOM_COMMENT_NODE){var A=domCreateComment(B,C.nodeValue);domAppendChild(D,A)}else{if(C.nodeType==DOM_ATTRIBUTE_NODE){domSetAttribute(D,C.nodeName,C.nodeValue)}}}}return null}function xsltMatch(C,E){var G=xpathParse(C);var B;if(G.steps&&!G.absolute&&G.steps.length==1&&G.steps[0].axis=="child"&&G.steps[0].predicate.length==0){B=G.steps[0].nodetest.evaluate(E).booleanValue()}else{B=false;var F=E.node;while(!B&&F){var A=G.evaluate(E.clone(F,0,[F])).nodeSetValue();for(var D=0;D<A.length;++D){if(A[D]==E.node){B=true;break}}F=F.parentNode}}return B}
