Class XPathException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.libxmq.imp.xml.XPathException
All Implemented Interfaces:
Serializable

public class XPathException extends Exception
Thrown when an xpath expression cannot be compiled or evaluated. The error codes and messages are the same as the libxml2 xmlXPathError codes, since the semantics of the xpath engine are ported from libxml2 xpath.c (Copyright (C) 1998-2012 Daniel Veillard, MIT license).
See Also:
  • Field Details

    • NUMBER_ERROR

      public static final int NUMBER_ERROR
      Number encoding error.
      See Also:
    • UNFINISHED_LITERAL_ERROR

      public static final int UNFINISHED_LITERAL_ERROR
      Unfinished literal.
      See Also:
    • START_LITERAL_ERROR

      public static final int START_LITERAL_ERROR
      Start of literal expected.
      See Also:
    • VARIABLE_REF_ERROR

      public static final int VARIABLE_REF_ERROR
      Expected $ for variable reference.
      See Also:
    • UNDEF_VARIABLE_ERROR

      public static final int UNDEF_VARIABLE_ERROR
      Undefined variable.
      See Also:
    • INVALID_PREDICATE_ERROR

      public static final int INVALID_PREDICATE_ERROR
      Invalid predicate.
      See Also:
    • EXPR_ERROR

      public static final int EXPR_ERROR
      Invalid expression.
      See Also:
    • UNCLOSED_ERROR

      public static final int UNCLOSED_ERROR
      Missing closing parenthesis/brace.
      See Also:
    • UNKNOWN_FUNC_ERROR

      public static final int UNKNOWN_FUNC_ERROR
      Unregistered function.
      See Also:
    • INVALID_OPERAND

      public static final int INVALID_OPERAND
      Invalid operand.
      See Also:
    • INVALID_TYPE

      public static final int INVALID_TYPE
      Invalid type.
      See Also:
    • INVALID_ARITY

      public static final int INVALID_ARITY
      Invalid number of arguments.
      See Also:
    • INVALID_CTXT_SIZE

      public static final int INVALID_CTXT_SIZE
      Invalid context size, ie last() used outside of a predicate.
      See Also:
    • INVALID_CTXT_POSITION

      public static final int INVALID_CTXT_POSITION
      Invalid context position, ie position() used outside of a predicate.
      See Also:
    • MEMORY_ERROR

      public static final int MEMORY_ERROR
      Memory error, used when a traversal would grow a node-set without limit.
      See Also:
    • UNDEF_PREFIX_ERROR

      public static final int UNDEF_PREFIX_ERROR
      Undefined namespace prefix.
      See Also:
    • FORBID_VARIABLE_ERROR

      public static final int FORBID_VARIABLE_ERROR
      A variable reference where variables are not allowed.
      See Also:
    • RECURSION_LIMIT_EXCEEDED

      public static final int RECURSION_LIMIT_EXCEEDED
      Recursion limit exceeded.
      See Also:
  • Constructor Details

    • XPathException

      public XPathException(int code, String expr, int offset)
      Create an xpath exception.
      Parameters:
      code - The libxml2 compatible error code, eg EXPR_ERROR.
      expr - The expression that failed, or null.
      offset - The offset in the expression where the error was detected, or -1.
  • Method Details

    • detail

      public String detail()
      The message with details (libxml2 xmlXPathErrFmt), eg "Unregistered function: f", or "".
      Returns:
      The detailed message or "".
    • evaluating

      public boolean evaluating()
      True if the error happened while evaluating a compiled expression (libxml2 has no expression context for such errors).
      Returns:
      True when evaluating.
    • quiet

      public boolean quiet()
      True if an extension function failed without a message (like setting ctxt->error in libxml2), nothing should be reported.
      Returns:
      True if quiet.
    • byteOffset

      public int byteOffset()
      The offset of the error as a byte offset in the utf8 encoded expression, like the C version.
      Returns:
      The byte offset, or -1.
    • staticMessage

      public String staticMessage()
      The static libxml2 message of the code, eg "Invalid expression".
      Returns:
      The message.
    • code

      public int code()
      Returns the libxml2 compatible error code.
      Returns:
      The error code.
    • expression

      public String expression()
      Returns the expression that failed.
      Returns:
      The expression or null.
    • offset

      public int offset()
      Returns the offset into the expression where the error was detected.
      Returns:
      The offset or -1 if unknown.
    • messageFor

      public static String messageFor(int code)
      Returns the libxml2 message for an error code.
      Parameters:
      code - The error code.
      Returns:
      The message, eg "Invalid expression".