blob: 23c3362bb8b1e741cec1fcc9fb35ba0ff7877117 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (11.0.2) on Wed Apr 22 10:19:16 CDT 2020 -->
<title>XmlAnyElement (EclipseLink 3.0.0, API Reference)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2020-04-22">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="XmlAnyElement (EclipseLink 3.0.0, API Reference)";
}
}
catch(err) {
}
//-->
var pathtoroot = "../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.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 class="aboutLanguage">EclipseLink 3.0.0, API Reference</div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</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>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">jakarta.xml.bind.annotation</a></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>
<pre><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Retention.html?is-external=true" title="class or interface in java.lang.annotation" class="externalLink">@Retention</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/RetentionPolicy.html?is-external=true#RUNTIME" title="class or interface in java.lang.annotation" class="externalLink">RUNTIME</a>)
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Target.html?is-external=true" title="class or interface in java.lang.annotation" class="externalLink">@Target</a>({<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/ElementType.html?is-external=true#FIELD" title="class or interface in java.lang.annotation" class="externalLink">FIELD</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/ElementType.html?is-external=true#METHOD" title="class or interface in java.lang.annotation" class="externalLink">METHOD</a>})
public @interface <span class="memberNameLabel">XmlAnyElement</span></pre>
<div class="block">Maps a JavaBean property to XML infoset representation and/or JAXB element.
<p>
This annotation serves as a "catch-all" property while unmarshalling
xml content into a instance of a JAXB 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 &#64;XmlElement or &#64;XmlElementRef
annotation for the other JavaBean properties on the class, is added to this
"catch-all" property.
<h2>Usages:</h2>
<pre>
&#64;XmlAnyElement
public <a href="https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Element.html?is-external=true" title="class or interface in org.w3c.dom" class="externalLink"><code>Element</code></a>[] others;
// Collection of <a href="https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Element.html?is-external=true" title="class or interface in org.w3c.dom" class="externalLink"><code>Element</code></a> or JAXB elements.
&#64;XmlAnyElement(lax="true")
public <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink"><code>Object</code></a>[] others;
&#64;XmlAnyElement
private List&lt;<a href="https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Element.html?is-external=true" title="class or interface in org.w3c.dom" class="externalLink"><code>Element</code></a>&gt; nodes;
&#64;XmlAnyElement
private <a href="https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Element.html?is-external=true" title="class or interface in org.w3c.dom" class="externalLink"><code>Element</code></a> node;
</pre>
<h2>Restriction usage constraints</h2>
<p>
This annotation is mutually exclusive with
<a href="XmlElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElement</code></a>, <a href="XmlAttribute.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAttribute</code></a>, <a href="XmlValue.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlValue</code></a>,
<a href="XmlElements.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElements</code></a>, <a href="XmlID.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlID</code></a>, and <a href="XmlIDREF.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlIDREF</code></a>.
<p>
There can be only one <a href="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="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="XmlMixed.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlMixed</code></a> like this:
<pre>
// List of java.lang.String or DOM nodes.
&#64;XmlAnyElement &#64;XmlMixed
List&lt;Object&gt; others;
</pre>
<h2>Schema To Java example</h2>
The following schema would produce the following Java class:
<pre><code>
&lt;xs:complexType name="foo"&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="a" type="xs:int" /&gt;
&lt;xs:element name="b" type="xs:int" /&gt;
&lt;xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" /&gt;
&lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;
</code></pre>
<pre>
class Foo {
int a;
int b;
&#64;<a href="XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a>
List&lt;Element&gt; any;
}
</pre>
It can unmarshal instances like
<pre><code>
&lt;foo xmlns:e="extra"&gt;
&lt;a&gt;1&lt;/a&gt;
&lt;e:other /&gt; // this will be bound to DOM, because unmarshalling is orderless
&lt;b&gt;3&lt;/b&gt;
&lt;e:other /&gt;
&lt;c&gt;5&lt;/c&gt; // this will be bound to DOM, because the annotation doesn't remember namespaces.
&lt;/foo&gt;
</code></pre>
The following schema would produce the following Java class:
<pre><code>
&lt;xs:complexType name="bar"&gt;
&lt;xs:complexContent&gt;
&lt;xs:extension base="foo"&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="c" type="xs:int" /&gt;
&lt;xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" /&gt;
&lt;/xs:sequence&gt;
&lt;/xs:extension&gt;
&lt;/xs:complexType&gt;
</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>
&lt;bar xmlns:e="extra"&gt;
&lt;a&gt;1&lt;/a&gt;
&lt;e:other /&gt; // this will be bound to DOM, because unmarshalling is orderless
&lt;b&gt;3&lt;/b&gt;
&lt;e:other /&gt;
&lt;c&gt;5&lt;/c&gt; // this now goes to Bar.c
&lt;e:other /&gt; // this will go to Foo.any
&lt;/bar&gt;
</code></pre>
<h2>Using <a href="XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> with <a href="XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a></h2>
<p>
The <a href="XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a> annotation can be used with <a href="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>
&lt;xs:complexType name="foo"&gt;
&lt;xs:choice maxOccurs="unbounded" minOccurs="0"&gt;
&lt;xs:element name="a" type="xs:int" /&gt;
&lt;xs:element name="b" type="xs:int" /&gt;
&lt;xs:any namespace="##other" processContents="lax" /&gt;
&lt;/xs:choice&gt;
&lt;/xs:complexType&gt;
</code></pre>
<pre>
class Foo {
&#64;<a href="XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a>(lax="true")
&#64;<a href="XmlElementRefs.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRefs</code></a>({
&#64;<a href="XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a>(name="a", type="JAXBElement.class")
&#64;<a href="XmlElementRef.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlElementRef</code></a>(name="b", type="JAXBElement.class")
})
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util" class="externalLink"><code>List</code></a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink"><code>Object</code></a>&gt; others;
}
&#64;XmlRegistry
class ObjectFactory {
...
&#64;XmlElementDecl(name = "a", namespace = "", scope = Foo.class)
<a href="../JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a>&lt;Integer&gt; createFooA( Integer i ) { ... }
&#64;XmlElementDecl(name = "b", namespace = "", scope = Foo.class)
<a href="../JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a>&lt;Integer&gt; createFooB( Integer i ) { ... }
</pre>
It can unmarshal instances like
<pre>
<code>&lt;foo xmlns:e="extra"&gt;</code>
<code> &lt;a&gt;1&lt;/a&gt;</code> // this will unmarshal to a <a href="../JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a> instance whose value is 1.
<code> &lt;e:other /&gt;</code> // this will unmarshal to a DOM <a href="https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Element.html?is-external=true" title="class or interface in org.w3c.dom" class="externalLink"><code>Element</code></a>.
<code> &lt;b&gt;3&lt;/b&gt;</code> // this will unmarshal to a <a href="../JAXBElement.html" title="class in jakarta.xml.bind"><code>JAXBElement</code></a> instance whose value is 1.
<code>&lt;/foo&gt;</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>
&#64;<a href="XmlRootElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlRootElement</code></a>
class Foo {
&#64;XmlAnyElement(lax=true)
public <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink"><code>Object</code></a>[] others;
}
</pre>
then the following document will unmarshal like this:
<pre><code>
&lt;foo&gt;
&lt;unknown /&gt;
&lt;foo /&gt;
&lt;/foo&gt;
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">Author:</span></dt>
<dd>Kohsuke Kawaguchi</dd>
<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 =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="annotation.type.optional.element.summary">
<!-- -->
</a>
<h3>Optional Element Summary</h3>
<table class="memberSummary">
<caption><span>Optional Elements</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Optional Element</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#lax()">lax</a></span></code></th>
<td class="colLast">
<div class="block">Controls the unmarshaller behavior when it sees elements
known to the current <a href="../JAXBContext.html" title="class in jakarta.xml.bind"><code>JAXBContext</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang" class="externalLink">Class</a>&lt;? extends <a href="DomHandler.html" title="interface in jakarta.xml.bind.annotation">DomHandler</a>&gt;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#value()">value</a></span></code></th>
<td class="colLast">
<div class="block">Specifies the <a href="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>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="annotation.type.element.detail">
<!-- -->
</a>
<h3>Element Detail</h3>
<a id="lax()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>lax</h4>
<pre>boolean&nbsp;lax</pre>
<div class="block">Controls the unmarshaller behavior when it sees elements
known to the current <a href="../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="XmlAnyElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlAnyElement</code></a>
is known to <a href="../JAXBContext.html" title="class in jakarta.xml.bind"><code>JAXBContext</code></a> (for example, there's a class with
<a href="XmlRootElement.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlRootElement</code></a> that has the same tag name, or there's
<a href="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 JAXB 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="../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 JAXB 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 JAXB 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>
</section>
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="value()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>value</h4>
<pre><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang" class="externalLink">Class</a>&lt;? extends <a href="DomHandler.html" title="interface in jakarta.xml.bind.annotation">DomHandler</a>&gt;&nbsp;value</pre>
<div class="block">Specifies the <a href="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>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.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 class="aboutLanguage">EclipseLink 3.0.0, API Reference</div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses.html">All&nbsp;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>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small>Copyright &#169; 2017&#x2013;2020 <a href="http://www.eclipse.org/eclipselink">Eclipse.org - EclipseLink Project</a>. All rights reserved.</small></p>
</footer>
</body>
</html>