Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Transforming Cinema Tools XML

More closely integrating Cinema Tools into production workflows is now possible thanks to the XML export feature in Cinema Tools version 4.0 and later.

The XML file format for exported Cinema Tools film lists is optimized to be machine readable and transformable. Cinema Tools XML files can be read as input to another software application or transformed into another format. As a result, users can more completely and conveniently access information in the film lists than was possible with the plain text files exported in earlier versions of the software. (NOTE: Cinema Tools XML is a distinct format from Final Cut Pro XML. For information about Final Cut Pro XML, see Final Cut Pro Opens Up.)

Processing XML Files

The Cinema Tools SDK (DMG) provides files that demonstrate two methods for processing a Cinema Tools XML file: an XSLT stylesheet or compiled software.

XSLT Processing

XSLT allows you to create a stylesheet that can transform an XML file into another format. (The original XML file remains unchanged.) On the disk image, there is a sample XSLT stylesheet that extracts cut list information from a Cinema Tools XML file and transforms this information into a tab-delimited text file. (You can run this style sheet from the command line or by using an AppleScript script provided on the disk image.)

XSLT uses a technology called XPath that takes advantage of the fact the XML files are hierarchical in nature and that you can identify an element in the XML tree by a constructing a path that starts with the root element and works its way down from the top of the hierarchy. In Cinema Tools XML, for example, the <ctlists> element contains all the various film lists and the <cutlist> element is one of those lists. The <cutlist> element in turn contains the <items> element, which contains all the items of the cut list. To specify a cut event using XPath, one would write /ctlists/cutlist/items/cut. Actually, the path does not specify just one cut event, but the set of all XML elements matching the path. XSLT can process each member of the set sequentially.

XSLT and XPath are powerful technologies that you can use to transform XML into many different data formats. The sample XSLT stylesheet on the disk image is a starting point for further development.

Software Processing

The disk image examples provide a second method for processing Cinema Tools XML files: Xcode projects that compile to software programs that can access and extract information from the XML.

The best way to programmatically access the individual elements in a Cinema Tools XML file (or any XML file) is to first parse the XML into a tree structure. Mac OS X ships with two different code libraries for doing this: the CoreFoundation framework and the Foundation framework. (There are other libraries of code freely available from different vendors. One example is libxml2, available at http://xmlsoft.org. )

There are two sample Xcode projects on the disk image:

  • CF XML Tool uses the CoreFoundation library and is written in C/C++.
  • NS XML Tool uses the Foundation library and is written in Objective-C.

These Xcode projects build Console applications called cfxmltool or nsxmltool that you can execute from the command line. The applications open an XML file specified as the single argument on the command line, parse the XML into a tree, access certain elements of the XML tree, and then print output to the Console.

The sample code in these projects is a starting point. While relatively simple, it provides examples of most things a developer may need to do. By starting with one of the sample projects, you should be able to easily extend the code to access any or all of the elements in a Cinema Tools XML film list. The console output can be written to a file using the redirect operator on the command line.

PDF And XML Formats

In addition to the XML export format, Cinema Tools also provides a PDF export file format optimized to be human readable. The film lists are paginated with page headers and footers and the columns of list data are completely user-selectable. (The default is for Cinema Tools to export a PDF file. New menu items have been added to support export of a XML file from an EDL or a Final Cut Pro XML file.)

Both the PDF and the XML files contain all the film lists chosen by the user in the export dialog. Lists that were not checked are omitted from the exported file. The PDF lists contain those columns of data in a list that were selected by the user in the export dialog. The XML lists, on the other hand, contain all the columns of data. There are no choices presented in the export dialog.

For More Information:

Updated: 2008-03-27