3. Custom conversion specifications

A custom conversion specification is simply a text file, UTF-8 encoded, containing a number of w2x command-line options separated by space or new line characters.

Example 1. Simple example used to generate a DocBook v4.5 book possibly containing CALS (not HTML) tables
-o docbook
-p convert.set-column-number yes
-p transform.cals-tables yes
Example 2. Advanced example used to convert XMLmind Word To XML Manual to a DITA bookmap

Custom conversion specification file w2x_install_dir/doc/manual/bookmap_options.txt:

-p edit.prune.preserve p-ProgramListing
-p edit.inlines.convert " c-Code code ! c-Abbrev abbr "
-p edit.blocks.convert "p-Term dt g:id='dl' g:container='dl' !¬
 p-Definition dd g:id='dl' g:container='dl' !¬
 p-ProgramListing span g:id='pre' g:container='pre'"
-pu edit.after.blocks customize/notes.xed
-p transform.root-topic-id manual
-p transform2.topic-path manual_bookmap_topics
-p transform2.section-depth 6
-o bookmap
-t customize/custom_topic.xslt

where customize/notes.xed is:

namespace "http://www.w3.org/1999/xhtml";
namespace html = "http://www.w3.org/1999/xhtml";
namespace g = "urn:x-mlmind:namespace:group";

for-each /html/body//p[get-class("p-Note")] {
    delete-text("note:\s*", "i");
    if content-type() <= 1 and not(@id) {
        delete();
    } else {
        remove-class("p-Note");
        set-attribute("g:id", "note_group_member");
        set-attribute("g:container", "div class='role-note'");
    }
}

group();

and customize/custom_topic.xslt is:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:h="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="h">

<xsl:import href="w2x:xslt/topic.xslt"/>

<xsl:template match="h:div[@class = 'role-note']">
  <note>
    <xsl:call-template name="processCommonAttributes"/>
    <xsl:apply-templates/>
  </note>
</xsl:template>

<xsl:template match="h:code">
  <tt>
    <xsl:call-template name="processCommonAttributes"/>
    <xsl:apply-templates/>
  </tt>
</xsl:template>

</xsl:stylesheet>

Note that relative URIs referenced by -pu options are relative to the text file containing the custom conversion specification. For example, customize/notes.xed referenced in w2x_install_dir/doc/manual/bookmap_options.txt is in fact w2x_install_dir/doc/manual/customize/notes.xed.