public class AddressCreator {
public static void writeAddress(Writer pWriter) throws JAXBException {
// Create the element:
Address addr = new AddressImpl();
addr.setName(new NameTypeImpl());
addr.getName().setFirst("Jane");
addr.getName().setLast("Doe");
addr.setPostal(new PostalTypeImpl());
addr.getPostal().setStreet("34 Main Street");
addr.getPostal().setCity("Boston");
addr.getPostal().setState("MA");
addr.getPostal().setZIP("02215");
addr.setEmailDetails(new EmailDetailsTypeImpl());
EmailType email = new EmailTypeImpl();
email.setType("Private");
email.setEmailAddress("jdoe@yourcompany.com");
addr.getEmailDetails().getEmail().add(email);
email = new EmailTypeImpl();
email.setType("Office");
email.setEmailAddress("josephdoe@mycompany.com");
addr.getEmailDetails().getEmail().add(email);
email = new EmailTypeImpl();
email.setType("Office");
email.setEmailAddress("joseph.doe@mycompany.com");
addr.getEmailDetails().getEmail().add(email);
addr.setPhoneDetails(new PhoneDetailsTypeImpl());
PhoneType phone = new PhoneTypeImpl();
phone.setType("Work");
phone.setPhoneNumber("555.6789");
addr.getPhoneDetails().getPhone().add(phone);
phone = new PhoneTypeImpl();
phone.setType("Fax");
phone.setPhoneNumber("555.1212");
addr.getPhoneDetails().getPhone().add(phone);
// And save it into the file "Address.xml"
JAXBContext context = JAXBContext.newInstance("org.apache.ws.jaxme.test.misc.address");
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(JMMarshallerImpl.JAXME_XML_DECLARATION, Boolean.FALSE);