## 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, DynamicError, NoDynamicContextException, NoOpenStartTagException, PTreeReader.PTreeException, StaticError, TerminationException, ValidationException, XPathException.Circularity

    public class XPathException

extends javax.xml.transform.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

See Also:
  Serialized Form

Nested Class Summary
`static class` `XPathException.Circularity` Subclass of XPathException used to report circularities

Constructor Summary
`XPathException(java.lang.String message)` Create an XPathException with an error message
`XPathException(java.lang.String message, javax.xml.transform.SourceLocator loc)` Create an XPathException that supplies an error message and supplies location information
`XPathException(java.lang.String message, javax.xml.transform.SourceLocator loc, java.lang.Throwable err)` Create an XPathException that supplies an error message and wraps an underlying exception and supplies location information
`XPathException(java.lang.String message, java.lang.String errorCode)` Create an XPathException that supplies an error message and an error code
`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
`XPathException(java.lang.String message, java.lang.Throwable err)` Create an XPathException that supplies an error message and wraps an underlying exception
`XPathException(java.lang.Throwable err)` Create an XPathException that wraps another exception

Method Summary
`java.lang.String` `getErrorCodeLocalPart()` Get the local part of the name of the error code
`java.lang.String` `getErrorCodeNamespace()` Get the namespace URI part of the name of the error code
`Value` `getErrorObject()` Get the error object associated with this error.
`XPathContext` `getXPathContext()` Get the dynamic context at the time the exception occurred
`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
`boolean` `isStaticError()` Ask whether this exception represents a static error
`boolean` `isTypeError()` Ask whether this exception represents a type error
`XPathException` `makeStatic()` Force an exception to a static error
`static XPathException` `makeXPathException(javax.xml.transform.TransformerException err)` Create an XPathException from a JAXP TransformerException.
`void` `maybeSetContext(XPathContext context)` Set the context of a message, only if it is not already set
`void` `maybeSetLocation(javax.xml.transform.SourceLocator locator)` Set the location of a message, only if it is not already set
`void` `setErrorCode(java.lang.String code)` Set the error code.
`void` `setErrorCode(java.lang.String namespace, java.lang.String code)` Set the error code.
`void` `setErrorObject(Value value)` Set the error object associated with this error.
`void` `setHasBeenReported()` Mark this error to indicate that it has already been reported to the error listener, and should not be reported again
`void` `setIsStaticError(boolean is)` Mark this exception to indicate that it represents (or does not represent) a static error
`void` `setIsTypeError(boolean is)` Mark this exception to indicate that it represents (or does not represent) a type error
`void` `setXPathContext(XPathContext context)` Set dynamic context information in the exception object

Methods inherited from class javax.xml.transform.TransformerException
`getCause, getException, getLocationAsString, getLocator, getMessageAndLocation, initCause, printStackTrace, printStackTrace, printStackTrace, setLocator`

Methods inherited from class java.lang.Throwable
`fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, setStackTrace, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

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,
                          javax.xml.transform.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(java.lang.String message,
                          javax.xml.transform.SourceLocator 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 occurred
    `err` - 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 message
    `errorCode` - 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 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

### makeXPathException

    public static XPathException makeXPathException(javax.xml.transform.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

### makeStatic

    public XPathException makeStatic()

  Force an exception to a static error

  Returns:
    this exception, marked as a static 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

### 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

### 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

### 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, and if no other namespace has been set, it sets the namespace of the error code to the standard system namespace `NamespaceConstant.ERR`

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

### setErrorCode

    public void setErrorCode(java.lang.String namespace,
                             java.lang.String code)

  Set the error code. The error code is a QName; this method sets both parts of the name.

  Parameters:
    `namespace` - The namespace URI part of the name of the error code
    `code` - The local part of the name of the error code

### 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(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

### 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

### setHasBeenReported

    public void setHasBeenReported()

  Mark this error to indicate that it has already been reported to the error listener, and should not be reported again

### 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(javax.xml.transform.SourceLocator locator)

  Set the location of a message, only if it is not already set

  Parameters:
    `locator` - 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)

Copyright (c) Saxonica Limited. All rights reserved.