Class SelectionParser


  • public class SelectionParser
    extends XPathParser
    This class parses the two XPath subsets defined in XML Schema for handling the "selector" and "field" attributes of the <unique>, <key>, and <keyref> elements.
    • Constructor Detail

    • Method Detail

      • parseSelector

        public Pattern parseSelector​(java.lang.String expression,
                                     StaticContext env,
                                     boolean isField)
                              throws XPathException
        Parse a string representing the restricted XPath expression allowed in an XML Schema selector or field attribute
        Parameters:
        expression - the expression expressed as a String
        env - the static context for the expression
        isField - true if the attribute is a "field" attribute, false if it is a "selector" attribute
        Returns:
        a Pattern object representing the result of parsing. The expression equivalent to this pattern may be obtained by calling getOptimizedExpression().
        Throws:
        XPathException - if the expression contains a syntax error
      • parseRelativePath

        protected Expression parseRelativePath()
                                        throws XPathException
        Description copied from class: XPathParser
        Parse a relative path (a sequence of steps). Called when the current token immediately follows a separator (/ or //), or an implicit separator (XYZ is equivalent to ./XYZ)
        Overrides:
        parseRelativePath in class XPathParser
        Returns:
        the resulting subexpression
        Throws:
        XPathException - if any error is encountered
      • parseStepExpression

        protected Expression parseStepExpression()
                                          throws XPathException
        Override the general XPath parsing of a StepExpression to support the simpler kind of Step used in XML Schema selectors
        Returns:
        an Expression, which will always be either an AxisExpression or a ContextItemExpression
        Throws:
        XPathException - if parsing fails
      • getOptimizedExpression

        public Expression getOptimizedExpression()
        After parsing a selector, return the optimized version of the XPath expression that was parsed
        Returns:
        the optimized XPath expression equivalent to the pattern that was created by parsing the selector