Java Reference
In-Depth Information
public class Product {
private static final long serialVersionUID = 12345L;
private String name;
private Date mfrDate;
public Product() {
}
public Date getMfrDate() {
return mfrDate;
}
public void setMfrDate(Date mfrDate) {
this.mfrDate = mfrDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Note that
schemagen
will ignore private fields in classes that do not also specify getter
and setter methods for them. The output after invoking
schemagen
looks like that shown in
Example2-17.Schema generated by schemagen for Product.java
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="product">
<xs:sequence>
<xs:element name="mfrDate" type="xs:dateTime" minOccurs="0"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
There are a few interesting things to discuss here. First, a single
complexType
, not an element,
was created for your class. Also, there is no target namespace for the schema.