The XmlTest.java
sample program demonstrates how to run Export out of process.
To convert files out of process in the Java API
If required, set parameters for the out-of-process conversion in the formats_e.ini
file. See Configure Out-of-Process Conversions.
Create an instance of the XmlExport
class.
XmlExport objXmlExport = new XmlExport();
If you are using a template file to set the conversion options, call the setIniFileName
method.
objXmlExport.setIniFileName(iniFile);
If you are using the API to set the conversion options, create instances of the following classes:
XmlTemplateInfo XmlOptionInfo XmlTOCOptionInfo StyleMapping XmlHeadingInfo
Set the classes to the current XmlExport
object using the appropriate set methods. If you do not set the classes before calling the startOOPSession
method, default values are used.
Set the location of the Export libraries by calling the setExportDirectory
method. These are normally in the directory install\OS\bin
, where install
is the path name of the Export installation directory and OS
is the name of the operating system.
objXmlExport.setExportDirectory(exportDir);
Optionally, set the input source as either a file or stream by calling the setInputSource
method.
//set the input source as file objXmlExport.setInputSource(inFile); //set the input source as stream inf = new File(inFile); fis = newFileInputStream(inf); objXmlExport.setInputSource(fis);
Set up an out-of-process session by calling the startOOPSession
method. This initializes the out-of-process session, creates a Servant process, establishes a communication channel between the application thread and the Servant, and sends the data to the Servant.
objXmlExport.startOOPSession();
Convert the input and generate the output files by calling the convertTo
method. You cannot use the convert
methods that set the input source because the input source must be set before the out-of-process session is initialized. The convertTo
method can only be called once in a single out-of-process session.
objXmlExport.convertTo(outFile);
Terminate the out-of-process session by calling the endOOPSession
method. The Servant ends the current conversion session, and releases the source data and session resources.
objXmlExport.endOOPSession(TRUE);
After all files are converted, terminate the out-of-process session and the Servant process by calling endOOPSession
and setting the Boolean to FALSE
.
objXmlExport.endOOPSession(FALSE);
Terminate the Export session and free allocated system resources by calling the shutdownExport()
method.
m_objExport.shutdownExport();
|