Display Ant property value in generated PDF

uprichard
Posts: 9
Joined: Tue Sep 24, 2013 1:23 am

Display Ant property value in generated PDF

Post by uprichard » Tue Sep 24, 2013 1:47 am

I am using a custom build script that holds the revision number of the documentation. I want to be able to build the PDF and have the revision number displayed on the front page.

What modifications do I need to be able to display an ANT property in the PDF document?

I managed to make it work for data values set in the ditamap i.e

Code: Select all

ditamap:
<data name="revision" value="v1"

fo/xsl/custom.xsl:
<xsl:value-of select="$map/data[@name='revision']/@value"/>
But how to do it for an ANT property?
If this is not easy then adding the current date to the front page may be enough

Thanks

Radu
Posts: 6980
Joined: Fri Jul 09, 2004 5:18 pm

Re: Display Ant property value in generated PDF

Post by Radu » Tue Sep 24, 2013 10:13 am

Hi Nigel,

In my opinion the approach with having the release number in the DITA Map and then reading it in the XSLT code is a good approach (and easier to implement as well).
Anyway, if you want to have the parameter in the custom build file (which eventually calls the DITA OT build file), you would need to also specify that extra parameter to the ANT <xslt> task used to invoke the XSLT code which parses the merged XML document. Then in your custom.xsl you would declare the xsl:param and its value will come from the build files which invoke the XSLT code.
For example you can look in this build file:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/plugins/org.dita.pdf2/build.xml

at the XSLT task:

Code: Select all

<xslt style="${temp.transformation.file}" in="${dita.temp.dir}/stage1a.xml" out="${dita.temp.dir}/stage2.fo">
which sets a lot of parameters for the stylesheets. You would probably need to send one extra parameter, the one with the value specified in your custom build file.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

uprichard
Posts: 9
Joined: Tue Sep 24, 2013 1:23 am

Re: Display Ant property value in generated PDF

Post by uprichard » Tue Sep 24, 2013 6:48 pm

So I would have to change the files under Oxygen Framework, no way to override in customization directory?

Is it possible to get the Current Date / Time placed in the ditmap as a <data> value? In that every time that the document is built the value will be replaced with the current date / time, without the author needing to update the value. I could use that instead of a version number

uprichard
Posts: 9
Joined: Tue Sep 24, 2013 1:23 am

Re: Display Ant property value in generated PDF

Post by uprichard » Tue Sep 24, 2013 8:07 pm

I noticed in the file you referenced there is a line

Code: Select all

<param name="variableFiles.url" expression="${variable.file.url}"/>
Could that be used in some way? i.e. point it to a file that is generated from the ANT script?

uprichard
Posts: 9
Joined: Tue Sep 24, 2013 1:23 am

Re: Display Ant property value in generated PDF

Post by uprichard » Wed Sep 25, 2013 1:26 am

Found a solution that works well. I have an xml file that I load into the custom xsl file. The xml file loads the values form a properties file that I generate from the ANT build file and then I can use the values as variables in the xsl file. No need to change any files in the framework directory.

Now to modify the webhelp output

Radu
Posts: 6980
Joined: Fri Jul 09, 2004 5:18 pm

Re: Display Ant property value in generated PDF

Post by Radu » Wed Sep 25, 2013 8:22 am

Hi Richard,

Yes, that is an interesting approach as well, thanks for sharing it.
About this question:
Is it possible to get the Current Date / Time placed in the ditmap as a <data> value?
You could have generated the current date directly in the XSLT script using XSLT 2.0 functions like current-dateTime().

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply