eXML
[General Eiffel Badge]
[General Eiffel Badge]
[General Eiffel Badge]
eBook File Format

The main eBook file format is 100% XML of course. XML is quite easy to understand. It helps alot if you know a bit about HTML. Have a look at the XML Version 1.0 Specification for full details about XML.

With eBook you have a clean seperation between content and layout. The content is stored in a XML file. The main element is ebook. Within the ebook element you can nest and list as many page elements as you want. A page element will be translated by eBook to a HTML page. The following sample would generate 3 (nearly) empty HTML files:


<ebook>
        <page>
        </page>

        <page>
        </page>

        <page>
        </page>
</ebook>
			

The previous example is not runnable because each page must have exactly one topic , exactly one text and zero or more page elements. The topic element must contain only text. The text you specify in the topic element will be used in the menu and as headline for the corresponding page. The text in the text element will be used as page content. For now only plain text is allowed. You can use regular HTML tags, as long as they are valid XML. Here is a more complete example:


<?xml version="1.0"?>

<!DOCTYPE ebook
[
<!ELEMENT ebook (page+)>
<!ELEMENT page (topic, text, page+)>
<!ATTLIST page
          key    CDATA "auto">
<!ELEMENT topic (#PCDATA)>
<!ELEMENT text (#PCDATA)>
]>

<ebook>
	<page key="index.html">
		<topic>
			Main Page
		</topic>
		<text>
			This is the main page.
		</text>
	</page>
	<page>
		<topic>
			Second Page
		</topic>
		<text>
			This is the second page, with some HTML tags.
			<A HREF="http://exml.net">I am a link!</A>
		</text>
	</page>
	<page>
		<topic>
			3rd Page
		</topic>
		<text>
			This is the 3rd page. 
			It includes a nested page.
		</text>
		<page>
			<topic>
				Nested page
			</topic>
			<text>
				This page is nested in the 3rd page.
			</text>
		</page>
	</page>
</ebook>
			

The first lines define how which format this XML document has. The key attribute you can see on the first page-start tag is optional on if specified forces eBook to use the value of the attribute as file-name for this page.

Currently eBook does nearly no validation on wether the input is correct or not. Well formdness rules are checked an reported, but if other errors will most likely result in an unhandled exception.