TiXI  3.3.0
File Handling Functions

Functions

DLL_EXPORT ReturnCode tixiOpenDocument (const char *xmlFilename, TixiDocumentHandle *handle)
 Open an XML-file for reading. More...
 
DLL_EXPORT ReturnCode tixiOpenDocumentRecursive (const char *xmlFilename, TixiDocumentHandle *handle, OpenMode oMode)
 Open an XML-file for reading. It acts like tixiOpenDocument. More...
 
DLL_EXPORT ReturnCode tixiOpenDocumentFromHTTP (const char *httpURL, TixiDocumentHandle *handle)
 Open an XML-file for reading from a http web resource. More...
 
DLL_EXPORT ReturnCode tixiCreateDocument (const char *rootElementName, TixiDocumentHandle *handle)
 Create an XML-document. More...
 
DLL_EXPORT ReturnCode tixiGetDocumentPath (TixiDocumentHandle handle, char **documentPath)
 Returns the file path to the document. More...
 
DLL_EXPORT ReturnCode tixiSaveDocument (TixiDocumentHandle handle, const char *xmlFilename)
 Write XML-document to disk. More...
 
DLL_EXPORT ReturnCode tixiSaveCompleteDocument (TixiDocumentHandle handle, const char *xmlFilename)
 Write XML-document with all external data to disk. More...
 
DLL_EXPORT ReturnCode tixiSaveAndRemoveDocument (TixiDocumentHandle handle, const char *xmlFilename)
 Write XML-document with all external data to disk. More...
 
DLL_EXPORT ReturnCode tixiCloseDocument (TixiDocumentHandle handle)
 Close an XML-document. More...
 
DLL_EXPORT ReturnCode tixiCloseAllDocuments ()
 Close all open documents. More...
 
DLL_EXPORT ReturnCode tixiCleanup ()
 Closes the xml2 library and frees its allocated variables. More...
 
DLL_EXPORT ReturnCode tixiExportDocumentAsString (const TixiDocumentHandle handle, char **text)
 Returns the Document as one text. More...
 
DLL_EXPORT ReturnCode tixiImportFromString (const char *xmlImportString, TixiDocumentHandle *handle)
 Imports a char-string into a new tixi-document. More...
 

Detailed Description

Function to open, create, close, and save XML-files.

Function Documentation

DLL_EXPORT ReturnCode tixiCleanup ( )

Closes the xml2 library and frees its allocated variables.

DLL_EXPORT ReturnCode tixiCloseAllDocuments ( )

Close all open documents.

Closes all XML-documents. This routine could be called at the of a program to free allocated memory. After calling this routine all current handles are invalid and no further processing of the document is possible.

Fortran syntax:

tixi_close_all_documents( integer error )

Returns
  • SUCCESS if successfully closed the XML-file
  • CLOSE_FAILED if closing the XML-files failed
DLL_EXPORT ReturnCode tixiCloseDocument ( TixiDocumentHandle  handle)

Close an XML-document.

Closes an XML-document. This routine should be called after the processing of an XML-document is completed. After calling this routine the handle is invalid and no further processing of the document is possible. It must be called after tixiSaveDocument.

Fortran syntax:

tixi_close_document( integer handle, integer error )

Parameters
[in]handlefile handle as returned by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP, tixiCreateDocument or tixiImportFromString
Returns
  • SUCCESS if successfully closed the XML-file
  • INVALID_HANDLE if handle not found in list of man
  • CLOSE_FAILED if closing the XML-file failed
DLL_EXPORT ReturnCode tixiCreateDocument ( const char *  rootElementName,
TixiDocumentHandle handle 
)

Create an XML-document.

Initializes a data structure to hold an XML-document.

Fortran syntax:

tixi_create_document( character*n root_element_name, integer handle, integer error )

Parameters
[in]rootElementNamename of the root element of the XML-document
[out]handlehandle to an XML-document. This handle is used in calls to other TIXI functions.
Returns
  • SUCCESS if data structure is set-up successfully
  • FAILED if data structure could not created
DLL_EXPORT ReturnCode tixiExportDocumentAsString ( const TixiDocumentHandle  handle,
char **  text 
)

Returns the Document as one text.

Returns the text content of the document specified by handle. If an error occurs text is set to NULL. On successful return the memory used for text is allocated internally and must not be released by the user. The deallocation is handle when the document referred to by handle is closed. If OpenMode=OPENMODE_RECURSIVE, text will be one big string with all external xml files included.

