Class PatternParser


  • public class PatternParser
    extends ExpressionParser
    Parser for XSLT patterns. This is created by overriding selected parts of the standard ExpressionParser.
    • Field Detail

      • inPredicate

        int inPredicate
    • Constructor Detail

      • PatternParser

        public PatternParser()
    • Method Detail

      • parsePattern

        public Pattern parsePattern​(java.lang.String pattern,
                                    StaticContext env)
                             throws XPathException
        Parse a string representing an XSLT pattern
        Parameters:
        pattern - the pattern expressed as a String
        env - the static context for the pattern
        Returns:
        a Pattern object representing the result of parsing
        Throws:
        XPathException - if the pattern contains a syntax error
      • parseBasicStep

        protected Expression parseBasicStep​(boolean firstInPattern)
                                     throws XPathException
        Parse a basic step expression (without the predicates)
        Overrides:
        parseBasicStep in class ExpressionParser
        Parameters:
        firstInPattern - true only if we are parsing the first step in a RelativePathPattern in the XSLT Pattern syntax
        Returns:
        the resulting subexpression
        Throws:
        XPathException - if any error is encountered
      • parseTypePattern

        protected Expression parseTypePattern()
                                       throws XPathException
        Parse a type pattern of the form "~ ItemType" (introduced in XSLT 3.0)
        Overrides:
        parseTypePattern in class ExpressionParser
        Returns:
        the type pattern, wrapped in a PatternSponsor to satisfy the parsing interface
        Throws:
        XPathException - if any error is found, for example if XSLT 3.0 is not enabled
      • parsePredicate

        protected Expression parsePredicate()
                                     throws XPathException
        Parse an expression appearing within a predicate. This enables full XPath parsing, without the normal rules that apply within an XSLT pattern
        Overrides:
        parsePredicate in class ExpressionParser
        Returns:
        the parsed expression that appears within the predicate
        Throws:
        XPathException
      • parseFunctionCall

        protected Expression parseFunctionCall()
                                        throws XPathException
        Parse a function call appearing within a pattern. Unless within a predicate, this imposes the constraints on which function calls are allowed to appear in a pattern
        Overrides:
        parseFunctionCall in class ExpressionParser
        Returns:
        the expression that results from the parsing (usually a FunctionCall)
        Throws:
        XPathException
      • parseFunctionArgument

        public Expression parseFunctionArgument()
                                         throws XPathException
        Description copied from class: ExpressionParser
        Parse an argument to a function call. Separate method so it can be overridden. With higher-order-function syntax in XPath 3.0/XQuery 3.0, this returns null if the pseudo-argument "?" is found.
        Overrides:
        parseFunctionArgument in class ExpressionParser
        Returns:
        the Expression used as the argument, or null if the argument is the place-holder "?"
        Throws:
        XPathException - if the argument expression does not parse correctly
      • makeTracer

        public Expression makeTracer​(int startOffset,
                                     Expression exp,
                                     int construct,
                                     StructuredQName qName)
        Description copied from class: ExpressionParser
        If tracing, wrap an expression in a trace instruction
        Overrides:
        makeTracer in class ExpressionParser
        Parameters:
        startOffset - the position of the expression in the soruce
        exp - the expression to be wrapped
        construct - integer constant identifying the kind of construct
        qName - the name of the construct (if applicable)
        Returns:
        the expression that does the tracing