Package jakarta.xml.bind.annotation
Annotation Type XmlAnyElement
-
@Retention(RUNTIME) @Target({FIELD,METHOD}) public @interface XmlAnyElementMaps a JavaBean property to XML infoset representation and/or JAXBElement.This annotation serves as a "catch-all" property while unmarshalling xml content into an instance of a Jakarta XML Binding annotated class. It typically annotates a multivalued JavaBean property, but it can occur on single value JavaBean property. During unmarshalling, each xml element that does not match a static @XmlElement or @XmlElementRef annotation for the other JavaBean properties on the class, is added to this "catch-all" property.
Usages:
{@snippet :- Since:
- 1.6, JAXB 2.0
- Author:
- Kohsuke Kawaguchi
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanlaxControls the unmarshaller behavior when it sees elements known to the currentJAXBContext.java.lang.Class<? extends DomHandler<?,?>>valueSpecifies theDomHandlerwhich is responsible for actually converting XML from/to a DOM-like data structure.
-
-
-
Element Detail
-
lax
boolean lax
Controls the unmarshaller behavior when it sees elements known to the currentJAXBContext.- When false
- If false, all the elements that match the property will be unmarshalled to DOM, and the property will only contain DOM elements.
- When true
-
If true, when an element matches a property marked with
XmlAnyElementis known toJAXBContext(for example, there's a class withXmlRootElementthat has the same tag name, or there'sXmlElementDeclthat has the same tag name), the unmarshaller will eagerly unmarshal this element to the Jakarta XML Binding object, instead of unmarshalling it to DOM. Additionally, if the element is unknown but it has a known xsi:type, the unmarshaller eagerly unmarshalls the element to aJAXBElement, with the unknown element name and the JAXBElement value is set to an instance of the Jakarta XML Binding mapping of the known xsi:type.
As a result, after the unmarshalling, the property can become heterogeneous; it can have both DOM nodes and some Jakarta XML Binding objects at the same time.
This can be used to emulate the "lax" wildcard semantics of the W3C XML Schema.
- Default:
- false
-
-
-
value
java.lang.Class<? extends DomHandler<?,?>> value
Specifies theDomHandlerwhich is responsible for actually converting XML from/to a DOM-like data structure.- Default:
- jakarta.xml.bind.annotation.W3CDomHandler.class
-
-