# Hacking &bookcase;

In the spirit of Free Software, you're welcome to hack on &bookcase; as much as you like. You should be able to write scripts to import, export, or modify data very easily. This chapter gives you more information about doing that.

## File Format

The default &bookcase; data file is a zip archive, normally with a `.bc` file extension. Inside the archive is a top-level `bookcase.xml` file. Any images are placed inside the `images/` directory in the archive. Additionally, the data file may be simply the XML file itself.

### XML Data

### Image Format

Images may also be included in the XML stream as base64-encoded data. This format may be useful when writing scripts to interface with &bookcase; when creating a Zip archive may be a hassle.

## Collection Type Values

The type of collection is given in the type attribute of the collection element. The value is equal to the CollectionType enum value in `src/collection.h`.

### Collection Type Values

Collection Type | Value
--- | ---
Custom Collection | 1
Book Collection | 2
Video Collection | 3
Music Collection | 4
Bibliography | 5
Comic Book Collection | 6
Wine Collection | 7
Coin Collection | 8
Stamp Collection | 9
Trading Card Collection | 10

## Field Type Values

&bookcase; will include all the default fields for a collection if the first field element has the name _default. For Paragraph, Table, or Image fields, the field category should be identical to the field title.

The type of field is given in the type attribute of the field element. The value is equal to the FieldType enum value in `src/field.h`. ReadOnly fields were intended for fields which should be retained in the collection, but which should not be editable by the user, such as some fields added when importing a collection from another file format. It is not currently used.

### Field Type Values

Field Type | Value
--- | ---
Simple Text | 1
Paragraph | 2
Choice | 3
Checkbox | 4
ReadOnly | 5
Number | 6
URL | 7
Single-Column Table | 8
Double-Column Table | 9
Image | 10
Dependent | 11

The field may have different flags set, given as a bitwise OR'd value in the flags attribute on the field element. The flag for preventing the user from deleting a field is intended for such things as the citation key for bibliographic entries.

### Field Flag Values

Field Flags | Value
--- | ---
Allow Multiple Values | 0x01
Allow Grouping | 0x02
Allow Completion | 0x04
Disallow Deleting | 0x08

The format of the field is given in the format attribute on the field element. Date Formatting is not currently used. Grouping by People uses all the fields which use Name Formatting.

### Field Format Values

Field Format | Value
--- | ---
Capitalization Only | 0
Title Formatting | 1
Name Formatting | 2
Date Formatting | 3
No Formatting | 4

## XSLT Tricks

Here are some tips for writing XSLT to parse &bookcase; XML data: