class Legend {

    public void marshall(Writer writer) {
        try {
            JAXBContext context = JAXBContext.newInstance(
            		Legend.class);
            Marshaller m = context.createMarshaller();
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            m.marshal(this, writer);
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }

}