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
,NoDynamicContextException
,NoOpenStartTagException
,TerminationException
,ValidationException
,XPathException.Circularity
XPathException is used to indicate an error in an XPath expression.
It will generally be either a StaticError or a DynamicError;
ValidationExceptions (arising from schema validation) form a third category
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Subclass of XPathException used to report circularities -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXPathException
(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, Throwable err) Create an XPathException that supplies an error message and wraps an underlying exceptionXPathException
(String message, SourceLocator loc) Create an XPathException that supplies an error message and supplies location informationXPathException
(String message, SourceLocator loc, Throwable err) Create an XPathException that supplies an error message and wraps an underlying exception and supplies location informationXPathException
(Throwable err) Create an XPathException that wraps another exception -
Method Summary
Modifier and TypeMethodDescriptionGet the additional location text, if any.Get the local part of the name of the error codeGet the namespace URI part of the name of the error codeGet the error code as a QNameGet the error object associated with this error.Get the dynamic context at the time the exception occurredboolean
Ask whether this error is marked to indicate that it has already been reported to the error listener, and should not be reported againboolean
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 referenceboolean
Tests whether this is a dynamic error that may be reported statically if it is detected staticallyboolean
Ask whether this exception represents a static errorboolean
Ask whether this exception represents a type errorForce an exception to a static errorstatic XPathException
Create an XPathException from a JAXP TransformerException.void
maybeSetContext
(XPathContext context) Set the context of a message, only if it is not already setvoid
maybeSetErrorCode
(String code) Set the error code, provided it has not already been set.void
maybeSetLocation
(SourceLocator locator) Set the location of a message, only if it is not already setvoid
Set additional location text.void
setErrorCode
(String code) Set the error code.void
Set the error code.void
setErrorObject
(Value value) Set the error object associated with this error.void
setHasBeenReported
(boolean reported) Mark this error to indicate that it has already been reported to the error listener, and should not be reported againvoid
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 referencevoid
setIsStaticError
(boolean is) Mark this exception to indicate that it represents (or does not represent) a static errorvoid
setIsTypeError
(boolean is) Mark this exception to indicate that it represents (or does not represent) a type errorvoid
setXPathContext
(XPathContext context) Set dynamic context information in the exception objectMethods inherited from class javax.xml.transform.TransformerException
getCause, getException, getLocationAsString, getLocator, getMessageAndLocation, initCause, printStackTrace, printStackTrace, printStackTrace, setLocator
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, setStackTrace, toString
-
Field Details
-
context
-
-
Constructor Details
-
XPathException
Create an XPathException with an error message- Parameters:
message
- the message explaining what is wrong. This should not include location information.
-
XPathException
Create an XPathException that wraps another exception- Parameters:
err
- the wrapped error or exception
-
XPathException
Create 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)
-
XPathException
Create an XPathException that supplies an error message and supplies location information- Parameters:
message
- the error messageloc
- indicates where in the user-written query or stylesheet (or sometimes in a source document) the error occurred
-
XPathException
Create an XPathException that supplies an error message and wraps an underlying exception and supplies location information- Parameters:
message
- the error message (which should generally explain what Saxon was doing when the underlying exception occurred)loc
- indicates where in the user-written query or stylesheet (or sometimes in a source document) the error occurrederr
- the underlying exception (the cause of this exception)
-
XPathException
Create an XPathException that supplies an error message and an error code- Parameters:
message
- the error messageerrorCode
- the error code - an eight-character code, which is taken to be in the standard system error code namespace
-
XPathException
Create an XPathException that supplies an error message and an error code and provides the dynamic context- Parameters:
message
- the error messageerrorCode
- the error code - an eight-character code, which is taken to be in the standard system error code namespacecontext
- the dynamic evaluation context
-
-
Method Details
-
makeXPathException
Create an XPathException from a JAXP TransformerException. If the TransformerException is an XPathException, or if its cause is an XPathException, that XPathException is returned unchanged; otherwise the TransformerException is wrapped.- Parameters:
err
- the supplied JAXP TransformerException- Returns:
- an XPathException obtained from the supplied TransformerException
-
makeStatic
Force an exception to a static error- Returns:
- this exception, marked as a static error
-
setXPathContext
Set dynamic context information in the exception object- Parameters:
context
- the dynamic context at the time the exception occurred
-
getXPathContext
Get the dynamic context at the time the exception occurred- Returns:
- the dynamic context if known; otherwise null
-
setAdditionalLocationText
Set additional location text. This gives extra information about the position of the error in textual form. Where XPath is embedded within a host language such as XSLT, the formal location information identifies the location of the error in the XSLT module, while this string locates the error within a specific XPath expression. The information is typically used only for static errors.- Parameters:
text
- additional information about the location of the error, designed to be output as a prefix to the error message if desired. (It is not concatenated with the message, because it may be superfluous in an IDE environment.)
-
getAdditionalLocationText
Get the additional location text, if any. This gives extra information about the position of the error in textual form. Where XPath is embedded within a host language such as XSLT, the formal location information identifies the location of the error in the XSLT module, while this string locates the error within a specific XPath expression. The information is typically used only for static errors.- Returns:
- additional information about the location of the error, designed to be output as a prefix to the error message if desired. (It is not concatenated with the message, because it may be superfluous in an IDE environment.)
-
setIsStaticError
public 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
-
isStaticError
public boolean isStaticError()Ask whether this exception represents a static error- Returns:
- true if this exception is a static error
-
setIsTypeError
public 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
-
isTypeError
public boolean isTypeError()Ask whether this exception represents a type error- Returns:
- true if this exception is a type error
-
setIsGlobalError
public 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
-
isGlobalError
public 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
-
setErrorCode
Set 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
-
maybeSetErrorCode
Set 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
-
setErrorCodeQName
Set 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
-
getErrorCodeQName
Get the error code as a QName- Returns:
- the error code as a QName
-
getErrorCodeLocalPart
Get the local part of the name of the error code- Returns:
- the local part of the name of the error code
-
getErrorCodeNamespace
Get the namespace URI part of the name of the error code- Returns:
- the namespace URI part of the name of the error code
-
setErrorObject
Set 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
-
getErrorObject
Get 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
-
setHasBeenReported
public 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
-
hasBeenReported
public 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
-
maybeSetLocation
Set the location of a message, only if it is not already set- Parameters:
locator
- the current location (or null)
-
maybeSetContext
Set the context of a message, only if it is not already set- Parameters:
context
- the current XPath context (or null)
-
isReportableStatically
public 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
-