Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Note:</strong> I'm the <a href="http://www.eclipse.org/eclipselink/moxy.php" rel="nofollow"><strong>EclipseLink JAXB (MOXy)</strong></a> lead and a member of the <a href="http://jcp.org/en/jsr/detail?id=222" rel="nofollow"><strong>JAXB (JSR-222)</strong></a> expert group.</p> <h2>About <code>@XmlPath</code></h2> <p><code>@XmlPath</code> is a EclipseLink JAXB (MOXy) extension and requires that you are using MOXy as your JAXB provider:</p> <ul> <li><a href="http://blog.bdoughan.com/2010/07/xpath-based-mapping.html" rel="nofollow">http://blog.bdoughan.com/2010/07/xpath-based-mapping.html</a></li> <li><a href="http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html" rel="nofollow">http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html</a></li> </ul> <p><strong>Valid Use Case #1</strong></p> <pre><code>import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlPath; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "name", propOrder = { "tag4", "id" }) public class newBean { @XmlElement(required=true) String tag4; @XmlPath("tag4/@id") String id; } </code></pre> <p><strong>Valid Use Case #2</strong></p> <pre><code>import java.util.List; import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlPath; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "name", propOrder = { "tag4", "id" }) public class newBean { @XmlPath("tag4/@id") List&lt;String&gt; id; } </code></pre> <p><strong>Invalid Use Case</strong></p> <pre><code>import java.util.List; import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlPath; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "name", propOrder = { "tag4", "id" }) public class newBean { @XmlElement(required=true) List&lt;String&gt; tag4; @XmlPath("tag4/@id") List&lt;String&gt; id; } </code></pre> <h2>Mapping Your Use Case</h2> <p>You could introduce an object that corresponds to the <code>tag4</code> element that has two properties corresponding to the <code>id</code> attribute and text. This would work with any JAXB (JSR-222) implementation.</p> <p><strong>newBean</strong></p> <pre><code>import java.util.List; import javax.xml.bind.annotation.*; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "name", propOrder = { "tag4", "id" }) public class newBean { List&lt;Tag4&gt; tag4; } </code></pre> <p><strong>Tag4</strong></p> <pre><code>import javax.xml.bind.annotation.*; @XmlAccessorType(XmlAccessType.FIELD) public class Tag4 { @XmlAttribute private String id; @XmlValue private String value; } </code></pre> <p><strong>For More Information</strong></p> <ul> <li><a href="http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html" rel="nofollow">http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload