Granule User's Manual
Prev |  | Next

# Chapter 5. File Formats And Conversions

This chapter discusses internal XML file format Granule employs to store its Decks. The example of a simple Perl script follows to illustrate the the import of a collection of flashcards from a different format.

# 5.1. File Formats

As mentioned before, a deck is stored in a simple XML formatted file with `*.dkf` file extension. Lets look at and discuss the meaning of each tag in our example file, `Lesson_01.dkf`.

    001 <?xml version="1.0" encoding="UTF-8"?>
    002 <!DOCTYPE deck SYSTEM "/etc/xml/granule/granule.dtd">
    003 <deck>
    004   <author>Vladislav Grinchenko</author>
    005   <description>Created on Wed 13 Oct 2004 11:18:13 PM EDT</description>
    006   <sound_path>/usr/share/WyabdcRealPeopleTTS</sound_path>
    007   <card id="_1097723900">
    008     <front>freedom</front>
    009     <back>the state of being released</back>
    010     <back_example>~ is being able to make decisions that affect mainly you.</back_example>
    011   </card>
    012   <card id="_1097723901">
    013     <front> ... </front>
    014     <back>  ... </back>
    015     <back_example> ... </back_example>
    016   </card>
            ...
    034 </deck>

- Line 001 is the preamble of an XML file indicating that each data field is a UTF-8 encoded string. Thus, you can store information in any language in the world so long as you have the right font and keyboard input binding installed for your locale.

- Line 002 informs XML parser that the body of the document must comply with `granule.dtd` data dictionary.

- Lines 003 through 034 define a Deck:

- Line 004 records the author of the Deck. Fill in your name.

- Line 005 records the Deck's description. By default, Granule records the creation date.

- Line 006 records the UNIX path to the sound dictionary (if you have one installed).

- Lines 007 through 011 define a Card:

- Line 007 defines the Card's ID. Each ID is uniquely indentifies a Card across your entire collecion of cards. It consists of an underscore followed by the number of seconds since January 1, 1970. A shell command ' % date +%s' gives you this UNIX time in seconds. Prepend it with underscore, and you have a unique ID.

- Line 008 holds the Question Word of the Card.

- Line 009 holds the Answer Word/Phrase of the Card.

- Line 010 holds an Example sentence(s) that illustrate the usage of the question word. XML preserves you line breaks (newline characters) and anywhere in the text (including question and answer fields) you can use Pango Text Attribute Markup Language.

Prev | Home | Next
Configuration File |  | To Import Flashcards From Other Formats