net.sf.saxon.trans

Class XPathException

public class XPathException extends TransformerException

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
Nested Class Summary
static classXPathException.Circularity
Subclass of XPathException used to report circularities
Field Summary
XPathContextcontext
StructuredQNameerrorCode
ValueerrorObject
Constructor Summary
XPathException(String message)
Create an XPathException with an error message
XPathException(Throwable err)
Create an XPathException that wraps another exception
XPathException(String message, Throwable err)
Create an XPathException that supplies an error message and wraps an underlying exception
XPathException(String message, SourceLocator loc)
Create an XPathException that supplies an error message and supplies location information
XPathException(String message, SourceLocator loc, Throwable err)
Create an XPathException that supplies an error message and wraps an underlying exception and supplies location information
XPathException(String message, String errorCode)
Create an XPathException that supplies an error message and an error code
XPathException(String message, String errorCode, XPathContext context)
Create an XPathException that supplies an error message and an error code and provides the dynamic context
Method Summary
StringgetErrorCodeLocalPart()
Get the local part of the name of the error code
StringgetErrorCodeNamespace()
Get the namespace URI part of the name of the error code
StructuredQNamegetErrorCodeQName()
Get the error code as a QName
ValuegetErrorObject()
Get the error object associated with this error.
XPathContextgetXPathContext()
Get the dynamic context at the time the exception occurred
booleanhasBeenReported()
Ask whether this error is marked to indicate that it has already been reported to the error listener, and should not be reported again
booleanisGlobalError()
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
booleanisStaticError()
Ask whether this exception represents a static error
booleanisTypeError()
Ask whether this exception represents a type error
XPathExceptionmakeStatic()
Force an exception to a static error
static XPathExceptionmakeXPathException(TransformerException err)
Create an XPathException from a JAXP TransformerException.
voidmaybeSetContext(XPathContext context)
Set the context of a message, only if it is not already set
voidmaybeSetErrorCode(String code)
Set the error code, provided it has not already been set.
voidmaybeSetLocation(SourceLocator locator)
Set the location of a message, only if it is not already set
voidsetErrorCode(String code)
Set the error code.
voidsetErrorCodeQName(StructuredQName code)
Set the error code.
voidsetErrorObject(Value 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 again
voidsetIsGlobalError(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
voidsetIsStaticError(boolean is)
Mark this exception to indicate that it represents (or does not represent) a static error
voidsetIsTypeError(boolean is)
Mark this exception to indicate that it represents (or does not represent) a type error
voidsetXPathContext(XPathContext context)
Set dynamic context information in the exception object

Field Detail

context

transient XPathContext context

errorCode

StructuredQName errorCode

errorObject

Value errorObject

Constructor Detail

XPathException

public XPathException(String message)
Create an XPathException with an error message

Parameters: message the message explaining what is wrong. This should not include location information.

XPathException

public XPathException(Throwable err)
Create an XPathException that wraps another exception

Parameters: err the wrapped error or exception

XPathException

public XPathException(String message, Throwable err)
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

public XPathException(String message, SourceLocator loc)
Create 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

XPathException

public XPathException(String message, SourceLocator loc, Throwable err)
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 occurred err the underlying exception (the cause of this exception)

XPathException

public XPathException(String message, String errorCode)
Create 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

XPathException

public XPathException(String message, String errorCode, XPathContext context)
Create 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 Detail

getErrorCodeLocalPart

public String getErrorCodeLocalPart()
Get the local part of the name of the error code

Returns: the local part of the name of the error code

getErrorCodeNamespace

public String 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

getErrorCodeQName

public StructuredQName getErrorCodeQName()
Get the error code as a QName

Returns: the error code as a QName

getErrorObject

public Value 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

getXPathContext

public XPathContext getXPathContext()
Get the dynamic context at the time the exception occurred

Returns: the dynamic context if known; otherwise null

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

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

isStaticError

public boolean isStaticError()
Ask whether this exception represents a static error

Returns: true if this exception is a static error

isTypeError

public boolean isTypeError()
Ask whether this exception represents a type error

Returns: true if this exception is a type error

makeStatic

public XPathException makeStatic()
Force an exception to a static error

Returns: this exception, marked as a static error

makeXPathException

public static XPathException makeXPathException(TransformerException err)
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

maybeSetContext

public void maybeSetContext(XPathContext context)
Set the context of a message, only if it is not already set

Parameters: context the current XPath context (or null)

maybeSetErrorCode

public void maybeSetErrorCode(String code)
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 namespace ERR

Parameters: code The local part of the name of the error code

maybeSetLocation

public void maybeSetLocation(SourceLocator locator)
Set the location of a message, only if it is not already set

Parameters: locator the current location (or null)

setErrorCode

public void setErrorCode(String code)
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 namespace ERR

Parameters: code The local part of the name of the error code

setErrorCodeQName

public void setErrorCodeQName(StructuredQName code)
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

setErrorObject

public void setErrorObject(Value value)
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

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

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

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

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

setXPathContext

public void setXPathContext(XPathContext context)
Set dynamic context information in the exception object

Parameters: context the dynamic context at the time the exception occurred