JAXB اسئلة واجوبة المقابلات
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 |
احفظ للمراجعة
احفظ هذا العنصر في الإشارات المرجعية، او حدده كصعب، او ضعه في مجموعة مراجعة.
سجل الدخول لحفظ الإشارات المرجعية والاسئلة الصعبة ومجموعات المراجعة.
هل هذا مفيد؟ نعم لا
الاكثر فائدة حسب تقييم المستخدمين:
- What Is XML Binding?
- What is XML Binding Relationships?
- Please explain JAXB Use Cases.
- Why Use XML Binding?
- What are the goals of JAXB?