Jump to content

Jakarta XML Binding

From Alfawiki
Jakarta XML Binding (JAXB)
Company typeSoftware framework
IndustrySoftware development
Founded2003; 23 years ago (2003)
FounderJava Community Process (JCP)
ProductsJava XML binding framework
Websiteeclipse-ee4j.github.io/jaxb-ri/

Jakarta XML Binding (JAXB; previously known as Java Architecture for XML Binding) is a software framework designed to assist Java EE developers in linking Java classes with XML data formats. The primary capabilities of JAXB include marshalling Java objects into XML and unmarshalling XML back into Java objects, enabling seamless data exchange and storage in XML without the need for manual XML processing code. It serves a similar purpose to xsd.exe and XmlSerializer found in the .NET Framework.

JAXB proves especially useful when working with intricate or frequently changing specifications, as it simplifies the synchronization between XML Schema definitions and corresponding Java representations.

As an integral part of the Jakarta EE ecosystem (formerly Java EE), JAXB supports the Java Web Services Development Pack (JWSDP) and forms a foundation for WSIT. It was bundled with Java SE editions 6 through 10 but has been excluded starting with Java SE 11.

The initial release, JAXB 1.0, debuted in 2003 through the Java Community Process under JSR 31. JAXB 2.0 followed in 2006 via JSR 222, with a Maintenance Release 2 issued in 2009. Reference implementations have been distributed under the CDDL open source license on java.net.

Usage

The "" utility facilitates the transformation of XML Schema and other schema formats—including experimental compatibility with RELAX NG, XML DTD, and WSDL since Java 1.6—into Java class structures. These classes incorporate annotations from the namespace, such as and , while sequences in XML correspond to attributes. Instances of JAXBContext are employed to instantiate marshallers and unmarshallers.

Additionally, JAXB offers "", which enables generating XML Schemas from annotated Java classes, thereby supporting two-way mapping between schema definitions and class models.

Default data type bindings

The following table outlines how XML Schema (XSD) data types correspond to Java data types within JAXB.

XML Schema Type Java Data Type
xsd:string java.lang.String
xsd:integer java.math.BigInteger
xsd:positiveInteger java.math.BigInteger
xsd:int int
xsd:long long
xsd:short short
xsd:decimal java.math.BigDecimal
xsd:float float
xsd:double double
xsd:boolean boolean
xsd:byte byte
xsd:QName javax.xml.namespace.QName
xsd:dateTime javax.xml.datatype.XMLGregorianCalendar
xsd:base64Binary byte[]
xsd:hexBinary byte[]
xsd:unsignedInt long
xsd:unsignedShort int
xsd:unsignedByte short
xsd:unsignedLong java.math.BigDecimal
xsd:time</ code > < code > javax.xml.datatype.XMLGregorianCalendar </ code > - < code > xsd:date </ code > < code > javax.xml.datatype.XMLGregorianCalendar </ code > - < code > xsd:g </ code > < code > javax.xml.datatype.XMLGregorianCalendar </ code > - < code > xsd:anySimpleType </ code >[1] < code > java.lang.Object </ code > - < code > xsd:anySimpleType </ code >[2] < code > java.lang.String </ code > - < code > xsd:duration </ code > < code > javax.xml.datatype.Duration </ code > - < code > xsd:NOTATION </ code > < code > javax.xml.namespace.QName </ code > -

Versions

  • Java SE 9: JAXB version 2.3.0 (available as module java.xml.bind; marked as deprecated)
  • Java SE 8: JAXB version 2.2.8
  • Java SE 7: JAXB version 2.2.3 (JSR 222, second maintenance update)
  • Java SE 6: JAXB version 2.0 (JSR 222)

See also

External links

Articles

  1. ↑ for < code > xsd:element </ code >
  2. ↑ for < code > xsd:attribute </ code >