DITA-OT 2.0: Overriding the "outputFile" parameter not working

99 views
Skip to first unread message

guillaume SEJOURNE

unread,
Aug 19, 2015, 5:22:57 AM8/19/15
to DITA-OT Users
Hi,

I'm using DITA-OT 2.0, with a plugin that extends the PDF2 transtype + XEP as PDF formatter.

I'm currently trying to set the PDF output file name, and reading the plugins/org.dita.pdf2/build_xep.xml file,
I found this section:

<condition property="outputFile" value="${dita.map.output.dir}/${outputFile.base}${xsl.formatter.ext}">
    <not><isset property="outputFile"/></not>
</condition>

So, I simply added a 
<param name="outputFile" value="${output.dir}/my_custom_filename.pdf"/>
param to the build target definition.

It has no effect, as far as I can see, and the outputFile param does not seem to be set prior to the condition eval.

Just want to make sure I'm doing it the way it should before filing a bug.

Thanks,

-Guillaume

Kendall Shaw

unread,
Aug 19, 2015, 2:15:23 PM8/19/15
to DITA-OT Users
Hi,

I don't follow what you mean when you say that you added a param to the build target. There aren't param elements in ant build targets. I can think of a few things that you might mean, but I am unsure.

I suspect it is not this, but if you always want the output file to have the same  name "my_custom_filename.pdf" and XEP is invoked from build_xep.xml, you can modify the condition statement, e.g.:

<condition property="outputFile" value="${dita.map.output.dir}/my_custom_filename.pdf">
    <not><isset property="outputFile"/></not>
</condition>

otherwise, some possible problems are:

1. ant properties are "immutable" (can only be set once), except that there is the new "local" task which gets around that, e.g.:

<condition property="outputFile" value="${dita.map.output.dir}/${outputFile.base}${xsl.formatter.ext}">
      <not><isset property="outputFile"/></not>
 </condition>
 <local name="outputFile"/>
 <property name="outputFile" value="mutant.pdf"/>

2. param appears in parameter files which pass parameters to XSL, which would mean that outputFile does nothing, probably.

If I'm missing what the problem is, maybe the list needs more specifics about what was changed.

Kendall
--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

guillaume SEJOURNE

unread,
Aug 19, 2015, 2:35:18 PM8/19/15
to DITA-OT Users
OK, I'll try to be more specific:
- in the build file, I want to pass a dynamically computed PDF filename, e.g 
<property name="outputFile" value="${pdf.output.dir}/${product}_${version}.pdf"/>
which I expected would be read by the ant condition.

- I don't want to hardcode it in the OT, as the pdf name is dynamically generated for each pdf.
- As much as possible, I don't want to add mods to the OT itself: I want to stick to custom plugin and build file modifications only.

Question however: If the "outputFile" property is static, I really don't understand what the condition test within the ant build_xep.xml file does...

Thanks,

-Guillaume

Kendall Shaw

unread,
Aug 19, 2015, 2:59:53 PM8/19/15
to DITA-OT Users
The condition checks if the property is already set. If it is not set, it sets the property.

So, one way it could be done is to have a script outside of DITA-OT that passes the outputFile property assignment to ant, e.g.

unix: ant -DoutputFile=${product}_${version}.pdf -Dargs.input=samples/taskbook.ditamap -Dtranstype=pdf
windows: ant -DoutputFile=%product%_%version%.pdf -Dargs.input=samples/taskbook.ditamap -Dtranstype=pdf

or

unix: dita -f pdf -i samples/taskbook.ditamap -DoutputFile=${product}_${version}.pdf
windows: dita -f pdf -i samples/taskbook.ditamap -DoutputFile=%product%_%version%.pdf

Otherwise, if you are setting outputFile right before XEP is invoked, you can use the local task to change outputFile. If that won't fit with the rest of the logic, then I would need to know more.

Kendall


guillaume SEJOURNE

unread,
Aug 20, 2015, 3:47:50 AM8/20/15
to DITA-OT Users
OK, this is what I ended up doing, based on your suggested fixes:

- I copied the transform.fo2pdf.xep target from the DITA-OT org.dita.pdf2 plugin into my own plugin, which then acts as an override
- I added the following local property definition to it like as you suggested:
<condition property="outputFile" value="${dita.map.output.dir}/${outputFile.base}${xsl.formatter.ext}">
      <not><isset property="outputFile"/></not>
</condition>
<local name="outputFile"/>
<property name="outputFile" value="${output.dir}/${pdf.file.name}"/>


And it works as expected.

I still find it weird, and not super user friendly, that you can't simply pass the outputFile property in the build file, just like you do with output.dir, pdf.formatter, etc.

Kendall Shaw

unread,
Aug 20, 2015, 10:51:14 AM8/20/15
to DITA-OT Users
I should have said that you can also set the property before the condition statement, sorry. In that case it would already be set and the condition statement wouldn't set it.

So, in your plugin before transform.fo2pdf.xep ends up being invoked.

Kendall
--
Reply all
Reply to author
Forward
0 new messages