passing param to xslt in dita ot
Posted: Thu Jan 09, 2025 4:26 pm
Hi all,
Im trying to use a custom plugin for pdf. I've been following Dita for Print book. But nothing I found is helping with this issue.
I want to have a footer that displays security clearance level. I would like this specified as a parameter in the command line.
So adding -Dseclevel=internal will give me "this document is for internal use". This text is in a localization file en.xml.
-Dseclevel=restricted will give me "this document is restricted" etc etc.
As of right now, the only way it seems to work is if I edit the base build.xml file directly, which is what I do not want.
I would need to add this parameter
into
File:
\dita-ot-4.2.4\plugins\org.dita.pdf2\build.xml
under
I want to avoid this. I thought by having an insertParameters file with the feature extension in the plugin would work but no.
Here is my setup in the custom plugin folder
command line:
plugin:
integrator:
insertParameters.xml
I add more details below (which I will append to my parent post)
In my plugin folder, I have my attr and my xsl.
cfg > common
> fo > attrs
> xsl
Looking at my fo > xsl folder:
I have a custom.xsl
static-content.xsl is where I have my footer.
within it:
I use the getVariable to look up the value I have in an en.xml file.
Im trying to use a custom plugin for pdf. I've been following Dita for Print book. But nothing I found is helping with this issue.
I want to have a footer that displays security clearance level. I would like this specified as a parameter in the command line.
So adding -Dseclevel=internal will give me "this document is for internal use". This text is in a localization file en.xml.
-Dseclevel=restricted will give me "this document is restricted" etc etc.
As of right now, the only way it seems to work is if I edit the base build.xml file directly, which is what I do not want.
I would need to add this parameter
Code: Select all
<param name="seclevel" expression="${seclevel}" if="seclevel"/>
into
File:
\dita-ot-4.2.4\plugins\org.dita.pdf2\build.xml
under
Code: Select all
<target name="transform.topic2fo.main">
<pipeline>
<xslt>
[b]<custom parameter here>[/b]
Here is my setup in the custom plugin folder
command line:
Code: Select all
dita -imap.ditamap -f print-pdf -Dseclevel=restricted -d -l log.xml -v
Code: Select all
<plugin id="auto_pdf" >
<require plugin="org.dita.pdf2"/>
<transtype name="print-pdf" extends="pdf" desc="PDF on A4 paper"/>
<feature extension="dita.transtype.print" value="print-pdf"/>
<feature extension="ant.import" file="integrator.xml"/>
<feature extension="dita.conductor.pdf2.param" file="insertParameters.xml"/>
</plugin>
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<project>
<target name="dita2print-pdf"
depends="dita2print-pdf.init,
dita2pdf2">
</target>
<target name="dita2print-pdf.init">
<property name="customization.dir"
location="${dita.plugin.auto_pdf.dir}/cfg"/>
</target>
</project>
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<dummy>
<param name="seclevel" expression="${seclevel}" if="seclevel"/>
</dummy>
I add more details below (which I will append to my parent post)
In my plugin folder, I have my attr and my xsl.
cfg > common
> fo > attrs
> xsl
Looking at my fo > xsl folder:
I have a custom.xsl
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:import href="../layout-masters.xsl"/>
<xsl:import href="commons.xsl"/>
<xsl:import href="root-processing.xsl"/>
<xsl:import href="static-content.xsl"/>
<xsl:import href="front-matter.xsl"/>
<xsl:import href="topic.xsl"/>
<xsl:import href="tables.xsl"/>
</xsl:stylesheet>
within it:
Code: Select all
<fo:table-cell text-align="center">
<fo:block font-size="8pt" font-weight="bold" color="black">
<xsl:choose>
<xsl:when test="$seclevel">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="concat('securitylevel ', $seclevel)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:with-param name="id" select="'securitylevel default'"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>