Document Storage/Retrieval Drivers manage the conversion between a transient OCAF Document in memory and its persistent reflection in some container (disk, memory, network ...). For XML Persistence, they are defined in the package XmlDrivers.
The main methods (entry points) of these drivers are:
Write() - for storage driver
Read() - for retrieval driver
The most common case (which is implemented in XML Persistence) is writing/reading document to/from a regular OS file. Such conversion is performed in two steps:
Convert the transient document into another form
(called persistent), suitable for writing into a file, and vice versa.
In XML Persistence LDOM_Document is used as the persistent form
of an OCAF Document and the DOM_Nodes are the persistent objects.
An OCAF Document is a tree of labels with attributes. Its transformation into a persistent form can be functionally divided into two parts:
Conversion of the labels structure, which is performed by the method XmlMDF::FromTo()
Conversion of the attributes and their underlying objects, which is performed by the corresponding attribute drivers (one driver per attribute type).
The driver for each attribute is selected from a table of drivers, either by attribute type (on storage) or by the name of the corresponding DOM_Element (on retrieval). The table of drivers is created by bymethods XmlDrivers_DocumentStorageDriver::AttributeDrivers() and XmlDrivers_DocumentRetrievalDriver::AttributeDrivers().
Write the persistent document into afile (or read
it from file).
In standard persistence Storage and FSD packages contain classes for
writing/reading the persistent document into a file.
In XML persistence LDOMParser and LDOM_XmlWriter are used instead.
Usually, the library containing document storage and retrieval drivers is loaded at run time by a plugin mechanism. To support this in XML Persistence, there is a plugin XmlPlugin and a Factory()method in the XmlDrivers package. This method compares passed GUIDs with known GUIDs and returns the corresponding driver or generates an exception if the GUID is unknown.
The application defines which GUID is needed for document storage or retrieval and in which library it should be found. This depends on document format and application resources. Resources for XML Persistence and also for standard persistence are found in the StdResource unit. They are written for the XmlOcaf document format.