Java tutorial
//package com.java2s; /******************************************************************************* * Manchester Centre for Integrative Systems Biology * University of Manchester * Manchester M1 7ND * United Kingdom * * Copyright (C) 2007 University of Manchester * * This program is released under the Academic Free License ("AFL") v3.0. * (http://www.opensource.org/licenses/academic.php) *******************************************************************************/ import javax.xml.bind.*; public class Main { /** * * @param contextPath * @return Marshaller * @throws JAXBException */ public static Marshaller getMarshaller(final String contextPath) throws JAXBException { final JAXBContext jaxbContext = JAXBContext.newInstance(contextPath); final Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); return marshaller; } }