Package net.sf.saxon.trans
Class XPathException
java.lang.Object
java.lang.Throwable
java.lang.Exception
javax.xml.transform.TransformerException
net.sf.saxon.trans.XPathException
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- CopyNamespaceSensitiveException,- Error.UserDefinedXPathException,- NoDynamicContextException,- NoOpenStartTagException,- QuitParsingException,- SchemaException,- TerminationException,- ValidationException,- XPathException.Circularity,- XPathException.StackOverflow
XPathException is used to indicate an error (static or dynamic) in an XPath expression,
 or in a query or stylesheet.
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classSubclass of XPathException used to report circularitiesstatic classSubclass of XPathException used to report stack overflow
- 
Constructor SummaryConstructorsConstructorDescriptionXPathException(String message) Create an XPathException with an error messageXPathException(String message, String errorCode) Create an XPathException that supplies an error message and an error codeXPathException(String message, String errorCode, XPathContext context) Create an XPathException that supplies an error message and an error code and provides the dynamic contextXPathException(String message, String errorCode, Location loc) Create an XPathException that supplies an error message and supplies location informationXPathException(String message, Throwable err) Create an XPathException that supplies an error message and wraps an underlying exceptionXPathException(Throwable err) Create an XPathException that wraps another exception
- 
Method SummaryModifier and TypeMethodDescriptionMark this exception to indicate that it represents a type errorasTypeErrorIf(boolean condition) static XPathExceptionGet the error code as a QNameGet the error object associated with this error.Get the host language codeMethod getLocator retrieves an instance of a SourceLocator object that specifies where an error occured.Get the dynamic context at the time the exception occurredbooleanAsk whether this error is marked to indicate that it has already been reported to the error listener, and should not be reported againbooleanhasErrorCode(String... codes) Ask whether the error code is a specific system error codebooleanAsk whether this exception originated while evaluating a global variable reference, and is therefore to be reported regardless of the try/catch context surrounding the variable referencebooleanTests whether this is a dynamic error that may be reported statically if it is detected staticallybooleanAsk whether this exception represents a static errorbooleanAsk whether this exception represents a syntax errorbooleanAsk whether this exception represents a type errorstatic XPathExceptionCreate an XPathException from an exception of another kind.voidmaybeSetContext(XPathContext context) Set the context of a message, only if it is not already setvoidmaybeSetErrorCode(String code) Set the error code, provided it has not already been set.voidmaybeSetLocation(Location here) Set the location of a message, only if it is not already setmaybeWithContext(XPathContext context) maybeWithErrorCode(String code) maybeWithFailingExpression(Expression failingExpression) maybeWithLocation(Location here) replacingErrorCode(String oldCode, String newCode) voidsetErrorCode(String code) Set the error code.voidSet the error code.voidsetErrorObject(Sequence value) Set the error object associated with this error.voidsetHasBeenReported(boolean reported) Mark this error to indicate that it has already been reported to the error listener, and should not be reported againvoidsetHostLanguage(String language) Set the host language codevoidsetHostLanguage(HostLanguage language) Set the host language codevoidsetIsGlobalError(boolean is) Mark this exception to indicate that it originated while evaluating a global variable reference, and is therefore to be reported regardless of the try/catch context surrounding the variable referencevoidsetIsStaticError(boolean is) Mark this exception to indicate that it represents (or does not represent) a static errorvoidsetIsSyntaxError(boolean is) Mark this exception to indicate that it represents (or does not represent) a syntax errorvoidsetIsTypeError(boolean is) Mark this exception to indicate that it represents (or does not represent) a type errorvoidsetLocation(Location loc) voidsetXPathContext(XPathContext context) Set dynamic context information in the exception objectwithErrorCode(String code) Set the error code.withErrorCode(StructuredQName code) withFailingExpression(Expression failingExpression) withLocation(Location loc) Set location information in the exception objectwithMessage(String message) Construct an exception that differs from a supplied exception only by changing the error messagewithXPathContext(XPathContext context) Set dynamic context information in the exception objectMethods inherited from class javax.xml.transform.TransformerExceptiongetCause, getException, getLocationAsString, getMessageAndLocation, initCause, printStackTrace, printStackTrace, printStackTrace, setLocatorMethods inherited from class java.lang.ThrowableaddSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, setStackTrace, toString
- 
Constructor Details- 
XPathExceptionCreate an XPathException with an error message- Parameters:
- message- the message explaining what is wrong. This should not include location information.
 
