| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <title>XmlAnyElement</title> |
| <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../script.js"></script> |
| |
| <link rel="shortcut icon" href="/img/jakarta-favicon.ico"> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="XmlAnyElement"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../jakarta/xml/bind/annotation/XmlAnyAttribute.html" title="annotation in jakarta.xml.bind.annotation"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../jakarta/xml/bind/annotation/XmlAttachmentRef.html" title="annotation in jakarta.xml.bind.annotation"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?jakarta/xml/bind/annotation/XmlAnyElement.html" target="_top">Frames</a></li> |
| <li><a href="XmlAnyElement.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Field | </li> |
| <li>Required | </li> |
| <li><a href="#annotation.type.optional.element.summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#annotation.type.element.detail">Element</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">jakarta.xml.bind.annotation</div> |
| <h2 title="Annotation Type XmlAnyElement" class="title">Annotation Type XmlAnyElement</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>@Retention(value=RUNTIME) |
| @Target(value={FIELD,METHOD}) |
| public @interface <span class="memberNameLabel">XmlAnyElement</span></pre> |
| <div class="block">Maps a JavaBean property to XML infoset representation and/or JAXBElement. |
| |
| <p> |
| This annotation serves as a "catch-all" property while unmarshalling |
| xml content into a instance of a Jakarta XML Binding annotated class. It typically |
| annotates a multi-valued 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. |
| |
| <h2>Usages:</h2> |
| <pre> |
| @XmlAnyElement |
| public <code>Element</code>[] others; |
| |
| // Collection of <code>Element</code> or JAXBElements. |
| @XmlAnyElement(lax="true") |
| public <code>Object</code>[] others; |
| |
| @XmlAnyElement |
| private List<<code>Element</code>> nodes; |
| |
| @XmlAnyElement |
| private <code>Element</code> node; |
| </pre> |
| |
| <h2>Restriction usage constraints</h2> |
| <p> |
| This annotation is mutually exclusive with |
| <a href="../../../../jakarta/xml/bind/annotation/XmlElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElement</code></a>, <a href="../../../../jakarta/xml/bind/annotation/XmlAttribute.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAttribute</code></a>, <a href="../../../../jakarta/xml/bind/annotation/XmlValue.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlValue</code></a>, |
| <a href="../../../../jakarta/xml/bind/annotation/XmlElements.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElements</code></a>, <a href="../../../../jakarta/xml/bind/annotation/XmlID.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlID</code></a>, and <a href="../../../../jakarta/xml/bind/annotation/XmlIDREF.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlIDREF</code></a>. |
| |
| <p> |
| There can be only one <a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> annotated JavaBean property |
| in a class and its super classes. |
| |
| <h2>Relationship to other annotations</h2> |
| <p> |
| This annotation can be used with <a href="../../../../jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapter.html" title="annotation in jakarta.xml.bind.annotation.adapters"><code>XmlJavaTypeAdapter</code></a>, so that users |
| can map their own data structure to DOM, which in turn can be composed |
| into XML. |
| |
| <p> |
| This annotation can be used with <a href="../../../../jakarta/xml/bind/annotation/XmlMixed.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlMixed</code></a> like this: |
| <pre> |
| // List of java.lang.String or DOM nodes. |
| @XmlAnyElement @XmlMixed |
| List<Object> others; |
| </pre> |
| |
| |
| <h2>Schema To Java example</h2> |
| |
| The following schema would produce the following Java class: |
| <pre><code> |
| <xs:complexType name="foo"> |
| <xs:sequence> |
| <xs:element name="a" type="xs:int" /> |
| <xs:element name="b" type="xs:int" /> |
| <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" /> |
| </xs:sequence> |
| </xs:complexType> |
| </code></pre> |
| |
| <pre> |
| class Foo { |
| int a; |
| int b; |
| @<a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> |
| List<Element> any; |
| } |
| </pre> |
| |
| It can unmarshal instances like |
| |
| <pre><code> |
| <foo xmlns:e="extra"> |
| <a>1</a> |
| <e:other /> // this will be bound to DOM, because unmarshalling is orderless |
| <b>3</b> |
| <e:other /> |
| <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces. |
| </foo> |
| </code></pre> |
| |
| |
| |
| The following schema would produce the following Java class: |
| <pre><code> |
| <xs:complexType name="bar"> |
| <xs:complexContent> |
| <xs:extension base="foo"> |
| <xs:sequence> |
| <xs:element name="c" type="xs:int" /> |
| <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" /> |
| </xs:sequence> |
| </xs:extension> |
| </xs:complexType> |
| </code></pre> |
| |
| <pre> |
| class Bar extends Foo { |
| int c; |
| // Foo.getAny() also represents wildcard content for type definition bar. |
| } |
| </pre> |
| |
| |
| It can unmarshal instances like |
| |
| <pre><code> |
| <bar xmlns:e="extra"> |
| <a>1</a> |
| <e:other /> // this will be bound to DOM, because unmarshalling is orderless |
| <b>3</b> |
| <e:other /> |
| <c>5</c> // this now goes to Bar.c |
| <e:other /> // this will go to Foo.any |
| </bar> |
| </code></pre> |
| |
| |
| |
| |
| <h2>Using <a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> with <a href="../../../../jakarta/xml/bind/annotation/XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a></h2> |
| <p> |
| The <a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> annotation can be used with <a href="../../../../jakarta/xml/bind/annotation/XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a>s to |
| designate additional elements that can participate in the content tree. |
| |
| <p> |
| The following schema would produce the following Java class: |
| <pre><code> |
| <xs:complexType name="foo"> |
| <xs:choice maxOccurs="unbounded" minOccurs="0"> |
| <xs:element name="a" type="xs:int" /> |
| <xs:element name="b" type="xs:int" /> |
| <xs:any namespace="##other" processContents="lax" /> |
| </xs:choice> |
| </xs:complexType> |
| </code></pre> |
| |
| <pre> |
| class Foo { |
| @<a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a>(lax="true") |
| @<a href="../../../../jakarta/xml/bind/annotation/XmlElementRefs.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRefs</code></a>({ |
| @<a href="../../../../jakarta/xml/bind/annotation/XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a>(name="a", type="JAXBElement.class") |
| @<a href="../../../../jakarta/xml/bind/annotation/XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a>(name="b", type="JAXBElement.class") |
| }) |
| <code>List</code><<code>Object</code>> others; |
| } |
| |
| @XmlRegistry |
| class ObjectFactory { |
| ... |
| @XmlElementDecl(name = "a", namespace = "", scope = Foo.class) |
| <a href="../../../../jakarta/xml/bind/JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a><Integer> createFooA( Integer i ) { ... } |
| |
| @XmlElementDecl(name = "b", namespace = "", scope = Foo.class) |
| <a href="../../../../jakarta/xml/bind/JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a><Integer> createFooB( Integer i ) { ... } |
| </pre> |
| |
| It can unmarshal instances like |
| |
| <pre> |
| <code> <foo xmlns:e="extra"></code> |
| <code> <a>1</a></code> // this will unmarshal to a <a href="../../../../jakarta/xml/bind/JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a> instance whose value is 1. |
| <code> <e:other /></code> // this will unmarshal to a DOM <code>Element</code>. |
| <code> <b>3</b></code> // this will unmarshal to a <a href="../../../../jakarta/xml/bind/JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a> instance whose value is 1. |
| <code> </foo></code> |
| </pre> |
| |
| |
| |
| |
| <h2>W3C XML Schema "lax" wildcard emulation</h2> |
| The lax element of the annotation enables the emulation of the "lax" wildcard semantics. |
| For example, when the Java source code is annotated like this: |
| <pre> |
| @<a href="../../../../jakarta/xml/bind/annotation/XmlRootElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlRootElement</code></a> |
| class Foo { |
| @XmlAnyElement(lax=true) |
| public <code>Object</code>[] others; |
| } |
| </pre> |
| then the following document will unmarshal like this: |
| <pre><code> |
| <foo> |
| <unknown /> |
| <foo /> |
| </foo> |
| |
| Foo foo = unmarshal(); |
| // 1 for 'unknown', another for 'foo' |
| assert foo.others.length==2; |
| // 'unknown' unmarshals to a DOM element |
| assert foo.others[0] instanceof Element; |
| // because of lax=true, the 'foo' element eagerly |
| // unmarshals to a Foo object. |
| assert foo.others[1] instanceof Foo; |
| </code></pre></div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>1.6, JAXB 2.0</dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="annotation.type.optional.element.summary"> |
| <!-- --> |
| </a> |
| <h3>Optional Element Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation"> |
| <caption><span>Optional Elements</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Optional Element and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html#lax--">lax</a></span></code> |
| <div class="block">Controls the unmarshaller behavior when it sees elements |
| known to the current <a href="../../../../jakarta/xml/bind/JAXBContext.html" title="class in jakarta.xml.bind"><code>JAXBContext</code></a>.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>java.lang.Class<? extends <a href="../../../../jakarta/xml/bind/annotation/DomHandler.html" title="interface in jakarta.xml.bind.annotation">DomHandler</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html#value--">value</a></span></code> |
| <div class="block">Specifies the <a href="../../../../jakarta/xml/bind/annotation/DomHandler.html" title="interface in jakarta.xml.bind.annotation"><code>DomHandler</code></a> which is responsible for actually |
| converting XML from/to a DOM-like data structure.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="annotation.type.element.detail"> |
| <!-- --> |
| </a> |
| <h3>Element Detail</h3> |
| <a name="lax--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>lax</h4> |
| <pre>public abstract boolean lax</pre> |
| <div class="block">Controls the unmarshaller behavior when it sees elements |
| known to the current <a href="../../../../jakarta/xml/bind/JAXBContext.html" title="class in jakarta.xml.bind"><code>JAXBContext</code></a>. |
| |
| <dl> |
| <dt>When false</dt> |
| <dd> |
| If false, all the elements that match the property will be unmarshalled |
| to DOM, and the property will only contain DOM elements. |
| </dd> |
| |
| <dt>When true</dt> |
| <dd> |
| If true, when an element matches a property marked with <a href="../../../../jakarta/xml/bind/annotation/XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> |
| is known to <a href="../../../../jakarta/xml/bind/JAXBContext.html" title="class in jakarta.xml.bind"><code>JAXBContext</code></a> (for example, there's a class with |
| <a href="../../../../jakarta/xml/bind/annotation/XmlRootElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlRootElement</code></a> that has the same tag name, or there's |
| <a href="../../../../jakarta/xml/bind/annotation/XmlElementDecl.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementDecl</code></a> that 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 unmarshals |
| the element to a <a href="../../../../jakarta/xml/bind/JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a>, 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. |
| </dd> |
| </dl> |
| |
| <p> |
| 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. |
| |
| <p> |
| This can be used to emulate the "lax" wildcard semantics of the W3C XML Schema.</div> |
| <dl> |
| <dt>Default:</dt> |
| <dd>false</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="value--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>value</h4> |
| <pre>public abstract java.lang.Class<? extends <a href="../../../../jakarta/xml/bind/annotation/DomHandler.html" title="interface in jakarta.xml.bind.annotation">DomHandler</a>> value</pre> |
| <div class="block">Specifies the <a href="../../../../jakarta/xml/bind/annotation/DomHandler.html" title="interface in jakarta.xml.bind.annotation"><code>DomHandler</code></a> which is responsible for actually |
| converting XML from/to a DOM-like data structure.</div> |
| <dl> |
| <dt>Default:</dt> |
| <dd>jakarta.xml.bind.annotation.W3CDomHandler.class</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../jakarta/xml/bind/annotation/XmlAnyAttribute.html" title="annotation in jakarta.xml.bind.annotation"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../jakarta/xml/bind/annotation/XmlAttachmentRef.html" title="annotation in jakarta.xml.bind.annotation"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?jakarta/xml/bind/annotation/XmlAnyElement.html" target="_top">Frames</a></li> |
| <li><a href="XmlAnyElement.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Field | </li> |
| <li>Required | </li> |
| <li><a href="#annotation.type.optional.element.summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#annotation.type.element.detail">Element</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |