GenBook and OpenOffice

From CrossWire Bible Society
Revision as of 07:26, 4 December 2009 by David Haslam (Talk | contribs) (Comments and suggestions: Open Office)

Jump to: navigation, search


The OpenOffice to OSIS export filter uses an XSLT stylesheet, in conjunction with an OpenOffice Writer template, to export documents from OpenOffice to OSIS XML (OSIS version 2.1.1) which can be used to create Genbook modules for the Sword Library.

System requirements

OpenOffice (, version 1.1 onwards as well as NeoOffice (

Installation instructions

To install the filter, follow these steps:

  1. Extract the contents of the archive.
  2. Open OpenOffice Writer. In the File menu click on “Templates/Organize...” Right click on “My Templates” and click on “Import Template...” Navigate to the folder where you extracted the archive and double-click on Click “Close” to close the “Template Management” window.
  3. In the Tools menu click on “XML Filter Settings...” Click on “New...”
  4. Enter the information below in the “General” tab:
    1. Filter Name: OSIS GenBook
    2. Application: Writer (.odt)
    3. Name of File Type: OSIS XML Version 2.1.1
    4. File extension: xml
  5. In the “Transformation” tab enter the following information:
    1. DocType: OSIS
    2. XSLT for Export: (the path to “oowriter2osis.xsl”; this could be in ~/.openoffice.org2/user/
    3. xslt/ or wherever you want it)

How to create an OSIS Genbook from OpenOffice Writer

  1. In the OpenOffice Writer File menu click “New.../Templates and Documents/Templates/My Templates” and double-click on OSISGenbook. That will open an untitled document with the necessary styles.
  2. Copy the text you want to be in the OSIS file and paste it into the new document and save it.
  3. Before you start formatting, in the File menu click on “Properties.” In the “Description” tab enter the title of the module as the “Title” and the module name as the “Subject.” Click on the “User Defined” tab and enter the xml:lang code under “1: Info 1.” If you don't enter one the filter will designate English as the language of the module.
  4. Now you can begin formatting. It is important to use the template provided because it is set up to work with the XSLT filter to create a properly formed OSIS document. The first thing you should do is apply paragraph styles for the major divisions in the module, such the book's title, chapters, etc. The hierarchy of divisions is defined in the Outline Numbering menu (Tools/Outline Numbering...) already in the template. These all correspond to OSIS div types except for x-unit, which provides a level of division between book and chapter. To apply a style, just click on the line to which you want to apply the style and double-click on the style in the Styles and Formatting window.
    1. bookGroup (could be a collection of works by the same author)
    2. book
    3. x-unit
    4. chapter
    5. section
    6. subSection
  5. The rest of the paragraphs of the work should be the Default paragraph style. However, you can define certain character styles within all paragraph styles which will be exported with the appropriate OSIS elements. Supported character styles include:
    1. Bold text
    2. Italic text
    3. Superscript text
    4. Subscript text
  6. In addition to text, the OSIS schema offers several features that are easily created in OpenOffice and exported with the proper OSIS elements. For images and Scripture references, follow the directions below to prepare your OpenOffice Document for export and your exported OSIS XML file for compiling.
    1. Footnotes
    2. Endnotes
    3. Tables
    4. Images: When you insert an image, right click on that image and click on “Picture...” Change the Name of the image to the filename, including the file extension. The template has an image named “crosswire.jpg”. Then copy the image to a folder named “images” and include that folder with the module.
    5. osisRef: To designate a Scripture reference as such, in OpenOffice Writer you have to apply the character style “osisRef” to the whole reference, including the book name, chapter, and verse. The export filter creates the <reference> element and copies that reference to the osisRef attribute as it is written in the document. You have to run a Perl script on the exported xml file to achieve a valid osisRef. See step 8 below.
  7. When your document is ready to export from OpenOffice, in the File menu click on “Export...” and in the “File Format” combo box choose “” and click “Export.” Now your OpenOffice Document is exported as an xml file.
  8. If there are scripture references in the book, you should use the script “” to make sure that osisRef's are handled correctly. Input reference formats that this script handles include the following: “Genesis 1,” “Genesis 1:1,” “Genesis 1-2,” and “Genesis 1:1-2:1.” References spanning multiple books need to be manually corrected. Also, Bible book names and abbreviations that are converted to OSIS abbreviations include only a select set of English names and abbreviations (see “Supported Bible Book Names.txt” for a list of supported names and abbreviations). To get command-line syntax and the output filename, simply open an terminal, navigate to the folder where the script is stored, type ./, and press enter. If this doesn't work, make sure that Perl is installed.
  9. Now your file should be ready to compile using xml2gbs. Be sure to include the folder “images” with any image files with your module.

Note: Not all features listed above display correctly in all the Sword front-ends, but the basic fundamentals should work.

Features requested but not yet supported

  1. <foreign> element
  2. <index> element

Current version number and date of release

Version 1.0, 2008-02-13

Comments and suggestions

If you have any comments or suggestions for improving these tools, send an email to Daniel Owens at or send an email to the Sword Developer's Collaboration Forum at sword-