users@jaxb.java.net

Re: Bind existing class to existing schema HOWTO

From: Dmitri Colebatch <colebatchd_at_gmail.com>
Date: Tue, 21 Jun 2005 11:19:40 +1000

Oh, I meant to add to step five:

On 6/21/05, Dmitri Colebatch <colebatchd_at_gmail.com> wrote:

> Step four - Specify the order of the fields to be serialized. We do
> this by adding the propOrder attribute (???) to the XmlType
> annotation. Suppose you have two fields, foo and bar, and you want
> foo to appear before bar, do this (note that I'm assuming you're using
> an anonymous type, if you're using a global type change this to suit):
>
> @XmlType(name = "", propOrder = { "foo", "bar" })
>
> Step five - Customize the mappings. Suppose you want foo to map to an
> element called "SomethingElse" then find the field foo:
>
> private String foo;
>
> and annotate it as follows:
>
> @XmlElement(name = "SomethingElse", namespace =
> "ElementNamespace", type=String.class)
> private String foo;
>
> Note also the namespace and type of the field.

Note that the field name used in step four is the name of the field,
not the name of the element.

cheers
dim