Basic implementation
The basic implementation uses the XML configuration document to define how ODWEK will build the transform command which it executes during document retrieval.
About this task
Use the XML document to synthesize the transform command, including the path to the transform executable, the document details stored in the Content Manager OnDemand server’s application definition, and transform-specific options to pass straight through to the transform command. The following example shows an XML file for a user-supplied transform that could be used in this implementation.
<Transforms>
<transform>
<TransformName>MyTXFRM_EXE</TransformName>
<TransformDescription>Transform Cmdline Executable</TransformDescription>
<ODFileType>L</ODFileType>
<OutputMimeType>application/pdf</OutputMimeType>
<OutputExtension>pdf</OutputExtension>
<CmdParms>
<RECORDLENGTH>-lm</RECORDLENGTH>
<CARRIAGECONTROL>-x</CARRIAGECONTROL>
<CODEPAGE>-a</CODEPAGE>
<OUTPUTFILE>-o</OUTPUTFILE>
</CmdParms>
<CmdLineExe>/opt/mytransform/bin/txfrm.exe</CmdLineExe>
<Passthru>
<!-- Use tag cmdlineparm to declare additional cmdline variables -->
<!-- that the transform might require -->
<cmdlineparm>-r PDF</cmdlineparm>
</Passthru>
</transform>
<Transforms>
In this example, a transform has been defined named “MyTXFRM_EXE”, which calls the transform command “txfrm.exe” that is defined by the <CmdLineExe> tag. The value given for the <TransformName> tag, which in this example is MyTXFRM_EXE, is specified as the “viewer” value argument in the ODWEK retrieve call. For example:
byte [] transformed_data_bytes = odHit.retrieve(“MyTXFRM_EXE”);
Additionally, from this XML, ODWEK knows that the transform requires RECORDLENGTH,
CARRIAGECONTROL, and CODEPAGE information from the Content Manager OnDemand server application definition for the hit being
retrieved, and that the transform takes an OUTPUTFILE parameter. The txfrm.exe also
requires some additional information to be passed along on the cmdline as well. The
-r that is specified in the
<cmdlineparm> tag has no meaning to ODWEK, so it is passed
through "as is" to the txfrm.exe.
If the hit being retrieved/transformed has these characteristics as specified in its application definition on the View Information page of the OnDemand Administrator client:
Code Page = 500
CC = Yes
RECFM = Fixed
LRECL = 133
CC Type = ANSI
Then using the example XML shown previously, the ODWEK Generic Transform Interface takes the retrieved bytes, writes them to a temporary file datafilename to be used as an argument to txfrm.exe, builds, and then executes the following command:
/opt/mytransform/bin/txfrm.exe -lm 133 –x A –a 500 –o outputfilename -r PDF datafilename
ODWEK manages the creation, naming, and deletion of any temporary files that are used to complete the command execution, such as outputfilename and datafilename. The txfrm.exe program writes its output to outputfilename. ODWEK reads the output from the file and returns it to the caller as a byte array. The byte array named transformed_data_bytes then contains the transformed data.