Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>By default the following is generated for your schema fragment:</p> <pre><code> import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "physicianList", propOrder = { "physician" }) public class PhysicianList { @XmlElement(name = "Physician") protected List&lt;Physician&gt; physician; public List&lt;Physician&gt; getPhysician() { if (physician == null) { physician = new ArrayList&lt;Physician&gt;(); } return this.physician; } } </code></pre> <p>If you annotate your XML schema:</p> <pre><code> &lt;xs:schema xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" jaxb:version="2.1"&gt; &lt;xs:complexType name="physician"&gt; &lt;xs:sequence&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="physicianList"&gt; &lt;xs:sequence&gt; &lt;xs:element name="Physician" type="physician" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:annotation&gt; &lt;xs:appinfo&gt; &lt;jaxb:property name="physicians"/&gt; &lt;/xs:appinfo&gt; &lt;/xs:annotation&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre> <p>Then you can generate the desired class:</p> <pre><code>import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "physicianList", propOrder = { "physicians" }) public class PhysicianList { @XmlElement(name = "Physician") protected List&lt;Physician&gt; physicians; public List&lt;Physician&gt; getPhysicians() { if (physicians == null) { physicians = new ArrayList&lt;Physician&gt;(); } return this.physicians; } } </code></pre>
 

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