- 
XPathExceptionCreate an XPathException that wraps another exception- Parameters:
- err- the wrapped error or exception
 
- 
XPathExceptionCreate an XPathException that supplies an error message and wraps an underlying exception- Parameters:
- message- the error message (which should generally explain what Saxon was doing when the underlying exception occurred)
- err- the underlying exception (the cause of this exception)
 
- 
XPathExceptionCreate an XPathException that supplies an error message and supplies location information- Parameters:
- message- the error message
- loc- indicates where in the user-written query or stylesheet (or sometimes in a source document) the error occurred
 
- 
XPathExceptionCreate an XPathException that supplies an error message and an error code- Parameters:
- message- the error message
- errorCode- the error code - an eight-character code, which is taken to be in the standard system error code namespace
 
- 
XPathExceptionCreate an XPathException that supplies an error message and an error code and provides the dynamic context- Parameters:
- message- the error message
- errorCode- the error code - an eight-character code, which is taken to be in the standard system error code namespace
- context- the dynamic evaluation context
 
 
- 
- 
Method Details- 
makeXPathExceptionCreate an XPathException from an exception of another kind. If the supplied Exception is an XPathException; if its cause is an XPathException, that XPathException is returned unchanged; otherwise the supplied Exception is wrapped.- Parameters:
- err- the supplied Exception
- Returns:
- an XPathException obtained from the supplied TransformerException
 
- 
fromXmlProcessingError
- 
withMessageConstruct an exception that differs from a supplied exception only by changing the error message- Parameters:
- message- the new message
- Returns:
- a new exception, copying all the properties of this exception except for the message
 
- 
setXPathContextSet dynamic context information in the exception object- Parameters:
- context- the dynamic context at the time the exception occurred
 
- 
withXPathContextSet dynamic context information in the exception object- Parameters:
- context- the dynamic context at the time the exception occurred
- Returns:
- this XPathException object in a modified state
 
- 
setLocation
- 
withLocationSet location information in the exception object- Parameters:
- loc- indicating where the exception occurred
- Returns:
- this XPathException object in a modified state
 
- 
getFailingExpression
- 
withFailingExpression
- 
maybeWithFailingExpression
- 
getLocatorMethod getLocator retrieves an instance of a SourceLocator object that specifies where an error occured.- Overrides:
- getLocatorin class- TransformerException
- Returns:
- A SourceLocator object, or null if none was specified.
 
- 
getXPathContextGet the dynamic context at the time the exception occurred- Returns:
- the dynamic context if known; otherwise null
 
- 
setIsStaticErrorpublic void setIsStaticError(boolean is) Mark this exception to indicate that it represents (or does not represent) a static error- Parameters:
- is- true if this exception is a static error
 
- 
asStaticError
- 
isStaticErrorpublic boolean isStaticError()Ask whether this exception represents a static error- Returns:
- true if this exception is a static error
 
- 
setIsSyntaxErrorpublic void setIsSyntaxError(boolean is) Mark this exception to indicate that it represents (or does not represent) a syntax error- Parameters:
- is- true if this exception is a syntax error
 
- 
isSyntaxErrorpublic boolean isSyntaxError()Ask whether this exception represents a syntax error- Returns:
- true if this exception is a syntax error
 
