Jakarta Xml Binding

Jakarta XML Binding (JAXB; formerly Java Architecture for XML Binding) is a software framework that allows Java EE developers to map Java classes to XML representations.

JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, i.e. to unmarshal XML back into Java objects. In other words, JAXB allows storing and retrieving data in memory in any XML format, without the need to implement a specific set of XML loading and saving routines for the program's class structure. It is similar to xsd.exe and XmlSerializer in the .NET Framework.

Jakarta XML Binding
Repository
Written inJava
Websiteprojects.eclipse.org/projects/ee4j.jaxb-impl Edit this at Wikidata

JAXB is particularly useful when the specification is complex and changing. In such a case, regularly changing the XML Schema definitions to keep them synchronised with the Java definitions can be time-consuming and error-prone.

JAXB is one of the APIs in the Java EE platform (formerly Java EE), part of the Java Web Services Development Pack (JWSDP), and one of the foundations for WSIT. It was also part of the Java SE platform (in version Java SE 6–10). As of Java SE 11, JAXB was removed. For details, see JEP 320.

JAXB 1.0 was released in 2003, having been developed under the Java Community Process as JSR 31. In 2006 JAXB 2.0 was released under JSR 222 and Maintenance Release 2 released in December 2009. Reference implementations for these specifications were available under the CDDL open source license at java.net.

Usage

The tool "xjc" can be used to convert XML Schema and other schema file types (as of Java 1.6, RELAX NG, XML DTD, and WSDL are supported experimentally) to class representations. Classes are marked up using annotations from javax.xml.bind.annotation.* namespace, for example, @XmlRootElement and @XmlElement. XML list sequences are represented by attributes of type java.util.List. Marshallers and Unmarshallers are created through an instance of JAXBContext.

In addition, JAXB includes a "schemagen" tool that can essentially perform the inverse of "xjc", creating an XML Schema from a set of annotated classes.

Default data type bindings

The table below lists the mappings of XML Schema (XSD) data types to Java data types in 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 javax.xml.datatype.XMLGregorianCalendar
xsd:date javax.xml.datatype.XMLGregorianCalendar
xsd:g javax.xml.datatype.XMLGregorianCalendar
xsd:anySimpleType java.lang.Object
xsd:anySimpleType java.lang.String
xsd:duration javax.xml.datatype.Duration
xsd:NOTATION javax.xml.namespace.QName

Versions

  • Java SE 9: JAXB 2.3.0 (in module java.xml.bind; this module is marked as deprecated )
  • Java SE 8: JAXB 2.2.8
  • Java SE 7: JAXB 2.2.3 (JSR 222, maintenance release 2)
  • Java SE 6: JAXB 2.0 (JSR 222)

See also

References

Articles

Tags:

Jakarta Xml Binding UsageJakarta Xml Binding Default data type bindingsJakarta Xml Binding VersionsJakarta Xml Binding.NET FrameworkClass (computer science)Jakarta EEMarshalling (computer science)Object (computer science)Software frameworkXML

🔥 Trending searches on Wiki English:

Olympiacos F.C.Tony Stark (Marvel Cinematic Universe)Shruti Sharma (actress)Millie Bobby BrownLee MajorsSharmin SegalAranmanai 4List of countries by GDP (nominal) per capitaReal Madrid CFTaaha ShahYoung SheldonChessJujutsu KaisenCherHacks (TV series)Lionel MessiMikey DayJohnny DeppEFL ChampionshipRonald ReaganKarim AdeyemiInter Miami CFMichael JordanMurder of Junko FurutaRoad House (2024 film)Leonardo da VinciJeremie FrimpongShardlake seriesSwitzerlandWiki FoundationBillie EilishNeymarBelle GibsonNava MauThe Family StarJohn LennonUnited KingdomJake GyllenhaalHong KongLiam NeesonIndiaColumbia UniversitySavagelandBastion (comics)John SwinneyNitish Kumar ReddyXVideosIsrael–Hamas warCicadaWorld War I2024–25 UEFA Champions LeagueCONCACAF Champions CupCecil ParkinsonUkraineList of countries by GDP (PPP) per capitaRebecca (1940 film)Sydney SweeneyMarilyn MonroeNoni MaduekeFallout 3Russian invasion of UkraineFallout (video game)Satyajit RayGMick JaggerJ. Robert OppenheimerRicha ChadhaUlterior Motives (song)Olivia RodrigoSurvivor 46Maya RudolphBrad PittPrincess Charlotte of Wales (born 2015)John MulaneyPost MaloneList of Young Sheldon episodesRyan Garcia🡆 More