Annotation Type XmlRootElement


  • @Retention(RUNTIME)
    @Target(TYPE)
    public @interface XmlRootElement
    Maps a class or an enum type to an XML element.

    Usage

    The XmlRootElement annotation can be used with the following program elements:

    • a top level class
    • an enum type

    See "Package Specification" in jakarta.xml.bind.package javadoc for additional common information.

    When a top level class or an enum type is annotated with the XmlRootElement annotation, then its value is represented as XML element in an XML document.

    This annotation can be used with the following annotations: XmlType, XmlEnum, XmlAccessorType, XmlAccessorOrder.

    Example 1: Associate an element with XML Schema type {@snippet : // Example: Code fragment

    Since:
    1.6, JAXB 2.0
    Author:
    Sekhar Vajjhala, Sun Microsystems, Inc.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String name
      local name of the XML element.
      java.lang.String namespace
      namespace name of the XML element.
    • Element Detail

      • namespace

        java.lang.String namespace
        namespace name of the XML element.

        If the value is "##default", then the XML namespace name is derived from the package of the class ( XmlSchema ). If the package is unnamed, then the XML namespace is the default empty namespace.

        Default:
        "##default"
      • name

        java.lang.String name
        local name of the XML element.

        If the value is "##default", then the name is derived from the class name.

        Default:
        "##default"