Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


 
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.
EdmiDefineOutputFunction may be used to redefine 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.
The model must have a name that is unique within the repository that holds the model. The model name must start with a letter and the rest of the model name can be any mix of alphanumeric characters and underscore. Model names are case sensitive.
 

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.
All instances in the specified <headerModelName> will be mapped to the XML file Header Section as is, except that the attribute FILE_DESCRIPTION.IMPLEMENTATION_LEVEL is set according to the mapping method specified by one of the following options: [CONFORMANCE_CLASS_1], [CONFORMANCE_CLASS_2] or [EDM_PRIVATE_FORMAT]. The attribute FILE_NAME.TIME_STAMP is set to the current date and time, i.e., the date and time when the XML file is produced.
When the [NO_HEADER_CHANGE] option is set, the specified header model will be mapped as is, i.e., also the three attribute values described above will be mapped from the specified header model to the XML file.
When the <headerModelName> argument is blank, a default Header Section is produced. This default header section can be configured by setting the EDM system variable EDM_XML_FILE_AUTHOR.

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.
Note that deleting an instance that are being referred to from outside, without removing all references, will result in an inconsistent data model. Hence, this option should only be used on "temporary models", i.e., models that are not ment to remain persistent in the EDMdatabase.
This option may greately improve performance when manipulating the data within a model

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.
This option removes all external references before deleting an instance, therby preserving consistency in the EDMdatabase
This option may greately improve performance when manipulating the data within a model

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;
The built in function USEDIN,The EDMinterface operations: edmiUsedIn, edmiUsedInBN, and edmiGetInstanceReferences
The ExpressX function xpxGetInstanceReferences
This option should only be used on "temporary models", i.e., models that are not ment to remain persistent in the EDMdatabase.

USER_CONTROLLED_INVERSE

No automatic update and maintenance of INVERSE attributes in the actual model.
This option can improve the performance of data manipulation in this model. This option should only be used on "temporary models", i.e., models that are not ment to remain persistent in the EDMdatabase.

DELETING_EXISTING_MODEL

This option ensures that the model is emptied before it is again repopulated with the data in the Xml File.
If the specified model exists, an error code will be returned unless one of the options [DELETING_EXISTING_MODEL] and [ADD_TO_EXISTING_MODEL] is used.

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.
By using this option, EDM will be forced to continue for as long as it is possible to recover from such problems. This may result in inconsistent populations and should therefore be used with care.

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; 
}

  • No labels