An EPUB file is a zipped group of files conforming to the EPUB standard of the International Digital Publishing Forum (IDPF). This standard is the distribution and interchange standard for digital web publications. In Archive View, you can open EPUB files, view the EPUB file's digital publication in a preview tab, edit component files of the EPUB archive directly in XMLSpy, validate the EPUB file, and save the component files back to the EPUB archive.
|Note:||(i) XMLSpy supports EPUB 2.0.1. (ii) A sample EPUB file is available in the Examples project and in the (My) Documents/Altova/XMLSpy2023/Examples folder.|
In the descriptions below, terms are used as follows:
• EPUB file is used to indicate the EPUB file having the file extension .epub. This is the ZIP file that contains the whole archive and is the file that will be opened in Archive View
•An archive file is any one of the files contained in the EPUB archive
•EPUB book is the term used to indicate the digital publication generated by the zipped EPUB file
In this section
The description below of EPUB functionality in XMLSpy is structured into the following parts:
•Opening EPUB files in Archive View
•Modifying the contents and structure of an EPUB archive
•Editing archive files directly in XMLSpy
•Entry helpers for archive files
Opening EPUB files in Archive View
Select the menu command File | Open, navigate to the EPUB file, and click Open. The EPUB file opens in Archive View (screenshot below). Alternatively, you can right-click the EPUB file in Windows Explorer and select the context menu command to open the file with XMLSpy. If you have set XMLSpy to be the default editor of EPUB files, then double-clicking the EPUB file will open the file in Archive View.
Folder View on the left-hand side shows the folders in the archive, whereas the Main Window shows the files in the folder selected in Folder View. The EPUB archive will have the following structure and the following key components.
|-- Mimetype file
|-- META-INF folder
| |-- container.xml
|-- DOCUMENT folder (In the screenshot above, OEBPS is the Document folder.)
|-- Contains HTML, CSS, image files, plus OPF and NCX files
Creating a new EPUB file
To create a new EPUB file, select the menu command File | New. In the Create New Document dialog that pops up, select the file type .epub. In the Save As dialog that now pops up, give a name for your EPUB document and click Save. A skeleton EPUB archive containing all the folders and files of a valid EPUB archive (see archive structure above) will be created in a new window in Archive View. Add the folders and files you wish to add to the archive, as described below, and then save the EPUB file. To edit an archive file directly in XMLSpy, double-click the file in Archive View. The file will open in a new XMLSpy window. Edit it and then save it with the File | Save (Ctrl+S) command.
Previewing an EPUB book
To preview an EPUB book, make the EPUB file active in Archive View, then click the Preview button in the toolbar of Archive View. The EPUB book will open in a separate (Internet Explorer) browser window in XMLSpy. If any of the files that will be used for the preview—whether a content file or a structure-related file—has been modified but not yet saved, you will be prompted to save the file. If you do not save the modifications, the preview will use the previously saved data and might not be up-to-date. You can specify that all modified files be saved automatically before previewing by toggling on this setting (via the Settings button in the the toolbar of Archive View).
Note the following:
•If the Preview button in Archive View is clicked while a Preview window of that EPUB publication is still open, then the EPUB publication will be reloaded in the open Preview window.
•Refreshing the Preview window itself (using the Refresh (F5) command of Internet Explorer) will not update the Preview window. The EPUB publication in the Preview window must be updated using the Preview button (of Archive View) of the corresponding EPUB file (see previous point).
•To close the preview, close the Preview window.
|Note:||Not all EPUB markup is supported in Internet Explorer, so previews could be distorted. Additionally, if the digital publication document is XML—and not HTML—the preview might not work. Newer versions of Internet Explorer provide improved handling of EPUB markup, so if you experience problems, try updating to the latest version of Internet Explorer.|
Modifying the contents and structure of an EPUB archive
You can add folders (click the New Folder button), new files (Add New Document), and existing files (Add Document) to the selected archive folder. Note that when you add a new folder or new document, you must immediately enter a name for the folder or file; it is not possible to rename folders in Archive View. You can delete a file or folder by selecting it and clicking the Delete from Archive button.
After you have modified the archive you must save the EPUB file (File | Save) for the changes to be saved.
Info and Settings
Clicking the Info button displays, at the bottom of Archive View, a summary of key archive information (screenshot below). Clicking the Info button again removes the summary. The summary reports the number of files in the archive (including the Mimetype file and container.xml), the size of the compressed EPUB file, and the cumulative size of the unzipped files.
The Settings button contains drops down two automatic file-saving options that can be toggled on and off: to automatically save the EPUB file (i) before validation, and (ii) before previewing the EPUB file in (via the Preview button) in XMLSpy.
Editing archive files directly in XMLSpy
To edit an archive file directly in XMLSpy, double-click the file in Archive View. Alternatively, select the file in Archive View and click the Open Document button in the toolbar of Archive View.The file will open in a new XMLSpy window. Edit it and then save it with the File | Save (Ctrl+S) command.
Entry helpers for archive files
Entry helpers for standards-based archive files are available when these archive files are opened in XMLSpy. These archive files are:
•The OPF file, traditionally named content.opf, contains the EPUB book's metadata. It is based on the Open Packaging Format (OPF) specification.
•The NCX file (Navigation Control file for XML), traditionally named toc.ncx, contains the publication's table of contents. It is based on the NCX part of the OPF specification.
•The folder named META-INF must contain the file container.xml, which points to the file defining the contents of the book (the OPF file). The file container.xml specifies how the archive files should be organized according to rules in the Open Container Format (OCF) specification.
Validating an EPUB file
To validate an EPUB file, select the command XML | Validate XML (F8). The validation results are displayed in the Messages window (screenshot below). If any of the archive files—whether a content file or a structure-related file—has been modified but not yet saved, you will be prompted to save the file. You must save the modified files in order to validate the EPUB file. You can specify that all modified files be saved automatically before validation by toggling on this setting (via the Settings button in the the toolbar of Archive View).
Error messages display: (i) the file in which the error was found, and, if applicable, the number of the line in which the error occurs; (ii) a description of the error. In the screenshot above, the highlighted error occurs in line 21 of the file content.opf. Clicking on the error line in the Messages window opens the relevant file and highlights the error.
|Note:||The EPUB validation engine is a Java utility, so Java must be installed on your machine for the validation engine to run.|