Chapter 5. Adding a custom conversion Previous topic Parent topic Child topic Next topic

We'll explain how to add a custom conversion by using the following example: define a conversion called "refCardToPS" which allows to convert a quick reference card to PostScript using Apache FOP. The XSLT stylesheets needed to perform that conversion are found in /opt/quickrefcard/.

Before you begin

XMLmind XSL Server is assumed to have been configured in order to have a customization directory as explained in Specifying the customization directory of XMLmind XSL Server. In the following example, we'll suppose that this customization directory is E:\opt\xslsrv/.

Procedure

  1. Start XMLmind XSL Utility by executing xslutil -p E:\opt\xslsrv &.
  2. Click Add.
  3. Click the Description tab and describe your conversion as follows.
    refcard_description.png
  4. Click the Transform tab and specify the location of the main XSLT stylesheet. While at it, add one or more XSLT stylesheet parameters.
    refcard_transform.png
  5. Click the Process tab and choose FOP as your XSL-FO processor.
    refcard_process.png
  6. Click OK to close the dialog box.
  7. Click Quit to quit XMLmind XSL Utility.
    From now, you'll be able to perform a refCardToPDF conversion in addition to all the stock conversions.
    Notice that stopping and then restarting XMLmind XSL Server was not needed in order to add a custom conversion.
    Attention
    Attention
    May be you'll have to slightly modify your custom XSLT stylesheets in order to use them in XMLmind XSL Server. Let's use an example to explain a possible issue.
    When you use XMLmind XSL Server to convert a remote document such as https://www.xmlmind.com/xmleditor/_distrib/demo/docbook/docbook-image.xml Opens in new window to PDF or RTF , the server generates a temporary XSL-FO file on its host. Let's call this temporary file /tmp/xslu12345.fo.
    By default, an XML element such as:
    <imagedata fileref="graphics/fish1.png" 
               format="PNG"/>
    is translated to something like:
    <fo:external-graphic src="graphics/fish1.png"
                         content-type="content-type:image/png"/>
    Unfortunately this cannot work because there is no /tmp/graphics/fish1.png file on the host running XMLmind XSL Server.
    Instead, the above XML element should be translated to:
    <fo:external-graphic
    src="https://www.xmlmind.com/xmleditor/_distrib/demo/graphics/fish1.png"
    content-type="content-type:image/png"/>
    The dbToXXX and db5ToXXX conversion specifications pass a number of parameters such as img.src.path Opens in new window to their XSLT stylesheets in order to get absolute URLs in the generated XSL-FO file. May be you'll have to add a similar facility to your own XSL stylesheets.(1).

 (1)
The xhtmlToXXX conversion specifications pass img-src-path to their XSLT stylesheets.
The ditaToXXX conversion specifications, which use XMLmind DITA Converter Opens in new window (ditac), have no such issue.