JAXB Questions et reponses d'entretien
Question : Java code for marshalling Java objects into XML.Reponse : • 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 |
Enregistrer pour revision
Ajoutez cet element aux favoris, marquez-le comme difficile ou placez-le dans un ensemble de revision.
Connectez-vous pour enregistrer des favoris, des questions difficiles et des ensembles de revision.
Est-ce utile ? Oui Non
Les plus utiles selon les utilisateurs :
- What Is XML Binding?
- What is XML Binding Relationships?
- Please explain JAXB Use Cases.
- Why Use XML Binding?
- What are the goals of JAXB?