Reads an XML document into an existing edmModel in a remote 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 edmiRemoteDeleteModelContents, before invoking this function.
Related functions: edmiRemoteCreateXMLConfiguration , edmiRemoteDeleteXMLConfiguration , edmiRemoteGetXMLConfiguration, edmiRemoteGetXMLConfigurationId, edmiRemoteListXMLConfigurations, edmiRemoteReadXMLFile, edmiRemoteWriteXMLDocument, edmiRemoteWriteXMLFile.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteReadXMLDocument(SdaiServerContext serverContextId,
SdaiString remoteRepositoryName,
SdaiString remoteModelName,
SdaiString xmlFileName,
SdaiString xmlString,
SdaiString xmlDiagNosticFile,
SdaiString *xmlDiagnosticString,
SdaiString encodingEdm,
SdaiOptions options,
SdaiString *encodingXmlDocument,
SdaiInteger *nbWarnings,
SdaiInteger *nbErrors,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
remoteRepositoryName |
The name of the edmRepository in which to populate an existing edmModel with the XML data stored in the file specified by the <xmlFileName> argument. The XML data will be appended to any existing population of the edmModel. The edmRepository and the edmModel must exist in the remote _EDMdatabase_ |
remoteModelName |
The name of the edmModel to populate. The <remoteRepositoryName> and <remoteModelName> arguments uniquely identify an existing edmModel in the remote EDMdatabase. |
xmlFileName |
The name of the file, on the local file system, containing the XML data to read. If <xmlFileName> is NULL, data will be read from the string given in the argument <xmlString>. |
xmlString |
The string containing the XML data to be read. If the <xmlFileName> argument is not NULL and contains anything but an empty string, this argument will be neglected. |
xmlDiagNosticFile |
The name of the file, on the local file system, that will receive the diagnostics from the parsing of the XML data. If <xmlDiagnosticFile> is NULL, the parsing diagnostics will be written to the string given in the argument <xmlDiagnosticString>. |
xmlDiagnosticString |
Variable that will receive the address of an allocated string containing the diagnostics from the parsing of the XML data. If the <xmlDiagnosticFile> argument is not NULL and contains anything but an empty string, this argument will be neglected. |
encodingEdm |
The encoding that will be used by EDM. Valid encodings are;
|
options |
See the description of all available options below. |
encodingXmlDocument |
Variable that will receive the encoding of the data in the XML document |
nbWarnings |
Variable that will receive the number of warnings that resulted from the execution of the function. |
nbErrors |
Variable that will receive the number of errors that resulted from the execution of the function. |
edmiInvocationId |
Currently unused |
Options: Descriptions:
SHOW_STATISTICS |
Show statistics when parsing the XML data. |
XML_PARSE_TRACE |
Trace the parsing of the XML data. |
PARSE_ONLY |
The XML document will be parsed only, i.e. only checked for syntactical correctness. No data will be stored in the EDMdatabase. |
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;
SdaiServerContext localContext, remoteContext;
SdaiModel myModelId;
SdaiSchema schemaId;
SdaiInstance instId, xmlConfigId;
SdaiInteger nInst, nErr, nWrn;
SdaiString xmlString, xmlEncoding;
. . .
/* Create an instance in the local database */
instId = edmiCreateInstanceAndPutAttrsBN(myModelId, "PERSON", 3,
"FIRST_NAME", sdaiSTRING, "LUCY",
"LAST_NAME", sdaiSTRING, "SCHMIDT",
"SEX", sdaiENUMERATION, "FEMALE");
/* Get predefined xml config id */
rstat = edmiGetSchema("SOCIAL_NETWORK", &schemaId);
rstat = edmiGetXMLConfigurationId(schemaId, "friends",
&xmlConfigId);
/* Define Local Db Context */
rstat = edmiDefineServerContext("MyLocalDbContext",
"Johnny", "Supervisor", "cf37ftr", "LOCAL_DB",
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&localContext);
/* Write xml to string */
rstat = edmiRemoteWriteXMLDocument(localContext, NULL, NULL, NULL, NULL,
&instId, 0, 1, &nInst,
NULL, xmlConfigId, NULL, &xmlString,
"c:/tmp/xml.dignostics", NULL,
"UTF-8", "UTF-8", INCLUDE_CONFIGURATION,
&nWrn, &nErr, NULL);
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyRemoteServerContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &remoteContext);
/* Read xml into remote database */
rstat = edmiRemoteReadXMLDocument(remoteContext,
"DataRepository", "MyFriends",
NULL, xmlString, NULL, NULL,
"UTF-8", 0, &xmlEncoding,
&nWrn, &nErr, NULL);
. . .