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:
java.io.Serializable
- Direct Known Subclasses:
CopyNamespaceSensitiveException,Error.UserDefinedXPathException,NoDynamicContextException,NoOpenStartTagException,QuitParsingException,SchemaException,TerminationException,ValidationException,XPathException.Circularity,XPathException.StackOverflow
public class XPathException extends javax.xml.transform.TransformerExceptionXPathException is used to indicate an error (static or dynamic) in an XPath expression, or in a query or stylesheet.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXPathException.CircularitySubclass of XPathException used to report circularitiesstatic classXPathException.StackOverflowSubclass of XPathException used to report stack overflow
-
Constructor Summary
Constructors Constructor Description XPathException(java.lang.String message)Create an XPathException with an error messageXPathException(java.lang.String message, java.lang.String errorCode)Create an XPathException that supplies an error message and an error codeXPathException(java.lang.String message, java.lang.String errorCode, XPathContext context)Create an XPathException that supplies an error message and an error code and provides the dynamic contextXPathException(java.lang.String message, java.lang.String errorCode, Location loc)Create an XPathException that supplies an error message and supplies location informationXPathException(java.lang.String message, java.lang.Throwable err)Create an XPathException that supplies an error message and wraps an underlying exceptionXPathException(java.lang.String message, Location loc, java.lang.Throwable err)Create an XPathException that supplies an error message and wraps an underlying exception and supplies location informationXPathException(java.lang.Throwable err)Create an XPathException that wraps another exception
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static XPathExceptionfromXmlProcessingError(XmlProcessingError error)java.lang.StringgetErrorCodeLocalPart()Get the local part of the name of the error codejava.lang.StringgetErrorCodeNamespace()Get the namespace URI part of the name of the error codeStructuredQNamegetErrorCodeQName()Get the error code as a QNameSequencegetErrorObject()Get the error object associated with this error.ExpressiongetFailingExpression()java.lang.StringgetHostLanguage()Get the host language codeLocationgetLocator()Method getLocator retrieves an instance of a SourceLocator object that specifies where an error occured.java.lang.StringgetMessage()Get the error message.XPathContextgetXPathContext()Get the dynamic context at the time the exception occurredbooleanhasBeenReported()Ask whether this error is marked to indicate that it has already been reported to the error listener, and should not be reported againbooleanisGlobalError()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 referencebooleanisReportableStatically()Tests whether this is a dynamic error that may be reported statically if it is detected staticallybooleanisStaticError()Ask whether this exception represents a static errorbooleanisSyntaxError()Ask whether this exception represents a syntax errorbooleanisTypeError()Ask whether this exception represents a type errorstatic XPathExceptionmakeXPathException(java.lang.Exception err)Create an XPathException from an exception of another kind.voidmaybeSetContext(XPathContext context)Set the context of a message, only if it is not already setvoidmaybeSetErrorCode(java.lang.String code)Set the error code, provided it has not already been set.voidmaybeSetFailingExpression(Expression failingExpression)voidmaybeSetLocation(Location here)Set the location of a message, only if it is not already setvoidsetErrorCode(java.lang.String code)Set the error code.voidsetErrorCodeQName(StructuredQName code)Set the error code.voidsetErrorObject(Sequence value)Set the error object associated with this error.voidsetFailingExpression(Expression failingExpression)voidsetHasBeenReported(boolean reported)Mark this error to indicate that it has already been reported to the error listener, and should not be reported againvoidsetHostLanguage(java.lang.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 objectXPathExceptionwithErrorCode(java.lang.String code)Set the error code.-
Methods inherited from class javax.xml.transform.TransformerException
getCause, getException, getLocationAsString, getMessageAndLocation, initCause, printStackTrace, printStackTrace, printStackTrace, setLocator
-
-
-
-
Constructor Detail
-
XPathException
public XPathException(java.lang.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(java.lang.Throwable err)
Create an XPathException that wraps another exception- Parameters:
err- the wrapped error or exception
-
XPathException
public XPathException(java.lang.String message, java.lang.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(java.lang.String message, java.lang.String errorCode, Location loc)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
public XPathException(java.lang.String message, Location loc, java.lang.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 occurrederr- the underlying exception (the cause of this exception)
-
XPathException
public XPathException(java.lang.String message, java.lang.String errorCode)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
public XPathException(java.lang.String message, java.lang.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 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 Detail
-
makeXPathException
public static XPathException makeXPathException(java.lang.Exception err)
Create 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
public static XPathException fromXmlProcessingError(XmlProcessingError error)
-
getMessage
public java.lang.String getMessage()
Get the error message. Adapted on C# to get the message from a contained exception- Overrides:
getMessagein classjava.lang.Throwable
-
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
-
setLocation
public void setLocation(Location loc)
-
getFailingExpression
public Expression getFailingExpression()
-
setFailingExpression
public void setFailingExpression(Expression failingExpression)
-
maybeSetFailingExpression
public void maybeSetFailingExpression(Expression failingExpression)
-
getLocator
public Location getLocator()
Method getLocator retrieves an instance of a SourceLocator object that specifies where an error occured.- Overrides:
getLocatorin classjavax.xml.transform.TransformerException- Returns:
- A SourceLocator object, or null if none was specified.
-
getXPathContext
public XPathContext getXPathContext()
Get the dynamic context at the time the exception occurred- Returns:
- the dynamic context if known; otherwise null
-
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
-
setIsSyntaxError
public 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
-
isSyntaxError
public boolean isSyntaxError()
Ask whether this exception represents a syntax error- Returns:
- true if this exception is a syntax 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
-
setHostLanguage
public void setHostLanguage(java.lang.String language)
Set the host language code- Parameters:
language- a value such as "XPath", "XQuery", "XSLT Pattern"
-
setHostLanguage
public void setHostLanguage(HostLanguage language)
Set the host language code- Parameters:
language- a value such as "XPath", "XQuery", "XSLT Pattern"
-
getHostLanguage
public java.lang.String getHostLanguage()
Get the host language code- Returns:
- a value such as "XPath", "XQuery", "XSLT Pattern", or null
-
setErrorCode
public void setErrorCode(java.lang.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 namespaceNamespaceConstant.ERR- Parameters:
code- The local part of the name of the error code
-
withErrorCode
public XPathException withErrorCode(java.lang.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 namespaceNamespaceConstant.ERR- Parameters:
code- The local part of the name of the error code- Returns:
- this XPathException object in a modified state
-
maybeSetErrorCode
public void maybeSetErrorCode(java.lang.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 namespaceNamespaceConstant.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
-
getErrorCodeQName
public StructuredQName getErrorCodeQName()
Get the error code as a QName- Returns:
- the error code as a QName
-
getErrorCodeLocalPart
public java.lang.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 java.lang.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
-
setErrorObject
public void setErrorObject(Sequence 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
-
getErrorObject
public Sequence 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
public void maybeSetLocation(Location here)
Set the location of a message, only if it is not already set- Parameters:
here- the current location (or null)
-
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)
-
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
-
-