From 86158510bf3209cf2710a5b302db959aa5aa3e8f Mon Sep 17 00:00:00 2001 From: ug Date: Sun, 6 Sep 2015 13:25:14 -0700 Subject: [PATCH 1/9] Added proper matching and parsing for wildcard namespaces and wildcard names *:nodeName prefix:* *:* * --- src/lexer.js | 4 ++-- src/nameTest.js | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/lexer.js b/src/lexer.js index de8835d..2a522d1 100644 --- a/src/lexer.js +++ b/src/lexer.js @@ -81,8 +81,8 @@ wgxpath.Lexer.tokenize = function(source) { * @private */ wgxpath.Lexer.TOKEN_ = new RegExp( - '\\$?(?:(?![0-9-])[\\w-]+:)?(?![0-9-])[\\w-]+' + - // Nodename (possibly with namespace) or variable. + '\\$?(?:(?![0-9-])[\\w-\\*]+:)?(?![0-9-])[\\w-\\*]+' + + // Nodename or wildcard[*] (possibly with namespace or wildcard[*]) or variable. '|\\/\\/' + // Double slash. '|\\.\\.' + // Double dot. '|::' + // Double colon. diff --git a/src/nameTest.js b/src/nameTest.js index 35edf54..cfed20b 100644 --- a/src/nameTest.js +++ b/src/nameTest.js @@ -54,12 +54,20 @@ wgxpath.NameTest = function(name, opt_namespaceUri) { */ this.name_ = name.toLowerCase(); + var defaultNamespace; + if(this.name_ == wgxpath.NameTest.WILDCARD) { + // wildcard names default to wildcard namespace + defaultNamespace = wgxpath.NameTest.WILDCARD; + } else { + // defined names default to html namespace + defaultNamespace = wgxpath.NameTest.HTML_NAMESPACE_URI_; + } /** * @type {string} * @private */ - this.namespaceUri_ = opt_namespaceUri ? opt_namespaceUri.toLowerCase() : - wgxpath.NameTest.HTML_NAMESPACE_URI_; + this.namespaceUri_ = opt_namespaceUri ? opt_namespaceUri.toLowerCase() : defaultNamespace; + }; @@ -72,6 +80,15 @@ wgxpath.NameTest = function(name, opt_namespaceUri) { */ wgxpath.NameTest.HTML_NAMESPACE_URI_ = 'http://www.w3.org/1999/xhtml'; + /** + * Wildcard namespace which matches any namespace + * + * @const + * @type {string} + * @private + */ + wgxpath.NameTest.WILDCARD = '*'; + /** * @override @@ -82,12 +99,21 @@ wgxpath.NameTest.prototype.matches = function(node) { type != goog.dom.NodeType.ATTRIBUTE) { return false; } - if (this.name_ != '*' && this.name_ != node.nodeName.toLowerCase()) { + console.log("Name matches? '"+this.name_+"' - '"+node.nodeName.toLowerCase()+"'"); + + // check if names dont match, if this is a wildcard then + if (this.name_ != wgxpath.NameTest.WILDCARD && this.name_ != node.nodeName.toLowerCase()) { return false; } else { - var namespaceUri = node.namespaceURI ? node.namespaceURI.toLowerCase() : - wgxpath.NameTest.HTML_NAMESPACE_URI_; - return this.namespaceUri_ == namespaceUri; + // wildcard namespace, it matches + if(this.namespaceUri_ == wgxpath.NameTest.WILDCARD) { + return true; + } else { + + var namespaceUri = node.namespaceURI ? node.namespaceURI.toLowerCase() : + wgxpath.NameTest.HTML_NAMESPACE_URI_; + return this.namespaceUri_ == namespaceUri; + } } }; From 4abc1e1ff8253f93ee3794be0e99b7ee8dd0e4f9 Mon Sep 17 00:00:00 2001 From: ug Date: Sun, 6 Sep 2015 14:01:43 -0700 Subject: [PATCH 2/9] Fixed wildcard bugs and added optional force overwrite parameter --- src/nameTest.js | 5 ++--- src/parser.js | 19 ++++++++++--------- src/wgxpath.js | 10 ++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/nameTest.js b/src/nameTest.js index cfed20b..13455c8 100644 --- a/src/nameTest.js +++ b/src/nameTest.js @@ -85,7 +85,7 @@ wgxpath.NameTest.HTML_NAMESPACE_URI_ = 'http://www.w3.org/1999/xhtml'; * * @const * @type {string} - * @private + * @public */ wgxpath.NameTest.WILDCARD = '*'; @@ -99,10 +99,9 @@ wgxpath.NameTest.prototype.matches = function(node) { type != goog.dom.NodeType.ATTRIBUTE) { return false; } - console.log("Name matches? '"+this.name_+"' - '"+node.nodeName.toLowerCase()+"'"); // check if names dont match, if this is a wildcard then - if (this.name_ != wgxpath.NameTest.WILDCARD && this.name_ != node.nodeName.toLowerCase()) { + if (this.name_ != wgxpath.NameTest.WILDCARD && this.name_ != node.localName.toLowerCase()) { return false; } else { // wildcard namespace, it matches diff --git a/src/parser.js b/src/parser.js index d3d6e40..5f1c5d8 100644 --- a/src/parser.js +++ b/src/parser.js @@ -270,9 +270,14 @@ wgxpath.Parser.prototype.parseNameTest_ = function() { return new wgxpath.NameTest(name); } else { var namespacePrefix = name.substring(0, colonIndex); - var namespaceUri = this.nsResolver_(namespacePrefix); - if (!namespaceUri) { - throw Error('Namespace prefix not declared: ' + namespacePrefix); + var namespaceUri; + if(namespacePrefix == wgxpath.NameTest.WILDCARD) { + namespaceUri = wgxpath.NameTest.WILDCARD; + } else { + namespaceUri = this.nsResolver_(namespacePrefix); + if (!namespaceUri) { + throw Error('Namespace prefix not declared: ' + namespacePrefix); + } } name = name.substr(colonIndex + 1); return new wgxpath.NameTest(name, namespaceUri); @@ -388,12 +393,8 @@ wgxpath.Parser.prototype.parseStep_ = function(op) { // Grab the test. token = this.lexer_.peek(); - if (!/(?![0-9])[\w]/.test(token.charAt(0))) { - if (token == '*') { - test = this.parseNameTest_(); - } else { - throw Error('Bad token: ' + this.lexer_.next()); - } + if (!/(?![0-9])[\w\*]/.test(token.charAt(0))) { + throw Error('Bad token: ' + this.lexer_.next()); } else { if (this.lexer_.peek(1) == '(') { if (!wgxpath.KindTest.isValidType(token)) { diff --git a/src/wgxpath.js b/src/wgxpath.js index 244517c..a7ee6fe 100644 --- a/src/wgxpath.js +++ b/src/wgxpath.js @@ -97,6 +97,7 @@ wgxpath.XPathExpression_ = function(expr, nsResolver) { if (!lexer.empty()) { throw Error('Bad token: ' + lexer.next()); } + this['evaluate'] = function(node, type) { var value = gexpr.evaluate(new wgxpath.Context(node)); return new wgxpath.XPathResult_(value, type); @@ -221,16 +222,17 @@ wgxpath.XPathNSResolver_ = function(node) { /** - * Installs the library. This is a noop if native XPath is available. + * Installs the library. This is a noop if native XPath is available or the 2nd parameter is true. * * @param {Window=} opt_win The window to install the library on. + * @param {boolean=} force_install Overwrites any existing method if evaluate on the document. */ -wgxpath.install = function(opt_win) { +wgxpath.install = function(opt_win, force_install) { var win = opt_win || goog.global; var doc = win.document; - // Installation is a noop if native XPath is available. - if (doc['evaluate']) { + // Installation is a noop if native XPath is available unless you want to force install + if (doc['evaluate'] && !force_install) { return; } From bade0db6a363768e5791ae96be5f9da4c7a98a35 Mon Sep 17 00:00:00 2001 From: ug Date: Sun, 6 Sep 2015 15:31:16 -0700 Subject: [PATCH 3/9] Messed up the regex and it was causing math expressions using multiplication(*) to fail. Fixed regex to only group asteriks when part of a name space definition(:) --- src/lexer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lexer.js b/src/lexer.js index 2a522d1..eed10c2 100644 --- a/src/lexer.js +++ b/src/lexer.js @@ -81,7 +81,7 @@ wgxpath.Lexer.tokenize = function(source) { * @private */ wgxpath.Lexer.TOKEN_ = new RegExp( - '\\$?(?:(?![0-9-])[\\w-\\*]+:)?(?![0-9-])[\\w-\\*]+' + + '\\$?(?:(?![0-9-])(?:\\*|[\\w-]+):)?(?![0-9-])(?:\\*|[\\w-]+)' + // Nodename or wildcard[*] (possibly with namespace or wildcard[*]) or variable. '|\\/\\/' + // Double slash. '|\\.\\.' + // Double dot. From d9233d960080652498a9a25ba1ac6ab0cf63c368 Mon Sep 17 00:00:00 2001 From: ug Date: Sun, 6 Sep 2015 17:19:21 -0700 Subject: [PATCH 4/9] Added support for period inside node name --- src/lexer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lexer.js b/src/lexer.js index eed10c2..3c3dc88 100644 --- a/src/lexer.js +++ b/src/lexer.js @@ -81,7 +81,7 @@ wgxpath.Lexer.tokenize = function(source) { * @private */ wgxpath.Lexer.TOKEN_ = new RegExp( - '\\$?(?:(?![0-9-])(?:\\*|[\\w-]+):)?(?![0-9-])(?:\\*|[\\w-]+)' + + '\\$?(?:(?![0-9-])(?:\\*|[\\w-\\.]+):)?(?![0-9-])(?:\\*|[\\w-\\.]+)' + // Nodename or wildcard[*] (possibly with namespace or wildcard[*]) or variable. '|\\/\\/' + // Double slash. '|\\.\\.' + // Double dot. From dff89c5908d6a99912605464dc40c924d56ec4a5 Mon Sep 17 00:00:00 2001 From: ug Date: Sun, 6 Sep 2015 17:22:03 -0700 Subject: [PATCH 5/9] Fixed support for periods in namespace prefixes and node names --- src/lexer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lexer.js b/src/lexer.js index 3c3dc88..57d4ddd 100644 --- a/src/lexer.js +++ b/src/lexer.js @@ -81,7 +81,7 @@ wgxpath.Lexer.tokenize = function(source) { * @private */ wgxpath.Lexer.TOKEN_ = new RegExp( - '\\$?(?:(?![0-9-])(?:\\*|[\\w-\\.]+):)?(?![0-9-])(?:\\*|[\\w-\\.]+)' + + '\\$?(?:(?![0-9-\\.])(?:\\*|[\\w-\\.]+):)?(?![0-9-\\.])(?:\\*|[\\w-\\.]+)' + // Nodename or wildcard[*] (possibly with namespace or wildcard[*]) or variable. '|\\/\\/' + // Double slash. '|\\.\\.' + // Double dot. From e2318a8caab73d9df8d152f55e4b11b8a61ed8b3 Mon Sep 17 00:00:00 2001 From: ug Date: Sun, 6 Sep 2015 22:04:02 -0700 Subject: [PATCH 6/9] Fixed comment about force_install parameter --- src/wgxpath.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wgxpath.js b/src/wgxpath.js index a7ee6fe..d90f94b 100644 --- a/src/wgxpath.js +++ b/src/wgxpath.js @@ -222,7 +222,7 @@ wgxpath.XPathNSResolver_ = function(node) { /** - * Installs the library. This is a noop if native XPath is available or the 2nd parameter is true. + * Installs the library. This is a noop if native XPath is available and the 2nd parameter (force_install) is false/undefined. * * @param {Window=} opt_win The window to install the library on. * @param {boolean=} force_install Overwrites any existing method if evaluate on the document. From 6738c5f6761d307babf40783580fe253f3fa7bb7 Mon Sep 17 00:00:00 2001 From: ug Date: Fri, 17 Jun 2016 01:11:02 -0700 Subject: [PATCH 7/9] =?UTF-8?q?-=20Removed=20toLowerCase()=20on=20node=20n?= =?UTF-8?q?ame=20storage=20and=20comparison.=20XPath=20is=20case=20sensiti?= =?UTF-8?q?ve.=20-=20Fixed=20descendant=20issue=20where=20nodes=20were=20b?= =?UTF-8?q?eing=20selected=20when=20they=20shouldn=E2=80=99t=20have=20when?= =?UTF-8?q?=20using=20variations=20of=20"//".=20Caused=20by=20the=20"Test"?= =?UTF-8?q?=20not=20being=20invoked=20during=20recursive=20node=20matching?= =?UTF-8?q?=20when=20finding=20descendants.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nameTest.js | 4 ++-- src/node.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nameTest.js b/src/nameTest.js index 73ef2bf..e0639b3 100644 --- a/src/nameTest.js +++ b/src/nameTest.js @@ -52,7 +52,7 @@ wgxpath.NameTest = function(name, opt_namespaceUri) { * @type {string} * @private */ - this.name_ = name.toLowerCase(); + this.name_ = name; var defaultNamespace; if (this.name_ == wgxpath.NameTest.WILDCARD) { @@ -103,7 +103,7 @@ wgxpath.NameTest.prototype.matches = function(node) { // TODO(moz): Investigate if node.localName is necessary. var localName = goog.isDef(node.localName) ? node.localName : node.nodeName; if (this.name_ != wgxpath.NameTest.WILDCARD && - this.name_ != localName.toLowerCase()) { + this.name_ != localName) { return false; } else { if (this.namespaceUri_ == wgxpath.NameTest.WILDCARD) { diff --git a/src/node.js b/src/node.js index cdcdc18..78611ba 100644 --- a/src/node.js +++ b/src/node.js @@ -268,7 +268,7 @@ wgxpath.Node.getDescendantNodesGeneric_ = function(test, node, } else if (node.getElementsByTagName) { var nodes = node.getElementsByTagName(test.getName()); goog.array.forEach(nodes, function(node) { - if (wgxpath.Node.attrMatches(node, attrName, attrValue)) { + if (test.matches(node) && wgxpath.Node.attrMatches(node, attrName, attrValue)) { nodeset.add(node); } }); From f6066c6c9ecb1eaa5dfccf936163f1527045e4e8 Mon Sep 17 00:00:00 2001 From: ug Date: Fri, 17 Jun 2016 01:39:30 -0700 Subject: [PATCH 8/9] - Fixed additional pre IE9 node matching - Fixed name() and local-name() also converting to lower case unnecessary --- src/functionCall.js | 4 ++-- src/node.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/functionCall.js b/src/functionCall.js index 9250493..d2bf443 100644 --- a/src/functionCall.js +++ b/src/functionCall.js @@ -371,14 +371,14 @@ wgxpath.FunctionCall.Func = { wgxpath.DataType.STRING, false, true, false, function(ctx, opt_expr) { var node = opt_expr ? opt_expr.evaluate(ctx).getFirst() : ctx.getNode(); - return node ? (node.localName || node.nodeName.toLowerCase()) : ''; + return node ? (node.localName || node.nodeName) : ''; }, 0, 1, true), NAME: wgxpath.FunctionCall.createFunc_('name', wgxpath.DataType.STRING, false, true, false, function(ctx, opt_expr) { // TODO: Fully implement this. var node = opt_expr ? opt_expr.evaluate(ctx).getFirst() : ctx.getNode(); - return node ? node.nodeName.toLowerCase() : ''; + return node ? node.nodeName : ''; }, 0, 1, true), NAMESPACE_URI: wgxpath.FunctionCall.createFunc_('namespace-uri', wgxpath.DataType.STRING, true, false, false, diff --git a/src/node.js b/src/node.js index 78611ba..8740572 100644 --- a/src/node.js +++ b/src/node.js @@ -320,7 +320,7 @@ wgxpath.Node.getChildNodesIEPre9_ = function(test, node, if (name != '*') { //children = children.tags(name); // children.tags seems buggy. children = goog.array.filter(children, function(child) { - return child.tagName && child.tagName.toLowerCase() == name; + return child.tagName && child.tagName == name; }); if (!children) { return nodeset; From 6f9404970882e1a1f74c99b39d19448fe3058e71 Mon Sep 17 00:00:00 2001 From: ug Date: Tue, 28 Jun 2016 13:54:56 -0700 Subject: [PATCH 9/9] Updated function calls to correctly handle localname and node name. node.nodeName returns a case insensitive version of the nodes name where localName and prefix return case sensitive versions of the respective qname. --- dist/wgxpath.install-node.js | 9 ++++----- dist/wgxpath.install.js | 9 ++++----- src/functionCall.js | 9 ++++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dist/wgxpath.install-node.js b/dist/wgxpath.install-node.js index d2c2c97..96ff04c 100644 --- a/dist/wgxpath.install-node.js +++ b/dist/wgxpath.install-node.js @@ -37,8 +37,8 @@ function Da(a,b){if(a==b)return 0;if(a.compareDocumentPosition)return a.compareD a:a.ownerDocument||a.document;c=d.createRange();c.selectNode(a);c.collapse(!0);a=d.createRange();a.selectNode(b);a.collapse(!0);return c.compareBoundaryPoints(k.Range.START_TO_END,a)}function Fa(a,b){var c=a.parentNode;if(c==b)return-1;for(;b.parentNode!=c;)b=b.parentNode;return Ea(b,a)}function Ea(a,b){for(;b=b.previousSibling;)if(b==a)return-1;return 1};var w=v&&!(9<=Number(Ba)),Ga=v&&!(8<=Number(Ba));function y(a,b,c,d){this.a=a;this.nodeName=c;this.nodeValue=d;this.nodeType=2;this.parentNode=this.ownerElement=b}function Ha(a,b){var c=Ga&&"href"==b.nodeName?a.getAttribute(b.nodeName,2):b.nodeValue;return new y(b,a,b.nodeName,c)};function z(a){var b=null,c=a.nodeType;1==c&&(b=a.textContent,b=void 0==b||null==b?a.innerText:b,b=void 0==b||null==b?"":b);if("string"!=typeof b)if(w&&"title"==a.nodeName.toLowerCase()&&1==c)b=a.text;else if(9==c||1==c){a=9==c?a.documentElement:a.firstChild;for(var c=0,d=[],b="";a;){do 1!=a.nodeType&&(b+=a.nodeValue),w&&"title"==a.nodeName.toLowerCase()&&(b+=a.text),d[c++]=a;while(a=a.firstChild);for(;c&&!(a=d[--c].nextSibling););}}else b=a.nodeValue;return""+b} function A(a,b,c){if(null===b)return!0;try{if(!a.getAttribute)return!1}catch(d){return!1}Ga&&"class"==b&&(b="className");return null==c?!!a.getAttribute(b):a.getAttribute(b,2)==c}function B(a,b,c,d,e){return(w?Ia:Ja).call(null,a,b,l(c)?c:null,l(d)?d:null,e||new C)} function Ia(a,b,c,d,e){if(a instanceof E||8==a.b||c&&null===a.b){var f=b.all;if(!f)return e;a=Ka(a);if("*"!=a&&(f=b.getElementsByTagName(a),!f))return e;if(c){for(var g=[],h=0;b=f[h++];)A(b,c,d)&&g.push(b);f=g}for(h=0;b=f[h++];)"*"==a&&"!"==b.tagName||F(e,b);return e}La(a,b,c,d,e);return e} -function Ja(a,b,c,d,e){b.getElementsByName&&d&&"name"==c&&!v?(b=b.getElementsByName(d),r(b,function(b){a.a(b)&&F(e,b)})):b.getElementsByClassName&&d&&"class"==c?(b=b.getElementsByClassName(d),r(b,function(b){b.className==d&&a.a(b)&&F(e,b)})):a instanceof G?La(a,b,c,d,e):b.getElementsByTagName&&(b=b.getElementsByTagName(a.f()),r(b,function(a){A(a,c,d)&&F(e,a)}));return e} -function Ma(a,b,c,d,e){var f;if((a instanceof E||8==a.b||c&&null===a.b)&&(f=b.childNodes)){var g=Ka(a);if("*"!=g&&(f=ia(f,function(a){return a.tagName&&a.tagName.toLowerCase()==g}),!f))return e;c&&(f=ia(f,function(a){return A(a,c,d)}));r(f,function(a){"*"==g&&("!"==a.tagName||"*"==g&&1!=a.nodeType)||F(e,a)});return e}return Na(a,b,c,d,e)}function Na(a,b,c,d,e){for(b=b.firstChild;b;b=b.nextSibling)A(b,c,d)&&a.a(b)&&F(e,b);return e} +function Ja(a,b,c,d,e){b.getElementsByName&&d&&"name"==c&&!v?(b=b.getElementsByName(d),r(b,function(b){a.a(b)&&F(e,b)})):b.getElementsByClassName&&d&&"class"==c?(b=b.getElementsByClassName(d),r(b,function(b){b.className==d&&a.a(b)&&F(e,b)})):a instanceof G?La(a,b,c,d,e):b.getElementsByTagName&&(b=b.getElementsByTagName(a.f()),r(b,function(b){a.a(b)&&A(b,c,d)&&F(e,b)}));return e} +function Ma(a,b,c,d,e){var f;if((a instanceof E||8==a.b||c&&null===a.b)&&(f=b.childNodes)){var g=Ka(a);if("*"!=g&&(f=ia(f,function(a){return a.tagName&&a.tagName==g}),!f))return e;c&&(f=ia(f,function(a){return A(a,c,d)}));r(f,function(a){"*"==g&&("!"==a.tagName||"*"==g&&1!=a.nodeType)||F(e,a)});return e}return Na(a,b,c,d,e)}function Na(a,b,c,d,e){for(b=b.firstChild;b;b=b.nextSibling)A(b,c,d)&&a.a(b)&&F(e,b);return e} function La(a,b,c,d,e){for(b=b.firstChild;b;b=b.nextSibling)A(b,c,d)&&a.a(b)&&F(e,b),La(a,b,c,d,e)}function Ka(a){if(a instanceof G){if(8==a.b)return"!";if(null===a.b)return"*"}return a.f()};function C(){this.b=this.a=null;this.l=0}function Oa(a){this.node=a;this.a=this.b=null}function Pa(a,b){if(!a.a)return b;if(!b.a)return a;var c=a.a;b=b.a;for(var d=null,e,f=0;c&&b;){e=c.node;var g=b.node;e==g||e instanceof y&&g instanceof y&&e.a==g.a?(e=c,c=c.a,b=b.a):0",4,2,function(a,b,c){return O(function(a,b){return a>b},a,b,c)});P("<=",4,2 ab.prototype.a=function(a){return this.h.m.apply(null,la(a,this.c))};ab.prototype.toString=function(){var a="Function: "+this.h;if(this.c.length)var b=t(this.c,function(a,b){return a+J(b)},"Arguments:"),a=a+J(b);return a};function bb(a,b,c,d,e,f,g,h,p){this.j=a;this.i=b;this.g=c;this.D=d;this.C=e;this.m=f;this.A=g;this.v=void 0!==h?h:g;this.B=!!p}bb.prototype.toString=function(){return this.j};var cb={}; function R(a,b,c,d,e,f,g,h){if(cb.hasOwnProperty(a))throw Error("Function already created: "+a+".");cb[a]=new bb(a,b,c,d,!1,e,f,g,h)}R("boolean",2,!1,!1,function(a,b){return M(b,a)},1);R("ceiling",1,!1,!1,function(a,b){return Math.ceil(K(b,a))},1);R("concat",3,!1,!1,function(a,b){return t(ma(arguments,1),function(b,d){return b+L(d,a)},"")},2,null);R("contains",2,!1,!1,function(a,b,c){return q(L(b,a),L(c,a))},2);R("count",1,!1,!1,function(a,b){return b.a(a).l},1,1,!0); R("false",2,!1,!1,function(){return!1},0);R("floor",1,!1,!1,function(a,b){return Math.floor(K(b,a))},1);R("id",4,!1,!1,function(a,b){function c(a){if(w){var b=e.all[a];if(b){if(b.nodeType&&a==b.id)return b;if(b.length)return ka(b,function(b){return a==b.id})}return null}return e.getElementById(a)}var d=a.a,e=9==d.nodeType?d:d.ownerDocument;a=L(b,a).split(/\s+/);var f=[];r(a,function(a){a=c(a);!a||0<=ha(f,a)||f.push(a)});f.sort(Da);var g=new C;r(f,function(a){F(g,a)});return g},1); -R("lang",2,!1,!1,function(){return!1},1);R("last",1,!0,!1,function(a){if(1!=arguments.length)throw Error("Function last expects ()");return a.f},0);R("local-name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?a.localName||a.nodeName.toLowerCase():""},0,1,!0);R("name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?a.nodeName.toLowerCase():""},0,1,!0);R("namespace-uri",3,!0,!1,function(){return""},0,1,!0); +R("lang",2,!1,!1,function(){return!1},1);R("last",1,!0,!1,function(a){if(1!=arguments.length)throw Error("Function last expects ()");return a.f},0);R("local-name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?a.localName||a.nodeName:""},0,1,!0);R("name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?void 0!==a.localName?(a.prefix?a.prefix+":":"")+a.localName:a.nodeName.toLowerCase():""},0,1,!0);R("namespace-uri",3,!0,!1,function(){return""},0,1,!0); R("normalize-space",3,!1,!0,function(a,b){return(b?L(b,a):z(a.a)).replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"")},0,1);R("not",2,!1,!1,function(a,b){return!M(b,a)},1);R("number",1,!1,!0,function(a,b){return b?K(b,a):+z(a.a)},0,1);R("position",1,!0,!1,function(a){return a.b},0);R("round",1,!1,!1,function(a,b){return Math.round(K(b,a))},1);R("starts-with",2,!1,!1,function(a,b,c){b=L(b,a);a=L(c,a);return 0==b.lastIndexOf(a,0)},2);R("string",3,!1,!0,function(a,b){return b?L(b,a):z(a.a)},0,1); R("string-length",1,!1,!0,function(a,b){return(b?L(b,a):z(a.a)).length},0,1);R("substring",3,!1,!1,function(a,b,c,d){c=K(c,a);if(isNaN(c)||Infinity==c||-Infinity==c)return"";d=d?K(d,a):Infinity;if(isNaN(d)||-Infinity===d)return"";c=Math.round(c)-1;var e=Math.max(c,0);a=L(b,a);return Infinity==d?a.substring(e):a.substring(e,c+Math.round(d))},2,3);R("substring-after",3,!1,!1,function(a,b,c){b=L(b,a);a=L(c,a);c=b.indexOf(a);return-1==c?"":b.substring(c+a.length)},2); R("substring-before",3,!1,!1,function(a,b,c){b=L(b,a);a=L(c,a);a=b.indexOf(a);return-1==a?"":b.substring(0,a)},2);R("sum",1,!1,!1,function(a,b){a=H(b.a(a));b=0;for(var c=I(a);c;c=I(a))b+=+z(c);return b},1,1,!0);R("translate",3,!1,!1,function(a,b,c,d){b=L(b,a);c=L(c,a);var e=L(d,a);a={};for(d=0;d]=|\s+|./g,hb=/^\s/;function S(a,b){return a.b[a.a+(b||0)]}function T(a){return a.b[a.a++]}function ib(a){return a.b.length<=a.a};function jb(a){n.call(this,3);this.c=a.substring(1,a.length-1)}m(jb);jb.prototype.a=function(){return this.c};jb.prototype.toString=function(){return"Literal: "+this.c};function E(a,b){this.j=a.toLowerCase();a="*"==this.j?"*":"http://www.w3.org/1999/xhtml";this.c=b?b.toLowerCase():a}E.prototype.a=function(a){var b=a.nodeType;if(1!=b&&2!=b)return!1;b=void 0!==a.localName?a.localName:a.nodeName;return"*"!=this.j&&this.j!=b.toLowerCase()?!1:"*"==this.c?!0:this.c==(a.namespaceURI?a.namespaceURI.toLowerCase():"http://www.w3.org/1999/xhtml")};E.prototype.f=function(){return this.j}; -E.prototype.toString=function(){return"Name Test: "+("http://www.w3.org/1999/xhtml"==this.c?"":this.c+":")+this.j};function kb(a){n.call(this,1);this.c=a}m(kb);kb.prototype.a=function(){return this.c};kb.prototype.toString=function(){return"Number: "+this.c};function lb(a,b){n.call(this,a.i);this.h=a;this.c=b;this.g=a.g;this.b=a.b;1==this.c.length&&(a=this.c[0],a.u||a.c!=mb||(a=a.o,"*"!=a.f()&&(this.f={name:a.f(),s:null})))}m(lb);function nb(){n.call(this,4)}m(nb);nb.prototype.a=function(a){var b=new C;a=a.a;9==a.nodeType?F(b,a):F(b,a.ownerDocument);return b};nb.prototype.toString=function(){return"Root Helper Expression"};function ob(){n.call(this,4)}m(ob);ob.prototype.a=function(a){var b=new C;F(b,a.a);return b};ob.prototype.toString=function(){return"Context Helper Expression"}; +G.prototype.toString=function(){var a="Kind Test: "+this.h;null===this.c||(a+=J(this.c));return a};function eb(a){this.b=a;this.a=0}function fb(a){a=a.match(gb);for(var b=0;b]=|\s+|./g,hb=/^\s/;function S(a,b){return a.b[a.a+(b||0)]}function T(a){return a.b[a.a++]}function ib(a){return a.b.length<=a.a};function jb(a){n.call(this,3);this.c=a.substring(1,a.length-1)}m(jb);jb.prototype.a=function(){return this.c};jb.prototype.toString=function(){return"Literal: "+this.c};function E(a,b){this.j=a;a="*"==this.j?"*":"http://www.w3.org/1999/xhtml";this.c=b?b.toLowerCase():a}E.prototype.a=function(a){var b=a.nodeType;if(1!=b&&2!=b)return!1;b=void 0!==a.localName?a.localName:a.nodeName;return"*"!=this.j&&this.j!=b?!1:"*"==this.c?!0:this.c==(a.namespaceURI?a.namespaceURI.toLowerCase():"http://www.w3.org/1999/xhtml")};E.prototype.f=function(){return this.j};E.prototype.toString=function(){return"Name Test: "+("http://www.w3.org/1999/xhtml"==this.c?"":this.c+":")+this.j};function kb(a){n.call(this,1);this.c=a}m(kb);kb.prototype.a=function(){return this.c};kb.prototype.toString=function(){return"Number: "+this.c};function lb(a,b){n.call(this,a.i);this.h=a;this.c=b;this.g=a.g;this.b=a.b;1==this.c.length&&(a=this.c[0],a.u||a.c!=mb||(a=a.o,"*"!=a.f()&&(this.f={name:a.f(),s:null})))}m(lb);function nb(){n.call(this,4)}m(nb);nb.prototype.a=function(a){var b=new C;a=a.a;9==a.nodeType?F(b,a):F(b,a.ownerDocument);return b};nb.prototype.toString=function(){return"Root Helper Expression"};function ob(){n.call(this,4)}m(ob);ob.prototype.a=function(a){var b=new C;F(b,a.a);return b};ob.prototype.toString=function(){return"Context Helper Expression"}; function pb(a){return"/"==a||"//"==a}lb.prototype.a=function(a){var b=this.h.a(a);if(!(b instanceof C))throw Error("Filter expression must evaluate to nodeset.");a=this.c;for(var c=0,d=a.length;c",4,2,function(a,b,c){return O(function(a,b){return a>b},a,b,c)});P("<=",4,2 ab.prototype.a=function(a){return this.h.m.apply(null,la(a,this.c))};ab.prototype.toString=function(){var a="Function: "+this.h;if(this.c.length)var b=t(this.c,function(a,b){return a+J(b)},"Arguments:"),a=a+J(b);return a};function bb(a,b,c,d,e,f,g,h,p){this.j=a;this.i=b;this.g=c;this.D=d;this.C=e;this.m=f;this.A=g;this.v=void 0!==h?h:g;this.B=!!p}bb.prototype.toString=function(){return this.j};var cb={}; function R(a,b,c,d,e,f,g,h){if(cb.hasOwnProperty(a))throw Error("Function already created: "+a+".");cb[a]=new bb(a,b,c,d,!1,e,f,g,h)}R("boolean",2,!1,!1,function(a,b){return M(b,a)},1);R("ceiling",1,!1,!1,function(a,b){return Math.ceil(K(b,a))},1);R("concat",3,!1,!1,function(a,b){return t(ma(arguments,1),function(b,d){return b+L(d,a)},"")},2,null);R("contains",2,!1,!1,function(a,b,c){return q(L(b,a),L(c,a))},2);R("count",1,!1,!1,function(a,b){return b.a(a).l},1,1,!0); R("false",2,!1,!1,function(){return!1},0);R("floor",1,!1,!1,function(a,b){return Math.floor(K(b,a))},1);R("id",4,!1,!1,function(a,b){function c(a){if(w){var b=e.all[a];if(b){if(b.nodeType&&a==b.id)return b;if(b.length)return ka(b,function(b){return a==b.id})}return null}return e.getElementById(a)}var d=a.a,e=9==d.nodeType?d:d.ownerDocument;a=L(b,a).split(/\s+/);var f=[];r(a,function(a){a=c(a);!a||0<=ha(f,a)||f.push(a)});f.sort(Da);var g=new C;r(f,function(a){F(g,a)});return g},1); -R("lang",2,!1,!1,function(){return!1},1);R("last",1,!0,!1,function(a){if(1!=arguments.length)throw Error("Function last expects ()");return a.f},0);R("local-name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?a.localName||a.nodeName.toLowerCase():""},0,1,!0);R("name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?a.nodeName.toLowerCase():""},0,1,!0);R("namespace-uri",3,!0,!1,function(){return""},0,1,!0); +R("lang",2,!1,!1,function(){return!1},1);R("last",1,!0,!1,function(a){if(1!=arguments.length)throw Error("Function last expects ()");return a.f},0);R("local-name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?a.localName||a.nodeName:""},0,1,!0);R("name",3,!1,!0,function(a,b){return(a=b?Ra(b.a(a)):a.a)?void 0!==a.localName?(a.prefix?a.prefix+":":"")+a.localName:a.nodeName.toLowerCase():""},0,1,!0);R("namespace-uri",3,!0,!1,function(){return""},0,1,!0); R("normalize-space",3,!1,!0,function(a,b){return(b?L(b,a):z(a.a)).replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"")},0,1);R("not",2,!1,!1,function(a,b){return!M(b,a)},1);R("number",1,!1,!0,function(a,b){return b?K(b,a):+z(a.a)},0,1);R("position",1,!0,!1,function(a){return a.b},0);R("round",1,!1,!1,function(a,b){return Math.round(K(b,a))},1);R("starts-with",2,!1,!1,function(a,b,c){b=L(b,a);a=L(c,a);return 0==b.lastIndexOf(a,0)},2);R("string",3,!1,!0,function(a,b){return b?L(b,a):z(a.a)},0,1); R("string-length",1,!1,!0,function(a,b){return(b?L(b,a):z(a.a)).length},0,1);R("substring",3,!1,!1,function(a,b,c,d){c=K(c,a);if(isNaN(c)||Infinity==c||-Infinity==c)return"";d=d?K(d,a):Infinity;if(isNaN(d)||-Infinity===d)return"";c=Math.round(c)-1;var e=Math.max(c,0);a=L(b,a);return Infinity==d?a.substring(e):a.substring(e,c+Math.round(d))},2,3);R("substring-after",3,!1,!1,function(a,b,c){b=L(b,a);a=L(c,a);c=b.indexOf(a);return-1==c?"":b.substring(c+a.length)},2); R("substring-before",3,!1,!1,function(a,b,c){b=L(b,a);a=L(c,a);a=b.indexOf(a);return-1==a?"":b.substring(0,a)},2);R("sum",1,!1,!1,function(a,b){a=H(b.a(a));b=0;for(var c=I(a);c;c=I(a))b+=+z(c);return b},1,1,!0);R("translate",3,!1,!1,function(a,b,c,d){b=L(b,a);c=L(c,a);var e=L(d,a);a={};for(d=0;d]=|\s+|./g,hb=/^\s/;function S(a,b){return a.b[a.a+(b||0)]}function T(a){return a.b[a.a++]}function ib(a){return a.b.length<=a.a};function jb(a){n.call(this,3);this.c=a.substring(1,a.length-1)}m(jb);jb.prototype.a=function(){return this.c};jb.prototype.toString=function(){return"Literal: "+this.c};function E(a,b){this.j=a.toLowerCase();a="*"==this.j?"*":"http://www.w3.org/1999/xhtml";this.c=b?b.toLowerCase():a}E.prototype.a=function(a){var b=a.nodeType;if(1!=b&&2!=b)return!1;b=void 0!==a.localName?a.localName:a.nodeName;return"*"!=this.j&&this.j!=b.toLowerCase()?!1:"*"==this.c?!0:this.c==(a.namespaceURI?a.namespaceURI.toLowerCase():"http://www.w3.org/1999/xhtml")};E.prototype.f=function(){return this.j}; -E.prototype.toString=function(){return"Name Test: "+("http://www.w3.org/1999/xhtml"==this.c?"":this.c+":")+this.j};function kb(a){n.call(this,1);this.c=a}m(kb);kb.prototype.a=function(){return this.c};kb.prototype.toString=function(){return"Number: "+this.c};function lb(a,b){n.call(this,a.i);this.h=a;this.c=b;this.g=a.g;this.b=a.b;1==this.c.length&&(a=this.c[0],a.u||a.c!=mb||(a=a.o,"*"!=a.f()&&(this.f={name:a.f(),s:null})))}m(lb);function nb(){n.call(this,4)}m(nb);nb.prototype.a=function(a){var b=new C;a=a.a;9==a.nodeType?F(b,a):F(b,a.ownerDocument);return b};nb.prototype.toString=function(){return"Root Helper Expression"};function ob(){n.call(this,4)}m(ob);ob.prototype.a=function(a){var b=new C;F(b,a.a);return b};ob.prototype.toString=function(){return"Context Helper Expression"}; +G.prototype.toString=function(){var a="Kind Test: "+this.h;null===this.c||(a+=J(this.c));return a};function eb(a){this.b=a;this.a=0}function fb(a){a=a.match(gb);for(var b=0;b]=|\s+|./g,hb=/^\s/;function S(a,b){return a.b[a.a+(b||0)]}function T(a){return a.b[a.a++]}function ib(a){return a.b.length<=a.a};function jb(a){n.call(this,3);this.c=a.substring(1,a.length-1)}m(jb);jb.prototype.a=function(){return this.c};jb.prototype.toString=function(){return"Literal: "+this.c};function E(a,b){this.j=a;a="*"==this.j?"*":"http://www.w3.org/1999/xhtml";this.c=b?b.toLowerCase():a}E.prototype.a=function(a){var b=a.nodeType;if(1!=b&&2!=b)return!1;b=void 0!==a.localName?a.localName:a.nodeName;return"*"!=this.j&&this.j!=b?!1:"*"==this.c?!0:this.c==(a.namespaceURI?a.namespaceURI.toLowerCase():"http://www.w3.org/1999/xhtml")};E.prototype.f=function(){return this.j};E.prototype.toString=function(){return"Name Test: "+("http://www.w3.org/1999/xhtml"==this.c?"":this.c+":")+this.j};function kb(a){n.call(this,1);this.c=a}m(kb);kb.prototype.a=function(){return this.c};kb.prototype.toString=function(){return"Number: "+this.c};function lb(a,b){n.call(this,a.i);this.h=a;this.c=b;this.g=a.g;this.b=a.b;1==this.c.length&&(a=this.c[0],a.u||a.c!=mb||(a=a.o,"*"!=a.f()&&(this.f={name:a.f(),s:null})))}m(lb);function nb(){n.call(this,4)}m(nb);nb.prototype.a=function(a){var b=new C;a=a.a;9==a.nodeType?F(b,a):F(b,a.ownerDocument);return b};nb.prototype.toString=function(){return"Root Helper Expression"};function ob(){n.call(this,4)}m(ob);ob.prototype.a=function(a){var b=new C;F(b,a.a);return b};ob.prototype.toString=function(){return"Context Helper Expression"}; function pb(a){return"/"==a||"//"==a}lb.prototype.a=function(a){var b=this.h.a(a);if(!(b instanceof C))throw Error("Filter expression must evaluate to nodeset.");a=this.c;for(var c=0,d=a.length;c