A FictionBook file is one XML document whose root, FictionBook, holds in
order: any number of stylesheet elements, one description, one
body with the text, optionally a second body for
the notes, and any number of binary
elements. This page covers the description, the book’s metadata. Element
names and occurrences are those of the FictionBook 2 XML schema
(FictionBook.xsd), whose namespace is
http://www.gribuser.ru/xml/fictionbook/2.0; links use XLink, namespace
http://www.w3.org/1999/xlink, usually with the prefix l: or
xlink:.
The file
- The encoding is given in the XML declaration. UTF-8 and Windows-1251 (Cyrillic) are the most common; readers must honour the declaration.
- The extension is
.fb2. Files are often zipped one per archive as.fb2.zip, which readers open directly. - There is no binary header: the file starts with the XML declaration, sometimes
after a UTF-8 byte order mark, then
<FictionBook.
description
| Child | Number | Content |
|---|---|---|
title-info | 1 | The book itself: see title-info. |
src-title-info | 0–1 | The same fields for the original, when the book is a translation. |
document-info | 1 | The FB2 file as a document: who made it, when, its ID and version. See document-info. |
publish-info | 0–1 | The printed edition the text came from. See publish-info. |
custom-info | Any | Free text, with a required info-type attribute naming what it is. |
output | 0–2 | FictionBook 2.1: rules for making paid and free copies. See output. |
title-info and src-title-info
| Child | Number | Content |
|---|---|---|
genre | 1 or more | A genre code. Attribute match: how well the genre fits, as a percentage, default 100. |
author | 1 or more | An author. |
book-title | 1 | The title. |
annotation | 0–1 | A blurb, in the same block elements as a section (paragraphs, poems, quotes, tables). |
keywords | 0–1 | Keywords, separated by commas. |
date | 0–1 | When the work was written: see dates. |
coverpage | 0–1 | One or more image elements pointing to cover images in binary elements. |
lang | 1 | The language of the book, such as ru or en. |
src-lang | 0–1 | The language of the original, for a translation. |
translator | Any | A translator, with the same content as author. |
sequence | Any | A series the book belongs to: see sequence. |
The elements must appear in this order. Text elements (book-title,
keywords and the like) may carry xml:lang.
Dates
A date element holds a date as people would read it, in any form, and
optionally a machine-readable value attribute in ISO form
(YYYY-MM-DD): <date value="1895-01-01">1895</date>.
It may carry xml:lang. The year of
publish-info is a plain year.
sequence
An empty element (or one holding nested sequence elements, for a
sub-series) with attributes name (required, the series name),
number (optional, the book’s number in it, a whole number) and
xml:lang: <sequence name="Discworld" number="3"/>.
document-info
| Child | Number | Content |
|---|---|---|
author | 1 or more | Who made the FB2 file (scanned, proofread, marked up). |
program-used | 0–1 | The programs used. |
date | 1 | When the file was made. |
src-url | Any | Where the source text came from. |
src-ocr | 0–1 | Who scanned and recognised the original. |
id | 1 | A unique ID for this document, often a GUID; libraries use it to spot duplicates. |
version | 1 | The version of the file, a decimal number such as 1.0 or 1.1, raised when it is corrected. |
history | 0–1 | The change history, as annotation-like block content. |
publisher | Any | The owner of the electronic edition, as an author structure. |
publish-info
| Child | Number | Content |
|---|---|---|
book-name | 0–1 | The title of the printed book. |
publisher | 0–1 | Its publisher, as text. |
city | 0–1 | The city of publication. |
year | 0–1 | The year of publication. |
isbn | 0–1 | The ISBN. |
sequence | Any | The publisher’s series. |
output (FictionBook 2.1)
Instructions for a shop or library that makes copies of the book for readers, for example a free extract and a paid full copy. At most two.
| Element | Attributes | Content |
|---|---|---|
output | mode (required): free or paid. include-all (required): require, allow or deny. price, currency. | part and output-document-class elements. |
part | xlink:href (required), xlink:type, include (required): require, allow or deny | Empty: whether a part of the book, by ID, goes into the copy. |
output-document-class | name (required), create (require, allow or deny), price | part elements: settings for one kind of output document. |
stylesheet
Before the description, stylesheet elements may hold style rules, with
a required type attribute such as text/css. They style the
named style elements of the text. Most readers ignore them.