Java tutorial
import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; public class Main { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Type.class); Type type = new Type(); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(type, System.out); } @XmlRootElement public static class Type { @XmlAttribute protected final String res = "http://www.w3.org/2004/02/java2s#ConceptScheme"; } }