List of usage examples for javax.xml.bind Marshaller setProperty
public void setProperty(String name, Object value) throws PropertyException;
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Items.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); File xml = new File("input.xml"); Items items = (Items) unmarshaller.unmarshal(xml); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(items, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { Root root = new Root(); Book cDev = new Book(); cDev.setName("C Development"); root.getEmployeeDesiredSkills().add(cDev); Book perlDev = new Book(); perlDev.setName("Perl Development"); root.getEmployeeDesiredSkills().add(perlDev); JAXBContext jc = JAXBContext.newInstance(Root.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(root, System.out); }
From source file:MyAbstractClass.java
public static void main(String[] args) throws JAXBException { MyClass my = new MyClass(); my.setDataType("data type"); my.setMatch("STRING MATCH"); my.setValue("value"); JAXBContext context = JAXBContext.newInstance(MyClass.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(my, System.out); }//from w ww .j a v a 2 s .com
From source file:Main.java
public static void main(final String[] args) throws Exception { JAXBContext context = JAXBContext.newInstance(Main.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); Main event = new Main(); event.setDate(new Date()); event.setDescription("im rick james"); marshaller.marshal(event, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Child.class); Child child = new Child(); child.setParentProperty1("parentProperty1"); child.setParentProperty2("parentProperty2"); child.setChildProperty("childProperty"); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(child, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { MyMessage sarm = new MyMessage(); MyGroupResponse[] sgr = new MyGroupResponse[2]; sgr[0] = new MyGroupResponse(); sgr[1] = new MyGroupResponse(); sarm.setSailingGroup(sgr);// w w w . jav a 2 s.c om JAXBElement<MyMessage> rootElement = new JAXBElement<MyMessage>(new QName("root"), MyMessage.class, sarm); JAXBContext jc = JAXBContext.newInstance(MyMessage.class, MyGroup.class, MyGroupResponse.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(rootElement, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(A.class, B.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); A a = new A(); a.setFoo("Hello World"); marshaller.marshal(a, System.out); B b = new B(); b.setFoo("Hello World"); marshaller.marshal(b, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Root.class); Root root = new Root(); DatatypeFactory dtf = DatatypeFactory.newInstance(); root.month = dtf.newXMLGregorianCalendar("--11"); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(root, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Graph.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); File xml = new File("input.xml"); Graph graph = (Graph) unmarshaller.unmarshal(xml); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(graph, System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Address.class); StringReader xml = new StringReader("<Address><Name>Test</Name></Address>"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Address address = (Address) unmarshaller.unmarshal(xml); System.out.println(address.getPostalAddress().getState()); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(address, System.out); }