Populates an EDMmodel with Xml-formatted data from a file.
This function is more or less equivalent to edmiReadStepFile. It may populate an existing model or implicitly create a new one.
Related functions:
edmiReadXMLDocument, edmiWriteXMLDocument, edmiWriteXMLFile, edmiWriteXMLFileEx.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiReadXMLFile(SdaiString xmlFileName,
SdaiString diagnosticFileName,
SdaiString repositoryName,
SdaiString modelName,
SdaiString headerRepositoryName,
SdaiString headerModelName,
SdaiString schemaName,
SdaiUnsignedInt options,
SdaiInteger *nbWarnings,
SdaiInteger *nbErrors,
SdaiErrorCode *sdaiError);
Arguments:
xmlFileName |
The name of the file containing XML-formatted data to read. |
diagnosticFileName |
The name of the file that will contain diagnostic information generated by this function. If this parameter is NULL or an empty string, all diagnostic information will be written to the EDMinterface current output device. |
repositoryName |
If populating an existing model, this parameter is the name of the repository in which the model exists. If a new model shall be created, this parameter is the name of the repository in which to create it. |
modelName |
The name of an existing model or a model to create. This model will be populated with data from the XML-file. |
headerRepositoryName |
Use this parameter to specify a separate repository for the Xml header model. If this parameter is NULL or an empty string, <headerRepositoryName> will be set equal to <repositoryName> |
headerModelName |
The name of the XML Header Model in the EDMdatabase. This model will be populated with data from the Header Section of the XML file. XML Header Model names are case sensitive. The specified XML Header Model will be placed in the repository specified by the <headerRepositoryName> parameter. |
schemaName |
The name of the schema containing dictionary data for the edmModel to create or update. |
options |
A bitwise OR between the options described below. All available options are defined in the header file sdai.h |
*nbWarnings |
Address of a variable that will receive the number of warnings detected during reading the specified XML file. |
*nbErrors |
Address of a variable that will receive the number of errors detected reading the specified XML file. |
*sdaiError |
Address of a variable that will receive any EDMinterface error code returned from the EDMserver. Use edmiGetErrorText to convert the error code into a readable error message |
Options: Descriptions:
SHOW_STATISTICS |
Show statistics when reading the XML file. |
XML_PARSE_TRACE |
Show trace when reading the XML file. |
DELETE_INSTANCES_WITH_REFS |
When using the option [DELETING_EXISTING_MODEL], instances that are being referred to by other instances will not be deleted unless one of the options [DELETE_INSTANCES_WITH_REFS] and [DELETE_INSTANCE_REFS_ON_DELETE] is used. |
DELETE_INSTANCE_REFS_ON_DELETE |
When using the option [DELETING_EXISTING_MODEL], instances that are being referred to by other instances will not be deleted unless one of the options [DELETE_INSTANCES_WITH_REFS] and [DELETE_INSTANCE_REFS_ON_DELETE] is used. |
NO_INSTANCE_REFERENCES |
When an edmModel is populated, edm will normally create and maintain tables of all external references to all the instances of the new population. To improve performance, the option [NO_INSTANCE_REFERENCES] may be used to suppress generation of these tables. The inconvenience of this is that some functions will not work on a model that has been populated with this option. These functions are; |
USER_CONTROLLED_INVERSE |
No automatic update and maintenance of INVERSE attributes in the actual model. |
DELETING_EXISTING_MODEL |
This option ensures that the model is emptied before it is again repopulated with the data in the Xml File. |
ADD_TO_EXISTING_MODEL |
Use this option if you want to add a population to an already existing population in the given model. This enables incremental populating of a data model from XML files. |
PARSE_ONLY |
The specified XML file will be parsed only, i.e. only checked for syntax. No data will be stored in the EDMdatabase. |
CREATE_SCRATCH_INSTANCES |
The imported population will not be persistant in the EDMdatabase. All created instances will be scratch instances in the scratch model of the given <schemaName>. |
CONTINUE_STORING_ON_ERROR |
If the population within the XML file contains errors such as for instance entity names that does not exist in the dictionary model, the entire population would normally be rejected. |
PERSISTENT_INSTANCES_HASH_TABLE |
creates a EDMpersistentInstancesHashTable |
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;
SdaiInteger nErrors;
SdaiInteger nWarnings;
. . .
modId = edmiGetModel("myRepository", "myModel");
if (rstat = edmiReadXMLFile ("c:/home/johnny/myXmlFile.xml",
"c:/home/johnny/tmp/myXmlFile.diag",
"myXmlRepository", "myXmlModel",
"", "myXmlHeaderModel", "myXmlSchema",
ADD_TO_EXISTING_MODEL | XML_PARSE_TRACE,
&nWarnings, &nErrors, &rstat)) {
printf("\nError %d in edmiReadXMLFile: %s", rstat,
edmiGetErrorText(rstat));
goto error;
}