Package net.sf.saxon.pattern
Class PatternParser
java.lang.Object
net.sf.saxon.expr.parser.ExpressionParser
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.ExpressionParser
ExpressionParser.TemporaryContainer -
Field Summary
FieldsFields inherited from class net.sf.saxon.expr.parser.ExpressionParser
allowXPath30Syntax, codeInjector, defaultContainer, env, language, languageVersion, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCallback to tailor the tokenizermakeTracer(int startOffset, Expression exp, int construct, StructuredQName qName) If tracing, wrap an expression in a trace instructionprotected ExpressionparseBasicStep(boolean firstInPattern) Parse a basic step expression (without the predicates)Override the parsing of top-level expressionsParse an argument to a function call.protected ExpressionParse a function call appearing within a pattern.parsePattern(String pattern, StaticContext env) Parse a string representing an XSLT patternprotected ExpressionParse an expression appearing within a predicate.protected ExpressionParse a type pattern of the form "~ ItemType" (introduced in XSLT 3.0)protected voidtestPermittedAxis(byte axis) Methods inherited from class net.sf.saxon.expr.parser.ExpressionParser
atStartOfRelativePath, currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, findRangeVariable, getCodeInjector, getDefaultContainer, getLanguage, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, grumble, grumble, isKeyword, isNamespaceTestAllowed, makeCurriedFunction, makeLocalNameTest, makeNameCode, makeNameCodeSilently, makeNamespaceTest, makeNameTest, makeNodeName, makeStringLiteral, makeStructuredQName, nextToken, normalizeEQName, parse, parseBinaryExpression, parseConstructor, parseDynamicFunctionCall, parseExprSingle, parseExtensionExpression, parseFLWORExpression, parseFunctionItemType, parseInlineFunction, parseItemType, parseLiteralFunctionItem, parseMapExpression, parseMapItemType, parseNodeTest, parseNumericLiteral, parseParenthesizedItemType, parsePathExpression, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseStepExpression, parseStringLiteral, parseSwitchExpression, parseTryCatchExpression, parseTypeswitchExpression, parseValidateExpression, parseVariableReference, reportMissingFunction, resolveFunctionName, setCodeInjector, setDefaultContainer, setLanguage, setLocation, setLocation, setLocation, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warning
-
Field Details
-
inPredicate
int inPredicate
-
-
Constructor Details
-
PatternParser
public 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:
customizeTokenizerin classExpressionParser- Parameters:
t- the Tokenizer to be customized
-
parseExpression
Override the parsing of top-level expressions- Overrides:
parseExpressionin classExpressionParser- Returns:
- the parsed expression
- Throws:
XPathException
-
parseBasicStep
Parse a basic step expression (without the predicates)- Overrides:
parseBasicStepin classExpressionParser- 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:
testPermittedAxisin classExpressionParser- Throws:
XPathException
-
parseTypePattern
Parse a type pattern of the form "~ ItemType" (introduced in XSLT 3.0)- Overrides:
parseTypePatternin classExpressionParser- 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
Parse an expression appearing within a predicate. This enables full XPath parsing, without the normal rules that apply within an XSLT pattern- Overrides:
parsePredicatein classExpressionParser- Returns:
- the parsed expression that appears within the predicate
- Throws:
XPathException
-
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:
parseFunctionCallin classExpressionParser- Returns:
- the expression that results from the parsing (usually a FunctionCall)
- Throws:
XPathException
-
parseFunctionArgument
Description copied from class:ExpressionParserParse 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:
parseFunctionArgumentin classExpressionParser- 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:ExpressionParserIf tracing, wrap an expression in a trace instruction- Overrides:
makeTracerin classExpressionParser- Parameters:
startOffset- the position of the expression in the soruceexp- the expression to be wrappedconstruct- integer constant identifying the kind of constructqName- the name of the construct (if applicable)- Returns:
- the expression that does the tracing
-