This annotation adds information that would be available from a schema type, but isn‘t implied by a Java class declaration. The annotation has several attributes:
factoryClass
andfactoryMethod
define the class containing a no-argument method for creating an instance of this class as the equivalent of an empty XML element.- The attribute
name
provides the XML schema name if you don‘t want to use the class name. - The
namespace
attribute provides the name of the target namespace. - The string array value defined by
propOrder
establishes an ordering of the sub-elements. (It‘s pretty obvious that there can‘t be a connection between the textual order of items in a class definition and the order its fields are returned by reflection methods.)
Here is an example for XmlType
, requesting that the elements title
, items
and cluster
should appear in the given order:
@XmlRootElement @XmlType( propOrder={ "title", "items", "cluster" } ) public class Document { ... }
时间: 2024-11-02 15:39:28