JAXB Interviewfragen und Antworten
Question: Java code for marshalling Java objects into XML.Answer: β’ ExampleMarshaller m = factory.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); Writer fw = new FileWriter("newCars.xml"); m.marshal(cars, fw); β’ marshal method accepts β java.io.OutputStream β java.io.Writer β javax.xml.transform.Result β’ related to XSLT β org.w3c.dom.Node β’ related to DOM β org.xml.sax.ContentHandler β’ related to SAX β’ Other Marshaller methods β boolean setEventHandler(ValidationEventHandler handler) β’ same as use with Unmarshaller, but validation events are delivered during marshalling β void setProperty(String name, Object value) β’ supported properties are β jaxb.encoding - value is a String Β» the encoding to use when marshalling; defaults to βUTF-8β β jaxb.formatted.output - value is a Boolean Β» true to output line breaks and indentation; false to omit (the default) β jaxb.schemaLocation - value is a String Β» to specify xsi:schemaLocation attribute in generated XML β jaxb.noNamespaceSchemaLocation - value is a String Β» to specify xsi:noNamespaceSchemaLocation attribute in generated XML |
Zum Wiederholen speichern
Speichere diesen Eintrag als Lesezeichen, markiere ihn als schwierig oder lege ihn in einem Wiederholungsset ab.
Melde dich an, um Lesezeichen, schwierige Fragen und Wiederholungssets zu speichern.
Ist das hilfreich? Ja Nein
Am hilfreichsten laut Nutzern:
- What Is XML Binding?
- What is XML Binding Relationships?
- Please explain JAXB Use Cases.
- Why Use XML Binding?
- What are the goals of JAXB?