- 
setIsTypeErrorpublic void setIsTypeError(boolean is) Mark this exception to indicate that it represents (or does not represent) a type error- Parameters:
- is- true if this exception is a type error
 
- 
asTypeErrorMark this exception to indicate that it represents a type error- Returns:
- this XPathException in a modified state
 
- 
asTypeErrorIf
- 
isTypeErrorpublic boolean isTypeError()Ask whether this exception represents a type error- Returns:
- true if this exception is a type error
 
- 
setIsGlobalErrorpublic void setIsGlobalError(boolean is) Mark this exception to indicate that it originated while evaluating a global variable reference, and is therefore to be reported regardless of the try/catch context surrounding the variable reference- Parameters:
- is- true if this exception is a global variable error
 
- 
isGlobalErrorpublic boolean isGlobalError()Ask whether this exception originated while evaluating a global variable reference, and is therefore to be reported regardless of the try/catch context surrounding the variable reference- Returns:
- true if this exception is a global variable error
 
- 
setHostLanguageSet the host language code- Parameters:
- language- a value such as "XPath", "XQuery", "XSLT Pattern"
 
- 
setHostLanguageSet the host language code- Parameters:
- language- a value such as "XPath", "XQuery", "XSLT Pattern"
 
- 
getHostLanguageGet the host language code- Returns:
- a value such as "XPath", "XQuery", "XSLT Pattern", or null
 
- 
setErrorCodeSet the error code. The error code is a QName; this method sets the local part of the name, setting the namespace of the error code to the standard system namespaceNamespaceConstant.ERR- Parameters:
- code- The local part of the name of the error code
 
- 
withErrorCodeSet the error code. The error code is a QName; this method sets the local part of the name, setting the namespace of the error code to the standard system namespaceNamespaceConstant.ERR- Parameters:
- code- The local part of the name of the error code
- Returns:
- this XPathException object in a modified state
 
- 
withErrorCode
- 
replacingErrorCode
- 
maybeSetErrorCodeSet the error code, provided it has not already been set. The error code is a QName; this method sets the local part of the name, setting the namespace of the error code to the standard system namespaceNamespaceConstant.ERR- Parameters:
- code- The local part of the name of the error code
 
- 
maybeWithErrorCode
- 
setErrorCodeQNameSet the error code. The error code is a QName; this method sets both parts of the name.- Parameters:
- code- The error code as a QName
 
- 
getErrorCodeQNameGet the error code as a QName- Returns:
- the error code as a QName
 
- 
showErrorCode
- 
hasErrorCodeAsk whether the error code is a specific system error code- Parameters:
- codes- the local part of the error(s) expected
- Returns:
- true if the error code matches one of the required codes, treated as local names in the standard error namespace
 
- 
setErrorObjectSet the error object associated with this error. This is used by the standard XPath fn:error() function- Parameters:
- value- the error object, as supplied to the fn:error() function
 
- 
getErrorObjectGet the error object associated with this error. This is used by the standard XPath fn:error() function- Returns:
- the error object, as supplied to the fn:error() function
 
- 
setHasBeenReportedpublic void setHasBeenReported(boolean reported) Mark this error to indicate that it has already been reported to the error listener, and should not be reported again- Parameters:
- reported- true if the error has been reported to the error listener
 
- 
hasBeenReportedpublic boolean hasBeenReported()Ask whether this error is marked to indicate that it has already been reported to the error listener, and should not be reported again- Returns:
- true if this error has already been reported
 
- 
maybeSetLocationSet the location of a message, only if it is not already set- Parameters:
- here- the current location (or null)
 
- 
maybeWithLocation
- 
maybeSetContextSet the context of a message, only if it is not already set- Parameters:
- context- the current XPath context (or null)
 
- 
maybeWithContext
- 
isReportableStaticallypublic boolean isReportableStatically()Tests whether this is a dynamic error that may be reported statically if it is detected statically- Returns:
- true if the error can be reported statically
 
 
-