4.3 Configuration
XHTML export can be configured with a configuration file. The configuration is read from several sources:
-
First Writer2xhtml reads the file writer2latex.xml in the same directory as writer2latex.jar. This file is supposed to contain installation-wide configuration.
-
Then it reads the file writer2latex.xml in your home directory (unix, eg. /home/username) or user profile (windows, eg. c:\documents and settings\username). This file is supposed to contain user-specific default configuration.
-
Then the file <documentname>-config.xml in the same directory in the source document is read.
-
If you specify a configuration file on the command line, this file will replace <documentname>-config.xml.
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
-
If the option create_document_config if set to true, the document specific configuration file mentioned above will be created if it does not exist.
-
The option xhtml_custom_stylesheet is used to specify an URL to your own, external stylesheet. If the value is empty or the option is not specified, no external stylesheet will be used.
-
The option xhtml_ignore_styles is used to specify if formatting should be exported. If the value is true, no style information will be exported (in this case you should specify a custom style sheet!).
-
The option xhtml_use_dublin_core is used to specify if Dublin Core Meta data should be exported (the format will be as specified in http://dublincore.org/documents/dcq-html/). If the value is false, it will not be exported.
-
The option xhtml_scaling is used to specify a scaling of all formatting, ie. to get a different text size than the original document. The value must be a percentage.
-
The option xhtml_splitting is used to specify that the documents should be split in several documents and the outline level at which the splitting should happen (the default 0 means no split). This is convenient for long documents. Each output document will get a simple navigation panel in the header and the footer.
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:
-
name specifies the name of the Writer style.
-
class specifies the styles class in Writer; this can either be text, paragraph, frame, list or attribute. The last value does not specify a real style, but refers to hard formatting attributes. The possible names in this case are bold, italics, fixed (for fixed pitch fonts), superscript and subscript.
-
element specifies the XHTML element to use when converting this style. This is not used for frame and list styles.
-
css specifies the CSS style class to use when converting this style. If it is not specified or the value is “(none)”, no CSS class will be used.
-
block-element only has effect for paragraph styles. It is used to specify a block XHTML element, that should surround several exported paragraphs with this style.
-
block-css specifies the CSS style class to be used for this block element. If it is not specified or the value is “(none)”, no CSS class will be used.
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.