Annotation Interface XmlRootElement
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 The annotation causes a global element declaration to be produced in the schema. The global element declaration is associated with the XML schema type to which the class is mapped.
Example 2: Orthogonality to type inheritance
An element declaration annotated on a type is not inherited by its derived types. The following example shows this. Example 3: Associate a global element with XML Schema type to which the class is mapped.
- Since:
- 1.6, JAXB 2.0
- Author:
- Sekhar Vajjhala, Sun Microsystems, Inc.
-
Optional Element Summary
Optional Elements
-
Element Details
-
namespace
String namespacenamespace 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
String namelocal name of the XML element.If the value is "##default", then the name is derived from the class name.
- Default:
- "##default"
-