Make preprocessing depenend on transtype

21 views
Skip to first unread message

Jörn Donges

unread,
Mar 21, 2024, 10:16:32 AMMar 21
to DITA-OT Users
Dear community

I need to preprocess some ditamaps before the topics are pulled and merged by the Dita OT.
I wrote a little plugin which extends the preprocess.pre and post extension points.

<plugin id="com.my.preprocess">
  <require plugin="com.oxygenxml.pdf.css"/>
  <feature extension="ant.import" file="build.xml"/>
  <feature extension="depend.preprocess.pre" value="my-preprocess"/>
  <feature extension="depend.preprocess.post" value="my-postprocess"/>
</plugin>

This works but the preprocessing now is applied to all transformations regardless of type. I dont want this, I only need it for certain ditamaps, so my idea was to define a new transtype.
  <feature extension="dita.transtype.print" value="my-preprocessed-pdf"/>
  <transtype name="my-preprocessed-pdf" extends="pdf-css-html5" />
and defined in build.xml an ant target

 <target name="dita2my-preprocessed-pdf" depends="dita2pdf-css-html5">

But from here on I don't know what to do. How do I connect the targets?

I want the "my-preprocess" and "my-postprocess" extensions only applied when the transtype is "my-preprocessed-pdf"

Any help is much appreciated.
Regards Jörn




Chris Papademetrious

unread,
Mar 23, 2024, 8:05:48 AMMar 23
to DITA-OT Users
Hi Jörn,

I do this by importing the TRANSTYPE Ant property into the preprocessing XSLT step. Here is a discussion post with example DITA-OT plugin showing how to do this:


 - Chris

Nicolas Delobel

unread,
Mar 24, 2024, 9:36:55 AMMar 24
to DITA-OT Users
Hi Jörn,

To manage your use case I think you can use something like this in your ant script :  
<condition property="isMyTranstype">
        <and>
            <matches pattern="my-preprocessed-pdf" string="${transtype}"/><!-- test transtype -->
            <matches pattern="\.(ditamap|map)$" string="${args.input}"/><!--test  input extension file -->
        </and>
 </condition>
   
 <target name=" my-preprocess " if="${isMyTranstype}">
...
</target>

Let me know if it works.

Regards,
Nicolas

Jörn Donges

unread,
Mar 25, 2024, 7:47:14 AMMar 25
to DITA-OT Users
Hi Chris and Nicolas, thanks for your answers!

Both of your suggested ways worked well.
I had previously tried to evaluate the ${transtype} property directly in my XSLT without the insert script so now I know why this did not work.
I guess this will will be useful in the future.
However I will implement it via the condition in the ant script because I don't have to touch the XSLT then.
Would it be better to post future questions on Github instead of here?

Regards 
Jörn
Reply all
Reply to author
Forward
0 new messages