boolean (XPathStep step) { XPathExpression prev = step.getPreviousStep(); if (prev instanceof XPathFilterExpression) { prev = ((XPathFilterExpression)prev).getExpression(); if (prev != null && !(prev instanceof XPathStep)) { // stuff like key('', '')[1]/xxx is invalid: "The filtered expression in a pattern must be a simple step" return false; } } if (prev instanceof XPathStep) { if (!checkStep((XPathStep)prev)) { return false; } } else if (prev instanceof XPathFunctionCall) { if (!checkIdKeyPattern(prev)) { return false; } } else if (step.getStep() != null || prev != null) { return false; } final XPathAxisSpecifier axisSpecifier = step.getAxisSpecifier(); if (axisSpecifier != null) { if ((axisSpecifier.getAxis() == Axis.CHILD || axisSpecifier.getAxis() == Axis.ATTRIBUTE)) { return true; } } else { return true; } return false; }