Annotation Interface XmlElements


@Retention(RUNTIME) @Target({FIELD,METHOD}) public @interface XmlElements

A container for multiple @XmlElement annotations.

Multiple annotations of the same type are not allowed on a program element. This annotation therefore serves as a container annotation for multiple @XmlElements as follows:

The @XmlElements annotation can be used with the following program elements:

  • a JavaBean property
  • non-static, non transient field
This annotation is intended for annotation a JavaBean collection property (e.g. List).

Usage

The usage is subject to the following constraints:

  • This annotation can be used with the following annotations: @XmlIDREF, @XmlElementWrapper.
  • If @XmlIDREF is also specified on the JavaBean property, then each @XmlElement.type() must contain a JavaBean property annotated with @XmlID.

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


Example 1: Map to a list of elements

Example 2: Map to a list of elements wrapped with another element

Example 3: Change element name based on type using an adapter.

Since:
1.6, JAXB 2.0
Author:
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
  • Sekhar Vajjhala, Sun Microsystems, Inc.
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Collection of @XmlElement annotations