Fortran syntax:

tixi_export_document_as_string( integer handle, character*n text, integer error )

Parameters
[in]handlehandle as returned by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP, tixiCreateDocument or tixiImportFromString
[out]texttext content of the document
Returns
  • SUCCESS if successfully retrieve the text content of a single element
  • INVALID_HANDLE if the handle is not valid, i.e. does not or no longer exist
DLL_EXPORT ReturnCode tixiGetDocumentPath ( TixiDocumentHandle  handle,
char **  documentPath 
)

Returns the file path to the document.

The path is empty, if the document was not opened, but created by tixiCreateDocument.

Parameters
[in]handledocument handle as returned by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP, tixiCreateDocument or tixiImportFromString
[out]documentPathPath to the file, opened by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP The path is a null pointer, if the document was created by tixiCreateDocument or tixiImportFromString
Returns
  • SUCCESS in case of no errors.
  • FAILED if documentPath is a null pointer.
  • INVALID_HANDLE if the document handle is invalid.
DLL_EXPORT ReturnCode tixiImportFromString ( const char *  xmlImportString,
TixiDocumentHandle handle 
)

Imports a char-string into a new tixi-document.

Creates a new TIXI-document with the content of the string and checks if it is well formed. To validate the document against a XML-Schema or DTD use tixiSchemaValidateFromFile, tixiSchemaValidateFromString or tixiDTDValidate.

Fortran syntax:

tixi_import_from_string( character*n xmlImportString, integer handle, integer error )

Parameters
[in]xmlImportStringthe string with the xml-content
[out]handlehandle to the XML-document. This handle is used in calls to other TIXI functions.
Returns
  • SUCCESS if successfully imported the string
  • NOT_WELL_FORMED if importing of the string succeeds but test for well-formedness fails
DLL_EXPORT ReturnCode tixiOpenDocument ( const char *  xmlFilename,
TixiDocumentHandle handle 
)

Open an XML-file for reading.

Opens an XML-file specified by xmlFilename for reading and checks if it is well formed. To validate the document against a XML-Schema or DTD use tixiSchemaValidateFromFile, tixiSchemaValidateFromString or tixiDTDValidate.

Fortran syntax:

tixi_open_document( character*n xml_filename, integer handle, integer error )

Parameters
[in]xmlFilenamename of the XML-file to be opened
[out]handlehandle to the XML-document. This handle is used in calls to other TIXI functions.
Returns
  • SUCCESS if successfully opened the XML-file
  • NOT_WELL_FORMED if opening the XML-file succeeds but test for well-formedness fails
  • OPEN_FAILED if opening of the XML-file failed
DLL_EXPORT ReturnCode tixiOpenDocumentFromHTTP ( const char *  httpURL,
TixiDocumentHandle handle 
)

Open an XML-file for reading from a http web resource.

Opens an XML-file specified by httpURL for reading and checks if it is well formed. To validate the document against a XML-Schema or DTD use tixiSchemaValidateFromFile, tixiSchemaValidateFromString or tixiDTDValidate.

Fortran syntax:

tixi_open_document_from_http( character*n xml_httpurl, integer handle, integer error )

Parameters
[in]httpURLurl of the XML-file to be opened
[out]handlehandle to the XML-document. This handle is used in calls to other TIXI functions.
Returns
  • SUCCESS if successfully opened the XML-file
  • NOT_WELL_FORMED if opening the XML-file succeeds but test for well-formedness fails
  • OPEN_FAILED if opening of the XML-file failed
DLL_EXPORT ReturnCode tixiOpenDocumentRecursive ( const char *  xmlFilename,
TixiDocumentHandle handle,
OpenMode  oMode 
)

Open an XML-file for reading. It acts like tixiOpenDocument.

If OpenMode is OPENMODE_PLAIN, only the given xml is opened. If OpenMode is OPENMODE_RECURSIVE, external xml files will be integrated into the xml tree by linking them into the main xml file. The user now has only one big xml file. In the path node has be be a valid URI. This uri could adress a relativ or absolut file path, or a http url. Example values for the path node are:

  • absolute local directory: "file:///tmp/" or "file:///c:/windws/"
  • relative local directory: "file://relativeDirectory/" or "file://../anotherRelativeDirectory/"
  • remote http ressource: "http://www.someurl.de/"

