How Does JAXB Compare to XMLBeans?
In previous posts I compared JAXB (JSR-222) to Simple and XStream when starting from Java objects. In this post I'll compare JAXB to XMLBeans when starting from an XML schema. I will use XMLBeans 2.5.0 (December 2009) which is the latest release. XML Schema (customer.xsd) Below is the XML schema that will be used to generate our domain models. Generating the Classes XMLBeans Below is the call to generate the XMLBeans classes from our XML schema. For the purposes of this example we will use the -srconly flag to generate only the source. 1 scomp -d out -srconly customer.xsd Below are all the artifacts that are generated by XMLBeans. The XML Schema Binary (XSB) files contain metadata need to perform binding and validation: com/example Address.java CustomerDocument.java PhoneNumber.java com/example/impl AddressImpl.java CustomerDocumentImpl.java PhoneNumberImpl.java schemaorg_apache_xmlbeans element/http_3A_2F_2Fwww_2Eexample_2Ecom customer.xsb javaname/com/example Address.xsb CustomerDocument.xsb PhoneNumber.xsb CustomerDocument Customer.xsb namespace/http_3A_2F_2Fwww_2Eexample_2Ecom xmlns.xsb src customer.xsd system/s16C99350D7D3A2544A7BFD5E35CA8BC8 address6f49type.xsb customer3fdddoctype.xsb customer11d7elemtype.xsb customerelement.xsb index.xsb phonenumber9c83type.xsb TypeSystemHolder.class type/http_3A_2F_2Fwww_2Eexample_2Ecom address.xsb phone_2Dnumber.xsb JAXB Below is the call to generate the JAXB classes from an XML schema: 1 xjc -d out customer.xsd Below are all the artifacts that are generated by JAXB. Note how many fewer artifacts are created: com.example Address.java Customer.java ObjectFactory.java package-info.java PhoneNumber.java Java Model - XMLBeans XMLBeans produces a set of Java interfaces that are backed by implementation classes. Below we will examine one of these pairs. Address This is one of the interfaces that is generated by XMLBeans. There are a few interesting things worth noting: This interface exposes POJO properties (line 24), and a DOM like model (line 29). This interface includes a factory (line 66). This factory is used for creating instances of the Address object (line 68), and for unmarshalling instances of Address from XML (line 75). package com.example; /** * An XML address(@http://www.example.com). * * This is a complex type. */ public interface Address extends org.apache.xmlbeans.XmlObject { public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType) org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Address.class.getClassLoader(), "schemaorg_apache_xmlbeans.system.s16C99350D7D3A2544A7BFD5E35CA8BC8").resolveHandle("address6f49type"); /** * Gets the "street" element */ java.lang.String getStreet(); /** * Gets (as xml) the "street" element */ org.apache.xmlbeans.XmlString xgetStreet(); /** * Sets the "street" element */ void setStreet(java.lang.String street); /** * Sets (as xml) the "street" element */ void xsetStreet(org.apache.xmlbeans.XmlString street); /** * Gets the "city" element */ java.lang.String getCity(); /** * Gets (as xml) the "city" element */ org.apache.xmlbeans.XmlString xgetCity(); /** * Sets the "city" element */ void setCity(java.lang.String city); /** * Sets (as xml) the "city" element */ void xsetCity(org.apache.xmlbeans.XmlString city); /** * A factory class with static methods for creating instances * of this type. */ public static final class Factory { public static com.example.Address newInstance() { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); } public static com.example.Address newInstance(org.apache.xmlbeans.XmlOptions options) { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); } /** @param xmlAsString the string value to parse */ public static com.example.Address parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null ); } public static com.example.Address parse(java.lang.String xmlAsString, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, options ); } /** @param file the file from which to load an xml document */ public static com.example.Address parse(java.io.File file) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, null ); } public static com.example.Address parse(java.io.File file, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, options ); } public static com.example.Address parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, null ); } public static com.example.Address parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, options ); } public static com.example.Address parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, null ); } public static com.example.Address parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, options ); } public static com.example.Address parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, null ); } public static com.example.Address parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, options ); } public static com.example.Address parse(javax.xml.stream.XMLStreamReader sr) throws org.apache.xmlbeans.XmlException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, null ); } public static com.example.Address parse(javax.xml.stream.XMLStreamReader sr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, options ); } public static com.example.Address parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, null ); } public static com.example.Address parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, options ); } /** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */ public static com.example.Address parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, null ); } /** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */ public static com.example.Address parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { return (com.example.Address) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, options ); } /** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */ public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); } /** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */ public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); } private Factory() { } // No instance of this class allowed } } AddressImpl Below is the source for the implementation class: /** * XML Type: address * Namespace: http://www.example.com * Java type: com.example.Address * * Automatically generated - do not modify. */ package com.example.impl; /** * An XML address(@http://www.example.com). * * This is a complex type. */ public class AddressImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements com.example.Address { private static final long serialVersionUID = 1L; public AddressImpl(org.apache.xmlbeans.SchemaType sType) { super(sType); } private static final javax.xml.namespace.QName STREET$0 = new javax.xml.namespace.QName("http://www.example.com", "street"); private static final javax.xml.namespace.QName CITY$2 = new javax.xml.namespace.QName("http://www.example.com", "city"); /** * Gets the "street" element */ public java.lang.String getStreet() { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.SimpleValue target = null; target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STREET$0, 0); if (target == null) { return null; } return target.getStringValue(); } } /** * Gets (as xml) the "street" element */ public org.apache.xmlbeans.XmlString xgetStreet() { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.XmlString target = null; target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STREET$0, 0); return target; } } /** * Sets the "street" element */ public void setStreet(java.lang.String street) { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.SimpleValue target = null; target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STREET$0, 0); if (target == null) { target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(STREET$0); } target.setStringValue(street); } } /** * Sets (as xml) the "street" element */ public void xsetStreet(org.apache.xmlbeans.XmlString street) { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.XmlString target = null; target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STREET$0, 0); if (target == null) { target = (org.apache.xmlbeans.XmlString)get_store().add_element_user(STREET$0); } target.set(street); } } /** * Gets the "city" element */ public java.lang.String getCity() { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.SimpleValue target = null; target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(CITY$2, 0); if (target == null) { return null; } return target.getStringValue(); } } /** * Gets (as xml) the "city" element */ public org.apache.xmlbeans.XmlString xgetCity() { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.XmlString target = null; target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(CITY$2, 0); return target; } } /** * Sets the "city" element */ public void setCity(java.lang.String city) { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.SimpleValue target = null; target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(CITY$2, 0); if (target == null) { target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(CITY$2); } target.setStringValue(city); } } /** * Sets (as xml) the "city" element */ public void xsetCity(org.apache.xmlbeans.XmlString city) { synchronized (monitor()) { check_orphaned(); org.apache.xmlbeans.XmlString target = null; target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(CITY$2, 0); if (target == null) { target = (org.apache.xmlbeans.XmlString)get_store().add_element_user(CITY$2); } target.set(city); } } } Java Model - JAXB JAXB implementations produce annotated POJOs. The generated classes closely resemble the ones we created by hand in the comparisons to Simple and XStream. Address // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2012.01.23 at 01:19:09 PM EST // package com.example; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * Java class for address complex type. * * The following schema fragment specifies the expected content contained within this class. * * * * * * * * * * * * * * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "address", propOrder = { "street", "city" }) public class Address { @XmlElement(required = true) protected String street; @XmlElement(required = true) protected String city; /** * Gets the value of the street property. * * @return * possible object is * {@link String } * */ public String getStreet() { return street; } /** * Sets the value of the street property. * * @param value * allowed object is * {@link String } * */ public void setStreet(String value) { this.street = value; } /** * Gets the value of the city property. * * @return * possible object is * {@link String } * */ public String getCity() { return city; } /** * Sets the value of the city property. * * @param value * allowed object is * {@link String } * */ public void setCity(String value) { this.city = value; } } Demo Code In the demo code we will unmarshal an XML file, add a phone number to the resulting customer object, and then marshal the customer back to XML. XMLBeans With XMLBeans the generated domain model is used to unmarshal (line 12) and marshal (line 19). The generated model also contains methods for interacting with collections (line 15), this is necessary as XMLBeans represent collection properties as arrays. package com.example; import java.io.File; import com.example.CustomerDocument.Customer; public class Demo { public static void main(String[] args) throws Exception { File xml = new File("src/com/example/input.xml"); CustomerDocument customerDocument = CustomerDocument.Factory.parse(xml); Customer customer = customerDocument.getCustomer(); PhoneNumber homePhoneNumber = customer.addNewPhoneNumber(); homePhoneNumber.setType("home"); homePhoneNumber.set("555-HOME"); customerDocument.save(System.out); } } JAXB JAXB separates the marshal/unmarshal calls into the standard runtime APIs (lines 9, 13 and 22). A java.util.List is used for collection properties (line 18). package com.example; import java.io.File; import javax.xml.bind.*; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance("com.example"); File xml = new File("src/com/example/input.xml"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Customer customer = (Customer) unmarshaller.unmarshal(xml); PhoneNumber homePhoneNumber = new PhoneNumber(); homePhoneNumber.setType("home"); homePhoneNumber.setValue("555-HOME"); customer.getPhoneNumber().add(homePhoneNumber); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(customer, System.out); } } Summary Both XMLBeans and JAXB produce Java models that make it easy for developers to interact with XML. The JAXB model however is annotated POJOs which has the following advantages: JPA annotations could easily be applied to the JAXB model enabling the model to be persisted in a relational database. Once generated the JAXB model could be modified to handle changes in the XML schema, the XMLBeans model would need to be regenerated. Starting with Java SE 6 no additional compile/runtime dependencies are required for the JAXB model. There are multiple JAXB implementations available: EclipseLink MOXy, Metro, Apache JaxMe, etc. JAXB is the standard binding layer for JAX-WS (SOAP) and JAX-RS (RESTful) Web Services. From http://blog.bdoughan.com/2012/01/how-does-jaxb-compare-to-xmlbeans.html
February 1, 2012
·
24,809 Views
·
0 Likes
Comments
Nov 14, 2013 · Jonathan Giles
Interesting article. Below is some additional information.
An implementation of JAXB 2 (JSR-222) implementation is included in Java SE 6. It will work with Java SE 5 and above. JAXB 2 was introduced as part of Java EE 5.
This statement is pretty true. A couple things to note are:
Apr 24, 2013 · mitchp
Apr 24, 2013 · Sangam Uprety
Mar 17, 2013 · Richard Carr
In this post an XmlAdapter is only required to unmarshal the document from use case #4. If a JAXB (JSR-222) impl can produce XML without an XmlAdapter then it can consume that XML without an XmlAdapter.
Mar 17, 2013 · Richard Carr
In this post an XmlAdapter is only required to unmarshal the document from use case #4. If a JAXB (JSR-222) impl can produce XML without an XmlAdapter then it can consume that XML without an XmlAdapter.
Mar 17, 2013 · James Sugrue
In this post an XmlAdapter is only required to unmarshal the document from use case #4. If a JAXB (JSR-222) impl can produce XML without an XmlAdapter then it can consume that XML without an XmlAdapter.
Mar 17, 2013 · James Sugrue
In this post an XmlAdapter is only required to unmarshal the document from use case #4. If a JAXB (JSR-222) impl can produce XML without an XmlAdapter then it can consume that XML without an XmlAdapter.
Nov 22, 2012 · James Sugrue
The key point to this post is that an XSLT transform can be applied to a Java model annotated with JAXB (JSR-222) annotations. One reason HTML was used as the result as the document would be sufficiently different from the source. The other reason is that this is a common use case in the creation of JAX-RS (JSR-311) services that return HTML.
Jun 22, 2012 · Tony Thomas
Hi Goel,
Here is a link to an article I wrote that explains how to leverage XmlAdapters when starting from an XSD:
-Blaise
Jun 22, 2012 · Tony Thomas
Hi Goel,
Here is a link to an article I wrote that explains how to leverage XmlAdapters when starting from an XSD:
-Blaise
Jun 22, 2012 · Tony Thomas
Hi Goel,
Here is a link to an article I wrote that explains how to leverage XmlAdapters when starting from an XSD:
-Blaise
Jun 22, 2012 · Mr B Loid
Hi Afandi,
The "name" attribute on the "jxb:javaType" element specifies the type of the generated field/property, and is required according to the XML schema for the bindings document. We need to specify it since the print/parse methods are not required to be on the classpath to infer the types from.
-Blaise
Jun 22, 2012 · Mr B Loid
Hi Afandi,
The "name" attribute on the "jxb:javaType" element specifies the type of the generated field/property, and is required according to the XML schema for the bindings document. We need to specify it since the print/parse methods are not required to be on the classpath to infer the types from.
-Blaise
Jun 22, 2012 · James Sugrue
Hi Afandi,
The "name" attribute on the "jxb:javaType" element specifies the type of the generated field/property, and is required according to the XML schema for the bindings document. We need to specify it since the print/parse methods are not required to be on the classpath to infer the types from.
-Blaise
Jun 22, 2012 · James Sugrue
Hi Afandi,
The "name" attribute on the "jxb:javaType" element specifies the type of the generated field/property, and is required according to the XML schema for the bindings document. We need to specify it since the print/parse methods are not required to be on the classpath to infer the types from.
-Blaise
Jun 22, 2012 · James Sugrue
Hi Afandi,
The "name" attribute on the "jxb:javaType" element specifies the type of the generated field/property, and is required according to the XML schema for the bindings document. We need to specify it since the print/parse methods are not required to be on the classpath to infer the types from.
-Blaise
Jun 22, 2012 · Mr B Loid
Hi Afandi,
The "name" attribute on the "jxb:javaType" element specifies the type of the generated field/property, and is required according to the XML schema for the bindings document. We need to specify it since the print/parse methods are not required to be on the classpath to infer the types from.
-Blaise
Feb 01, 2012 · Mr B Loid
Hi Robert,
Check out the JSON-binding that we are adding to MOXy in EclipseLink 2.4.0:
The same external mapping document is used as for the XML binding which allows you to apply multiple mappings:
-Blaise
Feb 01, 2012 · James Sugrue
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · James Sugrue
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · James Sugrue
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · Mr B Loid
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · Mr B Loid
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · Mr B Loid
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · Mr B Loid
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Feb 01, 2012 · James Sugrue
Hi Edward,
Thank you for your comment, below are my answers to your questions:
XMLBeans is built around the concept of infoset preservation. This includes things like comments, processing instructions, and whitespace that just doesn't map to your doman model. Using JAXB's Marshaller/Unmarshaller this info set isn't preserved. However if you use the JAXB's Binder it can be:
Validation of an individual XmlObject is a useful aspect of using XMLBeans. JAXB implementations are able to leverage the javax.xml.validation APIs to achieve some of this behaviour:
JSON is a very useful format, that does overlap with XML. However it is not able to represent everything that XML can so it is not always a direct replacement. This is a topic worthy of its own post.
Regeneration is a valid option that is available to users of both XMLBeans and JAXB. JAXB also gives you the option of editing the domain objects by hand.
-Blaise
Jan 01, 2012 · Mr B Loid
Additionally,
Jan 01, 2012 · James Sugrue
Additionally,
Oct 25, 2011 · Mr B Loid
Hi Ali,
The XML schema may be provided by a third party and you won't have control over how the imports are specified. This is the type of scenario where XML catalogs are useful.
-BlaiseOct 25, 2011 · Mr B Loid
Hi Ali,
The XML schema may be provided by a third party and you won't have control over how the imports are specified. This is the type of scenario where XML catalogs are useful.
-BlaiseOct 25, 2011 · James Sugrue
Hi Ali,
The XML schema may be provided by a third party and you won't have control over how the imports are specified. This is the type of scenario where XML catalogs are useful.
-BlaiseOct 25, 2011 · James Sugrue
Hi Ali,
The XML schema may be provided by a third party and you won't have control over how the imports are specified. This is the type of scenario where XML catalogs are useful.
-BlaiseOct 21, 2011 · Mr B Loid
Oct 21, 2011 · Mr B Loid
Oct 21, 2011 · Mr B Loid
Jun 27, 2011 · Gerd Storm
EclipseLink MOXy (http://www.eclipse.org/eclipselink/moxy.php) is a JAXB 2.1/2.2 (JSR-222) implementation, that is currently missing from your list. MOXy offers extensions for:
XPath Based Mapping
External Mapping File
Mapping JPA Entities
Mar 25, 2011 · Stacy Doss
JAXB implementations (Metro, MOXy, JaxMe, etc) do not require a grouping element. In fact the default behavior is not to have them:
Although a grouping element may be added:
-Blaise
Dec 14, 2010 · Pavel Sumarokov
Sep 01, 2010 · James Sugrue
WRT JAXB, coming up with a better copy process is solving the wrong problem. For years now we have been adding extensions to the EclipseLink JAXB implementation (MOXy) to make the copy step unneccessary. These extensions include:
For more information see:
Sep 01, 2010 · Tony Thomas
WRT JAXB, coming up with a better copy process is solving the wrong problem. For years now we have been adding extensions to the EclipseLink JAXB implementation (MOXy) to make the copy step unneccessary. These extensions include:
For more information see:
Apr 29, 2010 · Gerd Storm
I agree, and this is where standards/specifications can really help out. Gone are the days of XML parsers with proprietary APIs. If I'm doing StAX parsing, I can use the parser that comes with my JDK or with minimal config (without recompiling) I can swap in Woodstox StAX parser.
The same thing is happening with ORM. In the past TopLink, Hibernate, and others had proprietary APIs. But now we have the JPA spec (which is implemented by TopLink, EclipseLink, Hibernate, and others), and their are standard APIs for doing the most common things. Implementations compete on their extensions points, and the best extensions are brought back into the specification.
JAXB is to OXM what JPA is to ORM. The JAXB (JSR 222) APIs were created by a committee in which members of Metro, TopLink (EclipseLink), XMLBeans, EMF, and others participated. Many think of Metro as JAXB, but there are other implementations such as EclipseLink MOXy. Switching between JAXB implementations also requires minimal config (no recompiling).
In general the specs represent the commoditized behaviour (do we really need another way to report a characters event, query by primary key, or map a property to an XML attribute?). Innovation is in the area beyond the specifications. Luckily today the majority of parser, JPA, and JAXB implementations are open source and available to be contributed to.
Apr 29, 2010 · Gerd Storm
I agree, and this is where standards/specifications can really help out. Gone are the days of XML parsers with proprietary APIs. If I'm doing StAX parsing, I can use the parser that comes with my JDK or with minimal config (without recompiling) I can swap in Woodstox StAX parser.
The same thing is happening with ORM. In the past TopLink, Hibernate, and others had proprietary APIs. But now we have the JPA spec (which is implemented by TopLink, EclipseLink, Hibernate, and others), and their are standard APIs for doing the most common things. Implementations compete on their extensions points, and the best extensions are brought back into the specification.
JAXB is to OXM what JPA is to ORM. The JAXB (JSR 222) APIs were created by a committee in which members of Metro, TopLink (EclipseLink), XMLBeans, EMF, and others participated. Many think of Metro as JAXB, but there are other implementations such as EclipseLink MOXy. Switching between JAXB implementations also requires minimal config (no recompiling).
In general the specs represent the commoditized behaviour (do we really need another way to report a characters event, query by primary key, or map a property to an XML attribute?). Innovation is in the area beyond the specifications. Luckily today the majority of parser, JPA, and JAXB implementations are open source and available to be contributed to.
Apr 29, 2010 · Gerd Storm
I agree, and this is where standards/specifications can really help out. Gone are the days of XML parsers with proprietary APIs. If I'm doing StAX parsing, I can use the parser that comes with my JDK or with minimal config (without recompiling) I can swap in Woodstox StAX parser.
The same thing is happening with ORM. In the past TopLink, Hibernate, and others had proprietary APIs. But now we have the JPA spec (which is implemented by TopLink, EclipseLink, Hibernate, and others), and their are standard APIs for doing the most common things. Implementations compete on their extensions points, and the best extensions are brought back into the specification.
JAXB is to OXM what JPA is to ORM. The JAXB (JSR 222) APIs were created by a committee in which members of Metro, TopLink (EclipseLink), XMLBeans, EMF, and others participated. Many think of Metro as JAXB, but there are other implementations such as EclipseLink MOXy. Switching between JAXB implementations also requires minimal config (no recompiling).
In general the specs represent the commoditized behaviour (do we really need another way to report a characters event, query by primary key, or map a property to an XML attribute?). Innovation is in the area beyond the specifications. Luckily today the majority of parser, JPA, and JAXB implementations are open source and available to be contributed to.
Apr 29, 2010 · Gerd Storm
EclipseLink JAXB (aka MOXy) was designed to solve just that problem. Its XPath based mappings allows you to map your own domain model to any XML schema (or multiple XML schemas).
It is also the only binding solution I'm aware of with specific support for mapping JPA entities. This includes bi-directional relationships, compound keys, and embedded key classes.
Plus, if you are already using EclipseLink/TopLink for your JPA layer, you will already be familiar with some of the extension points.