// , + ~ >\r
"\\s*(\\+|~|>)\\s*", "$1",\r
//* ~ + >\r
- "([a-zA-Z0-9_\\-\\*])~([a-zA-Z0-9_\\-\\*])", "$1/following-sibling::$2",\r
- "([a-zA-Z0-9_\\-\\*])\\+([a-zA-Z0-9_\\-\\*])", "$1/following-sibling::*[1]/self::$2",\r
- "([a-zA-Z0-9_\\-\\*])>([a-zA-Z0-9_\\-\\*])", "$1/$2",\r
+ "([\\w\\-\\*])~([\\w\\-\\*])", "$1/following-sibling::$2",\r
+ "([\\w\\-\\*])\\+([\\w\\-\\*])", "$1/following-sibling::*[1]/self::$2",\r
+ "([\\w\\-\\*])>([\\w\\-\\*])", "$1/$2",\r
// all unescaped stuff escaped\r
"\\[([^=]+)=([^'|\"][^\\]]*)\\]", "[$1='$2']",\r
// all descendant or self to \r
- "(^|[^a-zA-Z0-9_\\-\\*])(#|\\.)([a-zA-Z0-9_\\-]+)", "$1*$2$3",\r
+ "(^|[^\\w\\-\\*])(#|\\.)([\\w\\-]+)", "$1*$2$3",\r
"([\\>\\+\\|\\~\\,\\s])([a-zA-Z\\*]+)", "$1//$2",\r
"\\s+//", "//",\r
// :first-child\r
- "([a-zA-Z0-9_\\-\\*]+):first-child", "*[1]/self::$1",\r
+ "([\\w\\-\\*]+):first-child", "*[1]/self::$1",\r
// :last-child\r
- "([a-zA-Z0-9_\\-\\*]+):last-child", "$1[not(following-sibling::*)]",\r
+ "([\\w\\-\\*]+):last-child", "$1[not(following-sibling::*)]",\r
// :only-child\r
- "([a-zA-Z0-9_\\-\\*]+):only-child", "*[last()=1]/self::$1",\r
+ "([\\w\\-\\*]+):only-child", "*[last()=1]/self::$1",\r
// :empty\r
- "([a-zA-Z0-9_\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",\r
+ "([\\w\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",\r
"(.+):not\\(([^\\)]*)\\)", rc_Not,\r
"([a-zA-Z0-9\\_\\-\\*]+):nth-child\\(([^\\)]*)\\)", rc_nth_child,\r
// :contains(selectors)\r
":contains\\(([^\\)]*)\\)", "[contains(string(.),'$1')]",\r
// |= attrib\r
- "\\[([a-zA-Z0-9_\\-]+)\\|=([^\\]]+)\\]", "[@$1=$2 or starts-with(@$1,concat($2,'-'))]",\r
+ "\\[([\\w\\-]+)\\|=([^\\]]+)\\]", "[@$1=$2 or starts-with(@$1,concat($2,'-'))]",\r
// *= attrib\r
- "\\[([a-zA-Z0-9_\\-]+)\\*=([^\\]]+)\\]", "[contains(@$1,$2)]",\r
+ "\\[([\\w\\-]+)\\*=([^\\]]+)\\]", "[contains(@$1,$2)]",\r
// ~= attrib\r
- "\\[([a-zA-Z0-9_\\-]+)~=([^\\]]+)\\]", "[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",\r
+ "\\[([\\w\\-]+)~=([^\\]]+)\\]", "[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",\r
// ^= attrib\r
- "\\[([a-zA-Z0-9_\\-]+)\\^=([^\\]]+)\\]", "[starts-with(@$1,$2)]",\r
+ "\\[([\\w\\-]+)\\^=([^\\]]+)\\]", "[starts-with(@$1,$2)]",\r
// $= attrib\r
- "\\[([a-zA-Z0-9_\\-]+)\\$=([^\\]]+)\\]", rc_$Attr,\r
+ "\\[([\\w\\-]+)\\$=([^\\]]+)\\]", rc_$Attr,\r
// != attrib\r
- "\\[([a-zA-Z0-9_\\-]+)\\!=([^\\]]+)\\]", "[not(@$1) or @$1!=$2]",\r
+ "\\[([\\w\\-]+)\\!=([^\\]]+)\\]", "[not(@$1) or @$1!=$2]",\r
// ids and classes\r
- "#([a-zA-Z0-9_\\-]+)", "[@id='$1']",\r
- "\\.([a-zA-Z0-9_\\-]+)", "[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",\r
+ "#([\\w\\-]+)", "[@id='$1']",\r
+ "\\.([\\w\\-]+)", "[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",\r
// normalize multiple filters\r
"\\]\\[([^\\]]+)", " and ($1)",\r
// tag:pseudo\r
- ":enabled", "[not(@disabled)]",\r
- ":checked", "[@checked='checked']",\r
+ ":(enabled)", "[not(@disabled)]",\r
+ ":(checked)", "[@$1='$1']",\r
":(disabled)", "[@$1]",\r
// put '*' when tag is omitted\r
- "^\\[", "*[",\r
- "\\|\\[", "|*["\r
+ "(^|\\|)(\\[)", "$1*$2"\r
};\r
\r
public static SelectorEngineCssToXPath getInstance() {\r