background image

Schema Content Ordering in the Example

<< Class Content Order | Interface XmlAdapter >>
<< Class Content Order | Interface XmlAdapter >>

Schema Content Ordering in the Example

Schema Content Ordering in the Example
The purchase order code example demonstrates the effects of schema content ordering using
the @XmlAccessorOrder annotation at the package and class level, and the
@XmlType.propOrder
annotation on a class.
Class package-info.java defines @XmlAccessorOrder to be ALPHABETICAL for the package.
The public fields shipTo and billTo in class PurchaseOrderType will be affected in the
generated schema content order by this rule. Class USAddress defines the @XmlType.propOrder
annotation on the class. User of this annotation demonstrates user-defined property order
superseding ALPHABETICAL order in the generated schema.
The generated schema file can be found in the
tut-install/javaeetutorial5/examples/jaxb/j2s-xmlAccessorOrder/build/schemas/
directory.
Building and Running the XmlAccessorOrder Example Using NetBeans
IDE
Follow these instructions to build and run the XmlAccessorOrder example on your Application
Server instance using the NetBeans IDE.
1. In NetBeans IDE, select File
Open Project.
2. In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/jaxb/.
3. Select the j2s-xmlAccessorOrder folder.
4. Select the Open as Main Project check box.
5. Click Open Project Folder.
6. Right-click the j2s-xmlAccessorOrder project and select Run Project.
Building and Running the XmlAccessorOrder Example Using Ant
To compile and run the XmlAccessorOrder example using Ant, in a terminal window, go to the
tut-install/javaeetutorial5/examples/jaxb/j2s-xmlAccessorOrder/ directory and type the
following:
ant runapp
XmlAdapter Field Example
The XmlAdapter Field example demonstrates how to use the XmlAdapter interface and the
@XmlJavaTypeAdapter
annotation to provide a custom mapping of XML content into and out
of a HashMap (field) that uses an int as the key and a String as the value.
Java-to-Schema Examples
The Java EE 5 Tutorial · September 2007
540