Package net.sf.saxon.pattern
Class PatternParser
java.lang.Object
net.sf.saxon.expr.parser.XPathParser
net.sf.saxon.pattern.PatternParser
Parser for XSLT patterns. This is created by overriding selected parts of the standard ExpressionParser.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.expr.parser.XPathParser
XPathParser.Accelerator, XPathParser.InlineFunctionDetails, XPathParser.NestedLocation, XPathParser.ParsedLanguage
-
Field Summary
Fields inherited from class net.sf.saxon.expr.parser.XPathParser
allowSaxonExtensions, allowXPath30Syntax, allowXPath30XSLTExtensions, allowXPath31Syntax, allowXPath40Syntax, catchDepth, charChecker, codeInjector, env, inlineFunctionStack, language, languageVersion, parserExtension, qNameParser, rangeVariables, scanOnly, t
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Callback to tailor the tokenizermakeTracer
(Expression exp, StructuredQName qName) If tracing, wrap an expression in a trace instructionprotected Expression
parseBasicStep
(boolean firstInPattern) Parse a basic step expression (without the predicates)Override the parsing of top-level expressionsParse an argument to a function call.parseFunctionCall
(Expression prefixArgument) Parse a function call appearing within a pattern.parsePattern
(String pattern, StaticContext env) Parse a string representing an XSLT patternprotected Expression
Parse an expression appearing within a predicate.protected void
testPermittedAxis
(int axis, String errorCode) Methods inherited from class net.sf.saxon.expr.parser.XPathParser
atStartOfRelativePath, checkLanguageVersion30, checkLanguageVersion31, checkLanguageVersion40, checkMapExtensions, checkSyntaxExtensions, createDynamicCurriedFunction, currentTokenDisplay, curryFunction, declareRangeVariable, disallowedAtStartOfRelativePath, expect, findOuterRangeVariable, findOuterRangeVariable, findRangeVariable, generateApplyCall, getCodeInjector, getLanguage, getMissingFunctionExplanation, getPlainType, getQNameParser, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, grumble, grumble, handleExternalFunctionDeclaration, isAllowAbsentExpression, isAllowXPath31Syntax, isKeyword, isNamespaceTestAllowed, isReservedFunctionName, isReservedInQuery, makeCurriedFunction, makeFingerprint, makeInlineFunctionValue, makeLocalNameTest, makeLocation, makeLocation, makeNamespaceTest, makeNameTest, makeNestedLocation, makeNodeName, makeQNameTest, makeStringLiteral, makeStructuredQName, makeStructuredQNameSilently, nextToken, operatorPrecedence, parse, parseAnnotationsList, parseArrayCurlyConstructor, parseArrayItemType, parseArraySquareConstructor, parseArrowPostfix, parseBackTickedStringLiteral, parseBinaryExpression, parseBinaryLiteral, parseConstructor, parseDynamicFunctionCall, parseEnumType, parseExprSingle, parseExtendedItemType, parseExtendedSequenceType, parseExtensionExpression, parseFLWORExpression, parseFocusFunction, parseFunctionItemType, parseHexLiteral, parseInlineFunction, parseInlineFunctionBody, parseItemType, parseLambdaParams, parseLookup, parseMapExpression, parseMapItemType, parseMappingArrowPostfix, parseNamedFunctionReference, parseNameTestUnion, parseNodeTest, parseNumericLiteral, parseOccurrenceIndicator, parseParenthesizedExpression, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseSimpleMappingExpression, parseStepExpression, parseStringConstructor, parseStringLiteral, parseStringTemplate, parseSwitchExpression, parseTryCatchExpression, parseTypeswitchExpression, parseUnionNodeTest, parseUnionType, parseValidateExpression, parseVariableName, reportMissingFunction, resolveFunctionName, resolveVariableReference, setAccelerator, setAllowAbsentExpression, setCatchDepth, setCodeInjector, setLanguage, setLocation, setLocation, setLocation, setParserExtension, setQNameParser, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, unescape, warning, whyDisallowedType
-
Constructor Details
-
PatternParser
-
-
Method Details
-
parsePattern
Parse a string representing an XSLT pattern- Parameters:
pattern
- the pattern expressed as a Stringenv
- the static context for the pattern- Returns:
- a Pattern object representing the result of parsing
- Throws:
XPathException
- if the pattern contains a syntax error
-
customizeTokenizer
Callback to tailor the tokenizer- Overrides:
customizeTokenizer
in classXPathParser
- Parameters:
t
- the Tokenizer to be customized
-
parseExpression
Override the parsing of top-level expressions- Overrides:
parseExpression
in classXPathParser
- Returns:
- the parsed expression
- Throws:
XPathException
- if the pattern is invalid
-
parseBasicStep
Parse a basic step expression (without the predicates)- Overrides:
parseBasicStep
in classXPathParser
- 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
-
testPermittedAxis
- Overrides:
testPermittedAxis
in classXPathParser
- Throws:
XPathException
-
parsePredicate
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 classXPathParser
- Returns:
- the parsed expression that appears within the predicate
- Throws:
XPathException
- if the predicate is invalid
-
parseFunctionCall
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 classXPathParser
- Parameters:
prefixArgument
- left hand operand of arrow operator, or null in the case of a conventional function call- Returns:
- the expression that results from the parsing (usually a FunctionCall)
- Throws:
XPathException
- if the function call is invalid
-
parseFunctionArgument
Description copied from class:XPathParser
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 classXPathParser
- 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
Description copied from class:XPathParser
If tracing, wrap an expression in a trace instructionNB, this no longer happens. Instead of creating trace expressions in the course of parsing and buildint the expression tree, trace code is now injected into the tree after the event, when parsing is complete. See
ExpressionTool.injectCode(Expression, CodeInjector)
.However, the method has another effect, which is to set the retainedStaticContext in the node in the expression tree.
- Overrides:
makeTracer
in classXPathParser
- Parameters:
exp
- the expression to be wrappedqName
- the name of the construct (if applicable)- Returns:
- the expression that does the tracing
-