Examples for the externaldata node:

1 <wings>
2  <airfoils>
3  <externaldata>
4  <path>file://aDirectory/</path>
5  <filename>VFW614-W-1.xml</filename>
6  <filename>VFW614-W-2.xml</filename>
7  ...
8  </externaldata>
9  <airfoil>
10  <name>VFW614 Seitenleitwerksprofil</name>
11  <coordinates>
12  <point><x>1.0000000</x><y>0.0000000</y><z>0.0000000</z></point>
13  <point><x>0.9795687</x><y>0.0023701</y><z>0.0000000</z></point>
14  ...
15  </coordinates>
16  </airfoil>
17  </airfoils>
18 </wings>

Fortran syntax:

tixi_open_document_recursive( character*n xml_filename, integer handle, integer openmode, integer error )

Parameters
[in]xmlFilenamename of the XML-file to be opened
[out]handlehandle to the XML-document. This handle is used in calls to other TIXI functions.
[in]oModeEnum of the mode to open (OPENMODE_PLAIN / OPENMODE_RECURSIVE).
Returns
  • SUCCESS if successfully opened the XML-file
  • NOT_WELL_FORMED if opening the XML-file succeeds but test for well-formedness fails
  • OPEN_FAILED if opening of the XML-file failed
DLL_EXPORT ReturnCode tixiSaveAndRemoveDocument ( TixiDocumentHandle  handle,
const char *  xmlFilename 
)

Write XML-document with all external data to disk.

The document is written into a file specified by xmlFilename. The user should validate the document before it is written to disk. Memory allocated internally for processing this document has to be released by tixiCloseDocument.

If the file was opened with OpenMode=OPENMODE_RECURSIVE and external file where linked into the main XML document, these additional nodes will be saved in the xml file as well. The external nodes will be removed from the main xml-document.

Fortran syntax:

tixi_save_and_remove_document( integer handle, character*n xml_filename, integer error )

Parameters
[in]handledocument handle as returned by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP, tixiCreateDocument or tixiImportFromString
[in]xmlFilenamename of the file to be created.
Returns
  • SUCCESS if the file is successfully written and validated
  • INVALID_HANDLE if handle not found in list of man
  • FAILED if writing and closing the XML-file failed
DLL_EXPORT ReturnCode tixiSaveCompleteDocument ( TixiDocumentHandle  handle,
const char *  xmlFilename 
)

Write XML-document with all external data to disk.

The document is written into a file specified by xmlFilename. The user should validate the document before it is written to disk. Memory allocated internally for processing this document has to be released by tixiCloseDocument.

If the file was opened with OpenMode=OPENMODE_RECURSIVE and external file where linked into the main XML document, these additional nodes will be saved in the xml file as well. The external nodes will not be removed from the main xml-document.

Fortran syntax:

tixi_save_complete_document( integer handle, character*n xml_filename, integer error )

Parameters
[in]handledocument handle as returned by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP, tixiCreateDocument or tixiImportFromString
[in]xmlFilenamename of the file to be created.
Returns
  • SUCCESS if the file is successfully written and validated
  • INVALID_HANDLE if handle not found in list of man
  • FAILED if writing and closing the XML-file failed
DLL_EXPORT ReturnCode tixiSaveDocument ( TixiDocumentHandle  handle,
const char *  xmlFilename 
)

Write XML-document to disk.

The document is written into a file specified by xmlFilename. The user should validate the document before it is written to disk. Memory allocated internally for processing this document has to be released by tixiCloseDocument.

If the file was opened with OpenMode=OPENMODE_RECURSIVE and external file where linked into the main XML tree, please note that these files are saved back into the external files. The external nodes will not be removed from the main xml-document.

Fortran syntax:

tixi_save_document( integer handle, character*n xml_filename, integer error )

Parameters
[in]handledocument handle as returned by tixiOpenDocument, tixiOpenDocumentRecursive, tixiOpenDocumentFromHTTP, tixiCreateDocument or tixiImportFromString
[in]xmlFilenamename of the file to be created.
Returns
  • SUCCESS if the file is successfully written and validated
  • INVALID_HANDLE if handle not found in list of man
  • FAILED if writing and closing the XML-file failed

Generated Tue Mar 8 2022 14:11:54, by Martin Siggel DLR