public class XPathParser
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
XPathParser.NestedLocation
A nested location: for use with XPath expressions and queries nested within some
larger document.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
allowXPath30Syntax |
protected boolean |
allowXPath31Syntax |
protected int |
catchDepth |
protected IntPredicate |
charChecker |
protected CodeInjector |
codeInjector |
protected StaticContext |
env |
static int |
EXTENDED_ITEM_TYPE |
protected int |
language |
protected int |
languageVersion |
protected ParserExtension |
parserExtension |
protected QNameParser |
qNameParser |
protected java.util.Stack<LocalBinding> |
rangeVariables |
protected boolean |
scanOnly |
static int |
SEQUENCE_TYPE |
protected Tokenizer |
t |
static int |
XPATH |
static int |
XQUERY |
static int |
XSLT_PATTERN |
Constructor and Description |
---|
XPathParser()
Create an expression parser
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
atStartOfRelativePath()
Test whether the current token is one that can start a RelativePathExpression
|
void |
checkHofFeature()
Check that the higher-order-function feature is licensed
|
protected void |
checkLanguageVersion30()
Check that XPath 3.0 is in use
|
protected void |
checkLanguageVersion31()
Check that XPath 3.1 is in use
|
void |
checkSyntaxExtensions(java.lang.String construct)
Check that Saxon syntax extensions are permitted
|
protected java.lang.String |
currentTokenDisplay()
Display the current token in an error message
|
protected void |
customizeTokenizer(Tokenizer t)
Callback to tailor the tokenizer
|
void |
declareRangeVariable(LocalBinding declaration)
Declare a range variable (record its existence within the parser).
|
protected boolean |
disallowedAtStartOfRelativePath()
Test whether the current token is one that is disallowed after a "leading lone slash".
|
void |
expect(int token)
Expect a given token; fail if the current token is different.
|
protected LocalBinding |
findRangeVariable(StructuredQName qName)
Locate a range variable with a given name.
|
protected Expression |
generateApplyCall(Expression functionItem,
java.util.ArrayList<Expression> args) |
CodeInjector |
getCodeInjector()
Set a CodeInjector which can be used to modify or wrap expressions on the tree
as the expression is parsed and the tree is constructed.
|
protected java.lang.String |
getLanguage()
Get the current language (XPath or XQuery)
|
static java.lang.String |
getMissingFunctionExplanation(StructuredQName functionName,
Configuration config)
Get a message containing suggestions as to why a requested function might not be available
|
ItemType |
getPlainType(StructuredQName sq) |
QNameParser |
getQNameParser()
Get the QNameParser to be used while parsing
|
java.util.Stack<LocalBinding> |
getRangeVariables()
Get the stack of in-scope range variables
|
StaticContext |
getStaticContext()
Get the static context used by this expression parser
|
Tokenizer |
getTokenizer()
Get the tokenizer (the lexical analyzer)
|
void |
grumble(java.lang.String message)
Report a syntax error (a static error with error code XPST0003)
|
void |
grumble(java.lang.String message,
java.lang.String errorCode)
Report a static error
|
void |
grumble(java.lang.String message,
java.lang.String errorCode,
int offset)
Report a static error, with location information
|
protected void |
grumble(java.lang.String message,
StructuredQName errorCode,
int offset)
Report a static error
|
boolean |
isAllowAbsentExpression(boolean allowEmpty)
Ask whether an absent expression is permitted
|
boolean |
isAllowXPath31Syntax()
Ask if XPath 3.1 is in use
|
protected boolean |
isKeyword(java.lang.String s)
Test whether the current token is a given keyword.
|
protected boolean |
isNamespaceTestAllowed()
Ask whether the syntax namespace-node() is allowed in a node kind test.
|
protected static boolean |
isReservedFunctionName30(java.lang.String name)
Check whether a function name is reserved in XPath 3.0 (when unprefixed)
|
static boolean |
isReservedFunctionName31(java.lang.String name)
Check whether a function name is reserved in XPath 3.1 (when unprefixed)
|
protected boolean |
isReservedInQuery(java.lang.String uri) |
protected Expression |
makeCurriedFunction(int offset,
StructuredQName name,
Expression[] args,
IntSet placeMarkers)
Process a function call in which one or more of the argument positions are
represented as "?" placemarkers (indicating partial application or currying)
|
int |
makeFingerprint(java.lang.String qname,
boolean useDefault)
Make a NameCode, using the static context for namespace resolution
|
LocalNameTest |
makeLocalNameTest(short nodeType,
java.lang.String localName)
Make a LocalNameTest (*:name)
|
Location |
makeLocation() |
NamespaceTest |
makeNamespaceTest(short nodeType,
java.lang.String prefix)
Make a NamespaceTest (name:*)
|
NameTest |
makeNameTest(short nodeType,
java.lang.String qname,
boolean useDefault)
Make a NameTest, using the static context for namespace resolution
|
Location |
makeNestedLocation(Location containingLoc,
int line,
int column,
java.lang.String nearbyText)
Make a Location object relative to an existing location
|
NodeName |
makeNodeName(java.lang.String qname,
boolean useDefault)
Make a FingerprintedQName, using the static context for namespace resolution
|
protected Literal |
makeStringLiteral(java.lang.String currentTokenValue)
Method to make a string literal from a token identified as a string
literal.
|
StructuredQName |
makeStructuredQName(java.lang.String qname,
java.lang.String defaultUri)
Make a Structured QName, using the static context for namespace resolution
|
StructuredQName |
makeStructuredQNameSilently(java.lang.String qname,
java.lang.String defaultUri)
Make a NameCode, using the static context for namespace resolution.
|
Expression |
makeTracer(int startOffset,
Expression exp,
int construct,
StructuredQName qName)
If tracing, wrap an expression in a trace instruction
|
void |
nextToken()
Read the next token, catching any exception thrown by the tokenizer
|
static int |
operatorPrecedence(int operator)
Get the precedence associated with a given operator
|
Expression |
parse(java.lang.String expression,
int start,
int terminator,
StaticContext env)
Parse a string representing an expression.
|
protected AnnotationList |
parseAnnotationsList()
Parse the annotations that can appear in a variable or function declaration
|
protected Expression |
parseArrayCurlyConstructor()
Parse a "curly" array constructor
array "{" expr "}"
Applies to XPath/XQuery 3.1 only
|
protected ItemType |
parseArrayItemType()
Get the item type used for array items (XPath 3.1)
Syntax:
array '(' '*' ') |
array '(' SeqType ')'
The "array(" has already been read
|
protected Expression |
parseArraySquareConstructor()
Parse a "square" array constructor
"[" (exprSingle ("," exprSingle)* )? "]"
Applies to XPath/XQuery 3.1 only
|
protected Expression |
parseArrowPostfix(Expression lhs)
Parse an XPath 3.1 arrow operator ("=>")
|
protected Expression |
parseBasicStep(boolean firstInPattern)
Parse a basic step expression (without the predicates)
|
Expression |
parseBinaryExpression(Expression lhs,
int minPrecedence)
Parse a binary expression, using operator precedence parsing.
|
protected Expression |
parseConstructor()
Parse a node constructor.
|
Expression |
parseDynamicFunctionCall(Expression functionItem,
Expression prefixArgument)
Parse a dynamic function call
|
Expression |
parseExpression()
Parse a top-level Expression:
ExprSingle ( ',' ExprSingle )*
|
Expression |
parseExprSingle()
Parse an ExprSingle
|
ItemType |
parseExtendedItemType(java.lang.String input,
StaticContext env)
Parse a string representing an extended item type: specifically, the content of itemType
or nodeTest attributes in an exported package.
|
SequenceType |
parseExtendedSequenceType(java.lang.String input,
StaticContext env)
Parse a string representing a sequence type with syntax extensions used in exported stylesheets;
also allows Saxon-specific extensions to SequenceType syntax, such as tuple types.
|
protected Expression |
parseExtensionExpression()
Parse an Extension Expression
This construct is XQuery-only, so the XPath version of this
method throws an error unconditionally
|
protected Expression |
parseFLWORExpression()
Parse a FOR or LET expression:
for $x in expr (',' $y in expr)* 'return' expr
let $x := expr (', $y := expr)* 'return' expr
This version of the method handles the subset of the FLWOR syntax allowed in XPath
|
Expression |
parseFunctionArgument()
Parse an argument to a function call.
|
Expression |
parseFunctionCall(Expression prefixArgument)
Parse a function call.
|
protected ItemType |
parseFunctionItemType(AnnotationList annotations)
Get the item type used for function items (XPath 3.0 higher order functions)
|
protected Expression |
parseInlineFunction(AnnotationList annotations)
Parse an inline function
"function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr
On entry, "function (" has already been read
|
ItemType |
parseItemType()
Parse an ItemType within a SequenceType
|
protected Expression |
parseLookup(Expression lhs)
Parse a lookup operator ("?")
|
protected Expression |
parseMapExpression()
Parse a map expression.
|
protected ItemType |
parseMapItemType()
Parse the item type used for maps (XSLT extension to XPath 3.0)
Syntax:
map '(' '*' ') |
map '(' ItemType ',' SeqType ')' 'as' SeqType
The "map(" has already been read
|
protected Expression |
parseNamedFunctionReference()
Parse a literal function item (introduced in XQuery 1.1)
Syntax: QName # integer
The QName and # have already been read
|
protected NodeTest |
parseNodeTest(short nodeType)
Parse a NodeTest.
|
Expression |
parseNumericLiteral(boolean traceable) |
Expression |
parseParenthesizedExpression() |
protected Expression |
parsePathExpression()
Parse a PathExpresssion.
|
protected Expression |
parsePredicate()
Parse the expression within a predicate.
|
protected Expression |
parseRelativePath()
Parse a relative path (a sequence of steps).
|
protected Expression |
parseRemainingPath(Expression start)
Parse the remaining steps of an absolute path expression (one starting in "/" or "//").
|
SequenceType |
parseSequenceType()
Parse the sequence type production.
|
SequenceType |
parseSequenceType(java.lang.String input,
StaticContext env)
Parse a string representing a sequence type
|
protected Expression |
parseSimpleMappingExpression()
Parse an XPath 3.0 simple mapping expression ("!" operator)
|
protected Expression |
parseStepExpression(boolean firstInPattern)
Parse a step (including an optional sequence of predicates)
|
protected Expression |
parseStringLiteral(boolean traceable) |
protected Expression |
parseStringTemplate(boolean complete) |
protected Expression |
parseSwitchExpression()
Parse a Switch Expression.
|
protected Expression |
parseTryCatchExpression()
Parse a try/catch Expression
This construct is XQuery-3.0 only, so the XPath version of this
method throws an error unconditionally
|
protected Expression |
parseTypeswitchExpression()
Parse a Typeswitch Expression.
|
protected Expression |
parseValidateExpression()
Parse a Validate Expression.
|
Expression |
parseVariableReference() |
Expression |
reportMissingFunction(int offset,
StructuredQName functionName,
Expression[] arguments) |
protected StructuredQName |
resolveFunctionName(java.lang.String fname)
Interpret a function name, returning it as a resolved QName
|
void |
setAllowAbsentExpression(boolean allowEmpty)
Say whether an absent expression is permitted
|
void |
setCatchDepth(int depth)
Set the depth of nesting within try/catch
|
void |
setCodeInjector(CodeInjector injector)
Set a CodeInjector which can be used to modify or wrap expressions on the tree
as the expression is parsed and the tree is constructed.
|
void |
setLanguage(int language,
int version)
Set the current language (XPath or XQuery, XSLT Pattern, or SequenceType)
|
void |
setLocation(Clause clause,
int offset)
Set location information on a clause of a FLWOR expression.
|
protected void |
setLocation(Expression exp)
Set location information on an expression.
|
void |
setLocation(Expression exp,
int offset)
Set location information on an expression.
|
void |
setParserExtension(ParserExtension extension) |
void |
setQNameParser(QNameParser qp)
Set the QNameParser to be used while parsing
|
void |
setRangeVariables(java.util.Stack<LocalBinding> variables)
Set a new stack of in-scope range variables
|
void |
setRangeVariableStack(java.util.Stack<LocalBinding> stack)
Set the range variable stack.
|
void |
setScanOnly(boolean scanOnly)
Set that we are parsing in "scan only"
|
protected void |
testPermittedAxis(byte axis,
java.lang.String errorCode) |
void |
undeclareRangeVariable()
Note when the most recently declared range variable has gone out of scope
|
protected java.lang.CharSequence |
unescape(java.lang.String token)
Unescape character references and built-in entity references in a string.
|
protected void |
warning(java.lang.String message)
Output a warning message
|
static java.lang.String |
whyDisallowedType(PackageData pack,
BuiltInAtomicType type)
Determine whether a given built-in type is disallowed in a given environment, and in the
case where it is disallowed, return a string explaining why
|
protected Tokenizer t
protected StaticContext env
protected java.util.Stack<LocalBinding> rangeVariables
protected QNameParser qNameParser
protected ParserExtension parserExtension
protected IntPredicate charChecker
protected boolean allowXPath30Syntax
protected boolean allowXPath31Syntax
protected boolean scanOnly
protected CodeInjector codeInjector
protected int language
public static final int XPATH
public static final int XSLT_PATTERN
public static final int SEQUENCE_TYPE
public static final int XQUERY
public static final int EXTENDED_ITEM_TYPE
protected int languageVersion
protected int catchDepth
public void setCodeInjector(CodeInjector injector)
injector
- the code injector to be usedpublic CodeInjector getCodeInjector()
public Tokenizer getTokenizer()
public StaticContext getStaticContext()
public void setParserExtension(ParserExtension extension)
public void setCatchDepth(int depth)
depth
- the depth of nestingpublic void nextToken() throws XPathException
XPathException
- if an invalid token is foundpublic void expect(int token) throws XPathException
token
- the expected tokenXPathException
- if the current token is not the expected
tokenpublic void grumble(java.lang.String message) throws XPathException
message
- the error messageXPathException
- always thrown: an exception containing the
supplied messagepublic void grumble(java.lang.String message, java.lang.String errorCode) throws XPathException
message
- the error messageerrorCode
- the error codeXPathException
- always thrown: an exception containing the
supplied messagepublic void grumble(java.lang.String message, java.lang.String errorCode, int offset) throws XPathException
message
- the error messageerrorCode
- the error codeoffset
- the coded location of the error, or -1 if the location of the current token should be usedXPathException
- always thrown: an exception containing the
supplied messageprotected void grumble(java.lang.String message, StructuredQName errorCode, int offset) throws XPathException
message
- the error messageerrorCode
- the error codeoffset
- the coded location of the error, or -1 if the location of the current token should be usedXPathException
- always thrown: an exception containing the
supplied messageprotected void warning(java.lang.String message) throws XPathException
message
- the text of the messageXPathException
- if the message cannot be outputpublic void setLanguage(int language, int version)
language
- one of the constants XPATH
, XQUERY
, XSLT_PATTERN
, SEQUENCE_TYPE
version
- The XPath or XQuery language version. For XQuery the value must be
10 (for "1.0"), 30 (for "3.0") or 31 (for "3.1"); for XPath it must be 20 (="2.0"),
30 (="3.0") or 31 (="3.1").protected java.lang.String getLanguage()
public boolean isAllowXPath31Syntax()
public void setQNameParser(QNameParser qp)
qp
- the QNameParserpublic QNameParser getQNameParser()
protected java.lang.String currentTokenDisplay()
public Expression parse(java.lang.String expression, int start, int terminator, StaticContext env) throws XPathException
expression
- the expression expressed as a Stringstart
- offset within the string where parsing is to startterminator
- character to treat as terminating the expressionenv
- the static context for the expressionXPathException
- if the expression contains a syntax errorprotected void customizeTokenizer(Tokenizer t)
t
- the Tokenizer to be customizedpublic SequenceType parseSequenceType(java.lang.String input, StaticContext env) throws XPathException
input
- the string, which should conform to the XPath SequenceType
productionenv
- the static contextXPathException
- if any error is encounteredpublic ItemType parseExtendedItemType(java.lang.String input, StaticContext env) throws XPathException
input
- the string, which should conform to the XPath SequenceType
productionenv
- the static contextXPathException
- if any error is encounteredpublic SequenceType parseExtendedSequenceType(java.lang.String input, StaticContext env) throws XPathException
input
- the string, which should conform to the XPath SequenceType
productionenv
- the static contextXPathException
- if any error is encounteredpublic Expression parseExpression() throws XPathException
XPathException
- if the expression contains a syntax errorpublic Expression parseExprSingle() throws XPathException
XPathException
- if any error is encounteredpublic Expression parseBinaryExpression(Expression lhs, int minPrecedence) throws XPathException
lhs
- Left-hand side "basic expression"minPrecedence
- the minimum precedence of an operator that is to be treated as not terminating the
current expressionXPathException
- if a static error is foundpublic static int operatorPrecedence(int operator)
operator
- the operator in questionprotected Expression parseTypeswitchExpression() throws XPathException
XPathException
- if a static error is foundprotected Expression parseSwitchExpression() throws XPathException
XPathException
- in the event of a syntax errorprotected Expression parseValidateExpression() throws XPathException
XPathException
- if a static error is foundprotected Expression parseExtensionExpression() throws XPathException
XPathException
- if a static error is foundprotected Expression parseTryCatchExpression() throws XPathException
XPathException
- if a static error is foundprotected Expression parseFLWORExpression() throws XPathException
XPathException
- if any error is encounteredpublic ItemType getPlainType(StructuredQName sq) throws XPathException
XPathException
public static java.lang.String whyDisallowedType(PackageData pack, BuiltInAtomicType type)
pack
- the containing packagetype
- the built-in type to be testedpublic SequenceType parseSequenceType() throws XPathException
XPathException
- if any error is encounteredpublic ItemType parseItemType() throws XPathException
XPathException
- if a static error is foundprotected ItemType parseFunctionItemType(AnnotationList annotations) throws XPathException
annotations
- the list of annotation assertions for this function item typeXPathException
- if a static error occurs (including the case
where XPath 3.0 syntax is not enabled)protected ItemType parseMapItemType() throws XPathException
XPathException
- if a parsing error occurs or if the map syntax
is not availableprotected ItemType parseArrayItemType() throws XPathException
XPathException
- if a parsing error occurs or if the array syntax
is not availableprotected boolean atStartOfRelativePath()
protected boolean disallowedAtStartOfRelativePath()
protected Expression parsePathExpression() throws XPathException
XPathException
- if any error is encounteredprotected Expression parseSimpleMappingExpression() throws XPathException
XPathException
- in the event of a syntax errorprotected Expression parseRelativePath() throws XPathException
XPathException
- if any error is encounteredprotected Expression parseRemainingPath(Expression start) throws XPathException
start
- the initial implicit expression: root() in the case of "/", root()/descendant-or-self::node in
the case of "//"XPathException
- if a static error is foundprotected Expression parseStepExpression(boolean firstInPattern) throws XPathException
firstInPattern
- true only if we are parsing the first step in a
RelativePathPattern in the XSLT Pattern syntaxXPathException
- if any error is encounteredprotected Expression parseArrowPostfix(Expression lhs) throws XPathException
XPathException
protected Expression parsePredicate() throws XPathException
XPathException
- if a static error is foundprotected boolean isReservedInQuery(java.lang.String uri)
protected Expression parseBasicStep(boolean firstInPattern) throws XPathException
firstInPattern
- true only if we are parsing the first step in a
RelativePathPattern in the XSLT Pattern syntaxXPathException
- if any error is encounteredpublic Expression parseParenthesizedExpression() throws XPathException
XPathException
protected void testPermittedAxis(byte axis, java.lang.String errorCode) throws XPathException
XPathException
public Expression parseNumericLiteral(boolean traceable) throws XPathException
XPathException
protected Expression parseStringLiteral(boolean traceable) throws XPathException
XPathException
protected Expression parseStringTemplate(boolean complete) throws XPathException
XPathException
public Expression parseVariableReference() throws XPathException
XPathException
protected Literal makeStringLiteral(java.lang.String currentTokenValue) throws XPathException
currentTokenValue
- the token as read (excluding quotation marks)XPathException
- if a static error is foundprotected java.lang.CharSequence unescape(java.lang.String token) throws XPathException
token
- the input string, which may include XML-style character references or built-in
entity referencesXPathException
- if a malformed character or entity reference is foundprotected Expression parseConstructor() throws XPathException
XPathException
- if a static error occurspublic Expression parseDynamicFunctionCall(Expression functionItem, Expression prefixArgument) throws XPathException
functionItem
- the expression that determines the function to be calledprefixArgument
- the LHS of an arrow operator, or null if this is not part of an arrow expressionXPathException
- if a static error is foundprotected Expression generateApplyCall(Expression functionItem, java.util.ArrayList<Expression> args) throws XPathException
XPathException
protected Expression parseLookup(Expression lhs) throws XPathException
lhs
- the expression that the function to be calledXPathException
- if a static error is foundprotected NodeTest parseNodeTest(short nodeType) throws XPathException
nodeType
- the node type being sought if one is specifiedXPathException
- if any error is encounteredprotected boolean isNamespaceTestAllowed()
protected void checkLanguageVersion30() throws XPathException
XPathException
- if XPath 3.0 support was not requestedprotected void checkLanguageVersion31() throws XPathException
XPathException
- if XPath 3.1 support was not requestedpublic void checkSyntaxExtensions(java.lang.String construct) throws XPathException
XPathException
- if Saxon syntax extensions have not been enabledprotected Expression parseMapExpression() throws XPathException
XPathException
protected Expression parseArraySquareConstructor() throws XPathException
XPathException
protected Expression parseArrayCurlyConstructor() throws XPathException
XPathException
- if the syntax is invalid or the construct is not permittedpublic Expression parseFunctionCall(Expression prefixArgument) throws XPathException
prefixArgument
- left hand operand of arrow operator,
or null in the case of a conventional function callXPathException
- if any error is encounteredpublic Expression reportMissingFunction(int offset, StructuredQName functionName, Expression[] arguments) throws XPathException
XPathException
public static java.lang.String getMissingFunctionExplanation(StructuredQName functionName, Configuration config)
functionName
- the name of the required functionconfig
- the Saxon configurationprotected StructuredQName resolveFunctionName(java.lang.String fname) throws XPathException
fname
- the lexical QName used as the function name; or an EQName presented
by the tokenizer as a name in Clark notationXPathException
- if the supplied name is not a valid QName or if its prefix
is not in scopepublic Expression parseFunctionArgument() throws XPathException
XPathException
- if the argument expression does not parse correctlyprotected Expression parseNamedFunctionReference() throws XPathException
XPathException
- if a static error is encounteredprotected AnnotationList parseAnnotationsList() throws XPathException
XPathException
- in the event of a syntax errorprotected Expression parseInlineFunction(AnnotationList annotations) throws XPathException
annotations
- the function annotations, which have already been read, or null if there are noneXPathException
- if a syntax error is foundprotected Expression makeCurriedFunction(int offset, StructuredQName name, Expression[] args, IntSet placeMarkers) throws XPathException
offset
- the position of the expression in the source textname
- the function name (as if there were no currying)args
- the arguments (with EmptySequence in the placemarker positions)placeMarkers
- the positions of the placemarkers @return the curried functionXPathException
- if a static error is foundprotected static final boolean isReservedFunctionName30(java.lang.String name)
name
- the function name (the local-name as a string)public static boolean isReservedFunctionName31(java.lang.String name)
name
- the function name (the local-name as a string)public java.util.Stack<LocalBinding> getRangeVariables()
public void setRangeVariables(java.util.Stack<LocalBinding> variables)
variables
- the stack of variablespublic void declareRangeVariable(LocalBinding declaration) throws XPathException
declaration
- the variable declaration to be added to the stackXPathException
- if any error is encounteredpublic void undeclareRangeVariable()
protected LocalBinding findRangeVariable(StructuredQName qName)
qName
- identifies the name of the range variablepublic void setRangeVariableStack(java.util.Stack<LocalBinding> stack)
stack
- the stack to be used for local variables declared within the expressionpublic final int makeFingerprint(java.lang.String qname, boolean useDefault) throws XPathException
qname
- The name as written, in the form "[prefix:]localname"; alternatively,
a QName in Clark notation ({uri}local)useDefault
- Defines the action when there is no prefix. If
true, use the default namespace URI for element names. If false,
use no namespace URI (as for attribute names).XPathException
- if the name is invalid, or the prefix
undeclaredpublic final StructuredQName makeStructuredQNameSilently(java.lang.String qname, java.lang.String defaultUri) throws XPathException
qname
- The name as written, in the form "[prefix:]localname"defaultUri
- Defines the URI to be returned if there is no prefix.XPathException
- if the name is invalid, or the prefix
undeclared or if the name is not a lexically valid QNamepublic final StructuredQName makeStructuredQName(java.lang.String qname, java.lang.String defaultUri) throws XPathException
qname
- The name as written, in the form "[prefix:]localname"; alternatively, a QName in
Clark format ({uri}local)defaultUri
- The URI to be used if the name is written as a localname with no prefixXPathException
- if the name is invalid, or the prefix
undeclaredpublic final NodeName makeNodeName(java.lang.String qname, boolean useDefault) throws XPathException, QNameException
qname
- The name as written, in the form "[prefix:]localname"; alternatively, a QName in
Clark format ({uri}local)useDefault
- Defines the action when there is no prefix. If
true, use the default namespace URI for element names. If false,
use no namespace URI (as for attribute names).XPathException
- if the name is invalid, or the prefix
undeclaredQNameException
- if the supplied qname is not a lexically valid QNamepublic NameTest makeNameTest(short nodeType, java.lang.String qname, boolean useDefault) throws XPathException
nodeType
- the type of node required (identified by a constant in
class Type)qname
- the lexical QName of the required node; alternatively,
a QName in Clark notation ({uri}local)useDefault
- true if the default namespace should be used when
the QName is unprefixedXPathException
- if the QName is invalidpublic NamespaceTest makeNamespaceTest(short nodeType, java.lang.String prefix) throws XPathException
nodeType
- integer code identifying the type of node requiredprefix
- the namespace prefixXPathException
- if the namespace prefix is not declaredpublic LocalNameTest makeLocalNameTest(short nodeType, java.lang.String localName) throws XPathException
nodeType
- the kind of node to be matchedlocalName
- the requred local nameXPathException
- if the local name is invalidprotected void setLocation(Expression exp)
exp
- the expression whose location information is to be setpublic void setLocation(Expression exp, int offset)
exp
- the expression whose location information is to be setoffset
- the character position within the expression (ignoring newlines)public void setLocation(Clause clause, int offset)
clause
- the clause whose location information is to be setoffset
- the character position within the expression (ignoring newlines)public Location makeLocation()
public Location makeNestedLocation(Location containingLoc, int line, int column, java.lang.String nearbyText)
containingLoc
- the containing locationline
- the line number relative to the containing location (zero-based)column
- the column number relative to the containing location (zero-based)nearbyText
- (maybe null) expression text around the point of the errorpublic Expression makeTracer(int startOffset, Expression exp, int construct, StructuredQName qName)
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)protected boolean isKeyword(java.lang.String s)
s
- The string to be compared with the current tokenpublic void setScanOnly(boolean scanOnly)
scanOnly
- true if parsing is to proceed in scan-only mode. In this mode
namespace bindings are not yet known, so no attempt is made to look up namespace
prefixes.public void setAllowAbsentExpression(boolean allowEmpty)
allowEmpty
- true if it is permitted for the expression to consist
only of whitespace and comments, in which case the result
of parsing will be an EmptySequence literalpublic boolean isAllowAbsentExpression(boolean allowEmpty)
public void checkHofFeature() throws XPathException
XPathException
- if the feature is licensedCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.