Class XmlValidationException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class XmlValidationException extends OpenXmlException
XML Validation Exception - Thrown when XML validation fails XML 验证异常 - 当 XML 验证失败时抛出

This exception is thrown when XML fails Schema or DTD validation. It contains the list of validation errors encountered.

当 XML 未通过 Schema 或 DTD 验证时抛出此异常。它包含遇到的验证错误列表。

Features | 主要功能:

  • Exception for XML schema/DTD validation failures - XML Schema/DTD 验证失败的异常
  • Extends OpenXmlException with specific context - 继承 OpenXmlException,带特定上下文

Usage Examples | 使用示例:

// Catch specific exception
try {
    // XML operation
} catch (XmlValidationException e) {
    System.err.println(e.getMessage());
}

Security | 安全性:

  • Thread-safe: Yes (immutable exception) - 线程安全: 是(不可变异常)
  • Null-safe: No (message must not be null) - 空值安全: 否(消息不能为 null)
Since:
JDK 25, opencode-base-xml V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • XmlValidationException

      public XmlValidationException(String message)
      Constructs a validation exception with message. 构造带消息的验证异常。
      Parameters:
      message - the detail message | 详细消息
    • XmlValidationException

      public XmlValidationException(List<String> errors)
      Constructs a validation exception with error list. 构造带错误列表的验证异常。
      Parameters:
      errors - the validation errors | 验证错误列表
    • XmlValidationException

      public XmlValidationException(String message, List<String> errors)
      Constructs a validation exception with message and error list. 构造带消息和错误列表的验证异常。
      Parameters:
      message - the detail message | 详细消息
      errors - the validation errors | 验证错误列表
    • XmlValidationException

      public XmlValidationException(String message, Throwable cause)
      Constructs a validation exception with message and cause. 构造带消息和原因的验证异常。
      Parameters:
      message - the detail message | 详细消息
      cause - the cause | 原因
  • Method Details

    • getErrors

      public List<String> getErrors()
      Returns the list of validation errors. 返回验证错误列表。
      Returns:
      the validation errors | 验证错误列表
    • hasErrors

      public boolean hasErrors()
      Returns whether there are any errors. 返回是否有任何错误。
      Returns:
      true if there are errors | 如果有错误则返回 true