| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (1.8.0_252) on Fri Jul 16 09:39:10 UTC 2021 --> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>XmlPath (EclipseLink 3.0.2, API Reference)</title> |
| <meta name="date" content="2021-07-16"> |
| <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="XmlPath (EclipseLink 3.0.2, API Reference)"; |
| } |
| } |
| 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 class="aboutLanguage">EclipseLink 3.0.2, API Reference</div> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../org/eclipse/persistence/oxm/annotations/XmlParameter.html" title="annotation in org.eclipse.persistence.oxm.annotations"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/eclipse/persistence/oxm/annotations/XmlPaths.html" title="annotation in org.eclipse.persistence.oxm.annotations"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/eclipse/persistence/oxm/annotations/XmlPath.html" target="_top">Frames</a></li> |
| <li><a href="XmlPath.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><a href="#annotation.type.required.element.summary">Required</a> | </li> |
| <li>Optional</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">org.eclipse.persistence.oxm.annotations</div> |
| <h2 title="Annotation Type XmlPath" class="title">Annotation Type XmlPath</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre><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">@Target</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Target.html?is-external=true#value--" title="class or interface in java.lang.annotation">value</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">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">METHOD</a>}) |
| <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">@Retention</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Retention.html?is-external=true#value--" title="class or interface in java.lang.annotation">value</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">RUNTIME</a>) |
| public @interface <span class="memberNameLabel">XmlPath</span></pre> |
| <div class="block"><p>XPath based mapping is what allows an existing object model to be mapped |
| to an existing XML schema. The <code>@XmlPath</code> annotation is the means by |
| which XPath based mapping is achieved.</p> |
| <b>Example 1 - Using <code>@XmlPath</code> to Add a Grouping Element</b> |
| <p>Sometimes grouping elements are added to your document to organise data. |
| JAXB has this concept for collection properties in the form of |
| <code>@XmlElementWrapper</code>. Here we'll use <code>@XmlPath</code> for |
| non-collection properties. In this case we'll nest the billing/shipping |
| address data within the "contact-info" element.</p> |
| <pre> |
| import jakarta.xml.bind.annotation.*; |
| import org.eclipse.persistence.oxm.annotations.XmlPath; |
| |
| @XmlRootElement |
| @XmlAccessorType(XmlAccessType.FIELD) |
| public class Customer { |
| @XmlPath("contact-info/billing-address") |
| private Address billingAddress; |
| |
| @XmlPath("contact-info/shipping-address") |
| private Address shippingAddress; |
| } |
| </pre> |
| This will produce XML like: |
| <pre><code> |
| <xmp> |
| <customer> |
| <contact-info> |
| <billing-address> |
| <street>1 Billing Street</street> |
| </billing-address> |
| <shipping-address> |
| <street>2 Shipping Road</street> |
| </shipping-address> |
| </contact-info> |
| </customer> |
| </xmp></code> |
| </pre> |
| <b>Example 2 - Using <code>@XmlPath</code> to Map by Position</b> |
| <p>Normally in JAXB elements with the same name must be mapped to a |
| collection property. Using the @XmlPath extension you map non-collection |
| properties to a repeated element by index.</p> |
| <pre> |
| import jakarta.xml.bind.annotation.*; |
| import org.eclipse.persistence.oxm.annotations.XmlPath; |
| |
| @XmlRootElement |
| @XmlAccessorType(XmlAccessType.FIELD) |
| public class Customer { |
| @XmlPath("address[1]") |
| private Address billingAddress; |
| |
| @XmlPath("address[2]") |
| private Address shippingAddress; |
| } |
| </pre> |
| This will produce XML like: |
| <pre><code> |
| <xmp> |
| <customer> |
| <address> |
| <street>1 Billing Street</street> |
| </address> |
| <address> |
| <street>2 Shipping Road</street> |
| </address> |
| </customer> |
| </xmp></code> |
| </pre> |
| <b>Example 3 - Using <code>@XmlPath</code> to Map Two Objects to the Same Node</b> |
| <p>We have seen how <code>@XmlPath</code> can be used to expand the structure by |
| adding a grouping element. <code>@XmlPath</code> can also be used to collapse the |
| structure by mapping two objects to the same node.</p> |
| <pre> |
| import jakarta.xml.bind.annotation.*; |
| import org.eclipse.persistence.oxm.annotations.XmlPath; |
| |
| @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) |
| public class Customer { |
| @XmlPath(".") |
| private Address billingAddress; |
| |
| private Address shippingAddress; |
| } |
| </pre> |
| This will produce XML like: |
| <pre><code> |
| <xmp> |
| <customer> |
| <street>1 Billing Street</street> |
| <shippingAddress> |
| <street>2 Shipping Road</street> |
| </shippingAddress> |
| </customer> |
| </xmp></code> |
| </pre></div> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="annotation.type.required.element.summary"> |
| <!-- --> |
| </a> |
| <h3>Required Element Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Required Element Summary table, listing required elements, and an explanation"> |
| <caption><span>Required Elements</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Required Element and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/persistence/oxm/annotations/XmlPath.html#value--">value</a></span></code> |
| <div class="block">The XPath for this property.</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="value--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>value</h4> |
| <pre>public abstract <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> value</pre> |
| <div class="block"><p>The XPath for this property. A subset of the XPath specification may be |
| used to specify mappings. The following concepts are supported:</p> |
| <ul> |
| <li>Attribute - "@id"</li> |
| <li>Element - "address"</li> |
| <li>Element by Position - "address[1]"</li> |
| <li>Element by Predicate - "address[@type='mailing']"</li> |
| <li>Element Text - "name/text()"</li> |
| <li>Text - "text()"</li> |
| <li>Self - "."</li> |
| <li>Combination - "personal-info/name[2]/text()"</li> |
| </ul> |
| <p>For namespace qualified nodes, the prefixes defined in the XmlNs |
| annotations can be used to qualify the XPath fragments. Unqualified |
| fragments will assumed to be in the namespace specified using |
| @XmlSchema.</p> |
| <b>Example</b> |
| <p>Assuming the following namespace information has been set up using the |
| @XmlSchema annotation:</p> |
| <pre> |
| @XmlSchema(namespace = "http://www.example.org/FOO", |
| xmlns = {@XmlNs(prefix="ns", namespaceURI="http://www.example.com/BAR")}, |
| elementFormDefault = XmlNsForm.QUALIFIED) |
| package org.example; |
| |
| import jakarta.xml.bind.annotation.*; |
| </pre> |
| <p>Then the following XPath:</p> |
| <pre> |
| @XmlPath("contact-info/ns:address/@id") |
| </pre> |
| <p>Will be qualified as:</p> |
| <ul> |
| <li>contact-info - in "http://www.example.org/FOO" namespace.</li> |
| <li>address - in "http://www.example.com/BAR" namespace.</li> |
| <li>@id - in no namespace.</li> |
| </ul></div> |
| <dl> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><code>XmlSchema</code>, |
| <code>XmlNs</code></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 class="aboutLanguage">EclipseLink 3.0.2, API Reference</div> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../org/eclipse/persistence/oxm/annotations/XmlParameter.html" title="annotation in org.eclipse.persistence.oxm.annotations"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/eclipse/persistence/oxm/annotations/XmlPaths.html" title="annotation in org.eclipse.persistence.oxm.annotations"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/eclipse/persistence/oxm/annotations/XmlPath.html" target="_top">Frames</a></li> |
| <li><a href="XmlPath.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><a href="#annotation.type.required.element.summary">Required</a> | </li> |
| <li>Optional</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 ======= --> |
| <p class="legalCopy"><small>Copyright © 2007–2021 <a href="http://www.eclipse.org/eclipselink">Eclipse.org - EclipseLink Project</a>. All rights reserved.</small></p> |
| </body> |
| </html> |