Page 1 of 1
Display Ant property value in generated PDF
Posted: Tue Sep 24, 2013 1:47 am
by uprichard
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
Re: Display Ant property value in generated PDF
Posted: Tue Sep 24, 2013 10:13 am
by Radu
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
Re: Display Ant property value in generated PDF
Posted: Tue Sep 24, 2013 6:48 pm
by uprichard
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
Re: Display Ant property value in generated PDF
Posted: Tue Sep 24, 2013 8:07 pm
by uprichard
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?
Re: Display Ant property value in generated PDF
Posted: Wed Sep 25, 2013 1:26 am
by uprichard
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
Re: Display Ant property value in generated PDF
Posted: Wed Sep 25, 2013 8:22 am
by Radu
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