company logo

ODABA XML format

XML data format is another way of providing complex data in an external file. XML files may contain any number of instances in any number of collection. When the scope of the XML file is the database or a selected object instance, the XML file has to provide a number of properties. When the scope for the XML file is a collection, the XML file has to provide a number of instances. Syntactically, instances and collection specifications do not differ. The difference is, however, that for an instance collection each top level tag starts with a data type tag, while the top level tags for a property collection start with a property name.

Since XML files require tags, only values to be imported or exported need to be defined, i.e. XML files need not to be complete. When importing an XML file, properties not defined in the file will not be updated. Properties passed without value cause deleting the property in the database (collection) or creating an empty value.

Furthermore, XML files can be accessed in exportData() and importData() functions (Property and ObjectSpace) or when opening external files by Property::openExtern().

Limited access to XML files is supported by defining XML extents in the dictionary (access type AT_EXTERN). In this case, the file path is expected in an option having the same name as the extent. No header and no external file description are supported for XML extents.

In order to provide more flexible access to XML files, a file description (schema definition) has to be passed explicitly to the Property::openExtern() function. In order to provide an external schema definition, any of the supported definition formats might be used (see Data Exchange schema).

XML file structure

XML files require a specific structure illustrated in the example below. Depending on the XML file context, the top level tags after the heading section refer either to a property or complex data type name.

When providing collection data, those must be enclosed by property (extent) name tags. Each instance in the collection has to be enclosed in complex data type name tags for the data type for the instances, which may differ for weak-typed collections. Complex attributes require a property tag and a data type tag.

When defining XML files in instance or database context, the top level tags have to refer to property (instance context) or extent (database or object space context) names.

Schema definition

XML files may contain a header defining the XML schema for the subsequent data section. The XML schema for the ODABA schema definition is defined in XML schema.

In order to provide an exchange schema, the data exchange specification has to be provided in the dictionary (resource database).