1. Computing & Technology

How to Write the Container.xml File for EPUB

Tutorial for the EPUB Container.xml File

From

Container.xml is an essential file for any EPUB document. Ebooks are in the forefront of the world of publishing these days. The advances in computer technology demand that a savvy writer understand the basics of digital books to succeed. EPUB is one way you can take your written pages and make them available to literally millions of readers. An EPUB archive document consists of three basic sections:

It is the META-INF section that holds the vital container.xml file. This file directs the device processor to the meta data information. Metad ata holds the statics of your book. For instances, you might state the author’s name and publishing date as metadata information. Creating a container.xml file is not difficult. Most files have the same setup. However, the technology does have specific syntax that must be followed. To write your container document open a basic text editor, such as Windows Notepad.

Declaration Statement

A container file starts the same way all XML documents do, with a declaration statement.

<?xml version="1.0"?>

Root Element and Namespace

For the container, the basic declaration statement is all you need. Next you must identify the root element in the file as container.

<container version="1.0"

The namespace and root element are static. They will be the same for all container files.

xmlns="urn:oasis:names:tc:opendocument:xmlns:container">

Put the namespace on the same line as the root element.

<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">

Parent Element

Establish the parent element. The parent element is static, as well. It will always be rootfiles.

<rootfiles>
</rootfiles>

Child Element and Path Information

Within the parent element opening and closing tags, you insert a child element that points to the meta data file. The child element name will always be rootfile.

The full-path declaration may vary per EPUB document. It must always be the name of the file that contains the metadata information. In most cases, this will be content.opf.

The completed container file will look similar to this:

<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf"
media-type= application/oebps-package+xml" />
</rootfiles>
</container>

As with all XML files, you must provide an opening and closing tag for the elements, so make sure to close the ;container tag in the last line of the file. To complete the process, save the container in the META-INF folder under the title container.xml.

©2012 About.com. All rights reserved.

A part of The New York Times Company.