4.3 Configuration

XHTML export can be configured with a configuration file. The configuration is read from several sources:

The configuration file is an xml file, here are the default contents:

<?xml version="1.0" encoding="UTF-8"?>

<config>

  <option name="create_document_config" value="false" />

  <option name="xhtml_custom_stylesheet" value="" />

  <option name="xhtml_ignore_styles" value="false" />

  <option name="xhtml_use_dublin_core" value="true" />

  <option name="xhtml_scaling" value="100%" />

  <option name="xhtml_split_level" value="0" />

</config>

Options

Style maps

In addition to the options, you can specify that certain styles in Writer should be mapped to specific XHTML elements and CSS style classes. Here are some examples showing how to use some of the built-in Writer styles to create XHTML elements:

<?xml version="1.0" encoding="UTF-8"?>

<config>

  <!-- map OOo paragraph styles to xhtml elements -->

  <xhtml-style-map name="Text body" class="paragraph"   

           element="p" css="(none)" />  

  <xhtml-style-map name="Sender" class="paragraph"

           element="address" css="(none)" />

  <xhtml-style-map name="Quotations" class="paragraph"

           block-element="blockquote" block-css="(none)"

           element="p" css="(none)" />

  <!-- map OOo text styles to xhtml elements -->

  <xhtml-style-map name="Citation" class="text"

           element="cite" css="(none)" />

  <xhtml-style-map name="Emphasis" class="text"

           element="em" css="(none)" />

  

  <!-- map hard formatting attributes to xhtml elements -->

  <xhtml-style-map name="bold" class="attribute"

           element="b" css="(none)" />

  <xhtml-style-map name="italics" class="attribute"

           element="i" css="(none)" />

</config>

An extended version of this is distributed with Writer2LaTeX, please see the file cleanxhtml.xml.

The attributes of the xhtml-style-map element are used as follows:

For example the rules above produces code like this:

<p>This paragraph is Text body</p>

<address>This paragraph i Sender</address>

<blockquote>

  <p>This paragraph is Quotations</p>

  <p>This paragraph is also Quotations</p>

</blockquote>

<p>This paragraph is also Text body and has some <em>text with emphasis style</em> and uses some <b>hard formatting</b>.</p>

You can use your own Writer styles together with your own CSS style sheet to create further style mappings, for example:

<xhtml-style-map name="Some OOo style" class="paragraph"

           block-element="div" block-css="block_style"

           element="p" css="par_style" />

to produce output like this:

<div class=”block_style”>

  <p class=”par_style”>Paragraph with Some OOo style</p>

  <p class=”par_style”>Yet another</p>

</div>

Note that the rules for hard formatting are only used when xhtml_ignore_styles is set to true. It is not recommended to rely on these rules, using real text styles is preferable. They are included because the use of hard character formatting is very common even in otherwise well-structured documents.