if ((firstVariable > 0 && // the xpath references a variable
firstFunction > 0) || // the xpath contains a function
(firstVariable < lastVariable)) { // the xpath references multiple variables
// most likely, the variable reference has not been resolved, so make that happen
boolean quoted = false, doubleQuoted = false, variable = false;
Name11Checker nameChecker = Name11Checker.getInstance();
for (int index = 0; index < xpathStr.length(); index++) {
char ch = xpathStr.charAt(index);
if (ch == '\''){
quoted = !quoted;
}
if (ch == '\"') {
doubleQuoted = !doubleQuoted;
}
if (quoted || doubleQuoted){
continue;
}
if (ch == '$') {
variable = true;
variableExpr.setLength(0);
variableExpr.append(ch);
} else {
if (variable) {
variableExpr.append(ch);
// in the name is qualified, don't check if its a qname when we're at the ":" character
if (ch == ':') {
continue;
}
if (index == xpathStr.length() ||
!nameChecker.isQName(variableExpr.substring(1))) {
variable = false;
variableExpr.setLength(variableExpr.length() - 1);
variableExprs.add(variableExpr.toString());
variableExpr.setLength(0);
}