Using this approach, marshalling an example Customer would produce the following XML:

<customer><address><street>323 Main Street</street></address></customer>

Note that the Address object is marshalled to the address element.

Using @XmlDescriminatorNode / @XmlDescrimintatorValue

You can also use the MOXY-specific @XmlDescriminatorNode and @XmlDescrimintatorValue annotations available in EclipseLink 2.2 to represent inheritance. With this approach, you can select the attribute to represent the subtype.

Using the same example from above, the ContactInfo class uses the @XmlDescriminatorNode annotation to specify the XML attribute (classifier) that will hold the subclass indicator. Address and PhoneNumber are annotated with @XmlDescriminatorValue, indicating that class' indicator name (address-classifier and phone-number-classifier).