DITA-OT plugin cannot find JAR file function when transtype = PDF

I am working on a DITA-OT plugin that calls a function from a JAR file. When I create XHTML, the plugin finds this function. When I create a PDF file, it is not. I read the DITA-OT docs about creating plugins and creating JAR files for them, and I followed some of the findings from Google, but can't figure out why this is happening.

Here's a simplified example showing behavior.

Here is plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<plugin id="com.example.test.import">
  <feature extension="dita.conductor.lib.import" file="ztest.jar" />
  <feature extension="dita.xsl.xhtml"            file="testimport.xsl" />
  <feature extension="dita.xsl.xslfo"            file="testimport.xsl" />  
</plugin>

Here is the XSL stylesheet testimport.xsl:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:z="java:ztest.Ztest"
  version="2.0" >

    <xsl:template match="concept">
        <xsl:call-template name="test" 
                           use-when="function-available('z:zmsg')">
            <xsl:with-param name="txt" 
                            select="z:zmsg()" />
        </xsl:call-template>

        <xsl:call-template name="fail" 
                           use-when="not(function-available('z:zmsg'))" />
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template name="test">
        <xsl:param name="txt" />
        <xsl:message>xxx txt from function z:zmsg = <xsl:value-of select="$txt"/></xsl:message>
  </xsl:template>

  <xsl:template name="fail">
        <xsl:message>xxx Function z:zmsg is not available.</xsl:message>
  </xsl:template>

</xsl:stylesheet>

I am using DITA-OT 2.1.2. DITA-OT is not changed (except for my plugin). No custom XSL for formatting. For the DITA source, I use the file in the DITA-OT sample directory. This is a simple concept:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN"
 "../../dtd/technicalContent/dtd/concept.dtd">
<concept id="lawnmowerconcept" xml:lang="en-us">
  <title>Lawnmower</title>
  <shortdesc>The lawnmower is a machine used to cut grass in the yard.</shortdesc>
  <conbody><p>Lawnmowers can be electric, gas-powered, or manual.</p></conbody>
</concept>

I tried to build the dita command and the ant command from the command line.

dita XHTML:

c:\dita\dita-ot\bin>dita -i ../samples/concepts/lawnmower.xml -f xhtml -o ../samples/atest -v

dita PDF:

c:\dita\dita-ot\bin>dita -i ../samples/concepts/lawnmower.xml -f pdf -o ../samples/atest -v

ant XHTML:

C:\dita\dita-ot\bin>ant -f ..\build.xml -Dargs.input=samples\concepts\lawnmower.xml -Dtranstype=xhtml -Doutput.dir=samples\atest

ant PDF:

C:\dita\dita-ot\bin>ant -f ..\build.xml -Dargs.input=samples\concepts\lawnmower.xml -Dtranstype=pdf -Doutput.dir=samples\atest    

transtype xhtml, "txt from function z: zmsg":

dita.inner.topics.html.common:
     [xslt] Transforming into c:\dita\dita-ot\samples\atest
     [xslt] Processing c:\tmp\temp20151105150253420\lawnmower.xml to c:\dita\dita-ot\samples\atest\lawnmower.html
     [xslt] Loading stylesheet c:\dita\dita-ot\plugins\org.dita.xhtml\xsl\dita2xhtml.xsl
     [xslt] xxx txt from function z:zmsg = String from Ztest.zmsg
     ...

transtype pdf2, "Function z: zmsg is not available":

transform.topic2fo.main:
     [xslt] Processing c:\tmp\temp20151105143733996\stage1a.xml to c:\tmp\temp20151105143733996\stage2.fo
     [xslt] Loading stylesheet c:\dita\dita-ot\plugins\org.dita.pdf2\xsl\fo\topic2fo_shell_fop.xsl
     [xslt] xxx Function z:zmsg is not available.
     ...

, Java Ztest zmsg():

package ztest;
public class Ztest {
    public static void main(String[] args) {
        System.out.println(zmsg());
    }    
    public static String zmsg() {
        return "String from Ztest.zmsg";
    }
}

, , .

+4

Source: https://habr.com/ru/post/1615654/


All Articles