There are still topics to cover in the previous strand, like embedding XML islands in your content and handling fallback from non-standard to standard document types - and I will cover those in future. To help you choose the posts that match your interests, I've created a separate list of links for the code development and will join the posts in each strand with 'next' and 'previous' links.
Objectives - mine and yours
The aim of the programming strand of this blog is to create a web-based, wysiwyg epub editor. This will work only with epub documents and will be suitable for the creation of new ebooks. There's plenty of effort going into conversion of existing texts between formats so I don't feel the need to do that. If you believe that epub will become the format of choice for ebooks then why not create your book in epub directly? I don't claim that this application will be as powerful as Microsoft Word® with a 'Save As epub' add-in; it definitely won't be. My aim is to show you how you might set about creating a robust, online, multi-user epub editor.
To show you where we'll end up, Figure 1. shows a screenshot of the editor after opening the sample epub book The Curious Case of Benjamin Button. It has a menu across the top and the body of the page shows the result of selecting a book on the 'Books' tab and clicking on the 'Book Content' tab. This manages to look like Adobe Digital Editions but, being online, doesn't require you to download and install the reader.
At the moment we're not interested in style, only in functionality. If you want to see what might be possible by adding CSS styling, look at epub Zen Garden.

Figure 1. Web-based, wysiwyg epub editor
The application was written for the ASP.Net platform using Microsoft's Visual Web Developer 2008 Express Edition®. The programming language is C#.
On the left of the screenshot, a Treeview control is bound to the navMap of the NCX document in order to display the Table of Contents. To the right, an editor control shows the content of the Title Page.
Software Prerequisites
We've seen that epub publications are held as Zip archives and that epub packaging is achieved using a range of XML documents. Content documents are held in XHTML. To start developing an epub editor that runs on the .Net platform I chose the following range of free and/or open software tools:
- Visual Web Developer 2008 Express Edition is used as the main development platform. There are more recent versions of this toolkit available, in beta testing at the time of writing, if you must have the latest. The tool enables the development of ASP.Net websites and includes extensive XML handling. The NCX file requires transformation before it is bound to the Table of Contents control and Visual Web Developer has facilities for using XSLT transforms.
- DotNetZip library is used to manipulate Zip files in the C# .Net environment. Follow the stratightforward installation instructions. The ZipFile class of this library is used to open .epub files and to extract the contents to a folder on disk. It is also used to refresh the archive when a content document is changed or when documents are added or removed.
- tiny MCE is a widely used Javascript editor which converts an ASP.Net TextBox control into an editor that outputs XHTML documents. The WordPress blogging site and the Joomla Content Management Software use this technology. The installation instructions are easy to follow. Configuration is a bit harder so, for the purposes of these posts, I'm keeping it simple.
My favourite approach to using visual development tools is prototyping and this is especially true if I just want to demonstrate some techniques. It's really easy to throw a website together using Visual Web Developer but, having said that, the object-oriented approach required by C# means we need to give some thought to the classes of object that will be required.
Data Model
Figure 2. shows the data model for an epub document drawn, literally, on the back of an envelope.

Figure 2. epub data model
Each node in this model will be developed either as a C# class or will be accessible as an XMLNode within one of those classes.
Example Class epub
Figure 2. shows the class epub which is used to model the contents of an epub file. Most of the code is hidden in this image to enable you to see the structure. The class has Members, Constructors, Methods, and Properties.
Figure 2. epub class
In order not to clutter the posts in this thread, reference material for the code project, including class definitions, can be found at: Inside Epub Code Reference
That's it for setting the scene. Next time I'll look at the user interface.
Article Navigation
Developing an epub editor << Previous Next >>
Exploring epub standarda: Introduction