Building and Running the Example
Building and Running the Example
The global, schema, and package, and most of the class customizations for the Customize Inline
and Datatype Converter examples are identical. Where the Datatype Converter example differs
from the Customize Inline example is in the parseMethod and printMethod used for converting
XML data to the Java int data type.
Specifically, rather than using methods in the custom MyDataTypeConverter class to perform
these data type conversions, the Datatype Converter example uses the built-in methods
provided by javax.xml.bind.DatatypeConverter:
<xsd:simpleType name=
"ZipCodeType">
<xsd:annotation>
<xsd:appinfo>
<jxb:javaType name=
"int"
parseMethod=
"javax.xml.bind.DatatypeConverter.parseInt"
printMethod=
"javax.xml.bind.DatatypeConverter.printInt"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base=
"xsd:integer">
<xsd:minInclusive value=
"10000"/>
<xsd:maxInclusive value=
"99999"/>
</xsd:restriction>
</xsd:simpleType>
Building and Running the Datatype Converter Example Using
NetBeans IDE
Follow these instructions to build and run the Datatype Converter 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 datatypeconverter folder.
4. Select the Open as Main Project check box.
5. Click Open Project Folder.
6. Right-click the datatypeconverter project and select Run Project.
Building and Running the Datatype Converter Example Using Ant
To compile and run the Datatype Converter example using Ant, in a terminal window, go to the
tut-install/javaeetutorial5/examples/jaxb/datatypeconverter/ directory and type the
following:
ant runapp
Customizing JAXB Bindings
The Java EE 5 Tutorial · September 2007
532