XML data binding

from Wikipedia, the free encyclopedia

XML data binding (English XML data binding ) is in the object-orientation of the mapping of the process XML -documents on objects and the representation of XML documents by objects and vice versa. This process enables programmers to access XML data via objects without using XML-typical mechanisms such as XPath , DOM or SAX .

The mapping of an object in XML data during the runtime of an application is called marshaling or serialization . The opposite way of mapping XML data into objects is called unmarshalling or deserialization .

functionality

XML data binding has to map objects to XML data and vice versa to map attributes of the objects to XML elements. This can be done in different ways, depending on the task or support from the XML binding framework used:

based on XML schema
Based on a given XML schema, classes are generated that correspond to the XML schema. The XML documents that match the XML schema are then represented by instances of these classes at runtime.
based on classes
A suitable XML schema is generated based on the given classes to be serialized. At runtime, the instances of these classes are saved in XML documents that match the XML schema.
based on mapping
A mapping usually defined in XML describes the mapping of XML elements to attributes. Based on this mapping, objects are then serialized into XML documents or XML documents are deserialized into objects at runtime.

All three methods can be implemented in different ways. With some frameworks, for example, it is possible to generate the required classes only at runtime or, through bytecode manipulation, even get by without their own classes.

Problems

XML schemas and classes cannot always be completely mapped to one another. For example, it is often difficult to map the two possible comments onto one another. In addition, it is often problematic to map the order of the XML elements in classes, while self-references of objects in XML are difficult to map. It can therefore be the case that XML data binding does not take into account all of the information of the elements to be bound. Modern XML data binding frameworks, however, are able to preserve the complete information.

alternative

The alternative to XML data binding is the manual serialization and deserialization of objects in XML documents using known XML techniques such as XPath , DOM or SAX . The most important disadvantage of this alternative is the additional effort for the necessary implementation and the associated follow-up costs. However, this only applies to object-oriented runtime environments. If an, ideally pure, XML runtime environment is used instead, as is possible using XQuery, XSLT and XProc, development time and follow-up costs are often shortened, since here, right from the start, the need for object-oriented XML data binding does not arise in the first place , but the XML data can be passed through from the source to the destination without being converted into another data format. However, this is only recommended when using document-oriented databases that already display the data as XML or for static files in XML format.

XML data binding frameworks

C ++ and C

  • gSOAP - Open Source XML Data Binding Compiler for C ++ and C; supports SOAP, WSDL and XSD.
  • CodeSynthesis XSD - Open Source XML Data Binding Compiler for C ++, SAX or tree-like mapping to C ++ classes.
  • xmlbeansxx - C ++ library for XML data binding. Similar to XMLBeans .

Java

  • Java Architecture for XML Binding (JAXB), Java programming interface for XML data binding, part of JSE and JEE.
  • Castor - open source XML data binding framework
  • Apache XMLBeans - open source XML data binding framework, access to XML documents via classes generated from XML schema
  • JiBX - Fast open source XML data binding framework, mapping of classes to XML schemas via bytecode manipulation
  • XStream - open source XML data binding framework, also serialized to JSON
  • Apache Commons Betwixt - Simple open source XML data binding framework, serializes objects in XML without prior XML schema definition

.Net

  • System.Xml.Serialization - Part of the .NET framework, also contains XML data binding classes

Web links

Further information