Annotation Interface XmlRoot


@Retention(RUNTIME) @Target(TYPE) @Documented public @interface XmlRoot
XML Root Element Annotation - Marks a class as an XML root element XML 根元素注解 - 标记类为 XML 根元素

This annotation specifies the root element name for XML binding.

此注解指定 XML 绑定的根元素名称。

Features | 主要功能:

  • Define root element name for XML binding - 定义 XML 绑定的根元素名称
  • Namespace URI support - 命名空间 URI 支持
  • Defaults to lowercase class name if not specified - 未指定时默认使用小写类名

Usage Examples | 使用示例:

@XmlRoot("user")
public class User {
    private String name;
    private String email;
}

@XmlRoot(value = "item", namespace = "http://example.com")
public class Item {
    private String id;
}

Security | 安全性:

  • Thread-safe: Yes (annotation is immutable) - 线程安全: 是(注解不可变)
  • Null-safe: N/A (annotation type) - 空值安全: 不适用(注解类型)
Since:
JDK 25, opencode-base-xml V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The namespace URI.
    The element name.
  • Element Details

    • value

      String value
      The element name. 元素名称。
      Returns:
      the element name, defaults to class name | 元素名称,默认为类名
      Default:
      ""
    • namespace

      String namespace
      The namespace URI. 命名空间 URI。
      Returns:
      the namespace URI | 命名空间 URI
      Default:
      ""