Reads an Xml formatted document into an existing data model in the EDMdatabase .
The imported data will be added to any existing data in the model. In case incremental import is not required, the model must be manually emptied, e.g with edmiDeleteModelContents, before invoking this function.
Related functions: edmiReadXMLFile
Header:
#include "sdai.h"
Prototype:
EdmiError edmiReadXMLDocument (SdaiXml pXml,
SdaiModel modelId,
SdaiString encodingEdm,
SdaiUnsignedInt options);
Arguments:
pXml |
Xml document exchange struct. See sdai.h for detailed description of all data structure elements. |
modelId |
modelId of the data model in the EDMdatabase to populate. This function can not create a model implicitly. I.e, the model must exist. |
encodingEdm |
The encoding of data in EDM. Valid encodings are; |
options |
A bitwise OR between the options listed and described below. All available options are defined in the header file sdai.h . |
Options: Descriptions:
SHOW_STATISTICS |
Show statistics when reading/writing XML |
XML_PARSE_TRACE |
Show trace when reading/writing XML |
CREATE_SCRATCH_INSTANCES |
The imported population in the xml document will not be persistant. |
CONTINUE_STORING_ON_ERROR |
Ignore errors when populating the data model from the Xml document. E.g, entities that do not exist in the Express schema will simply be ignored. By default, the import will be abrupted in case of erroneous data. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an EDMinterface error code. Use edmiGetErrorText to get the error text corresponding to the error code.
EXAMPLE
EdmiError rstat;
SdaiModel modId;
SdaiXml xml;
SdaiUnsignedInt options = SHOW_STATISTICS | XML_PARSE_TRACE;
SdaiString encoding = "UTF-8";
. . .
modId = edmiGetModel("myRepository", "myModel");
if (rstat = edmiReadXMLDocument (xml, modId, encoding, options)) {
printf("\nError %d in edmiReadXMLDocument: %s", rstat,
edmiGetErrorText(rstat));
goto error;
}