newb question; custom parameters

Oxygen general issues.
peterd
Posts: 3
Joined: Tue Apr 18, 2023 4:43 am

newb question; custom parameters

Post by peterd »

Real dumb question, I just would like someone to confirm Im digging in the right direction.
Our DITA-PDF customization setup was done by someone who is no longer around and admittedly Im catching up (and also a XSL noob). We do a bit of funky chicken in our customization.dir/fo/xsl/custom.xsl file:

Code: Select all

<xsl:variable name="customizationVarsFile" select="concat($customizationDir.url, 'common/vars/', $locale, '.xml')"/>
From there we nab variables for our transforms from customization.dir/fo/common/vars/$local.xml (customizationVarsFile) and its great. But the structure for our document repository is based around <product>\<document>\<locale> and right now there's a customization folder for each document which is silly. I'd like to change things so Im using a common Customization folder for all documents in <product> or even across all products. i.e. instead of using
<product>\<document>\Customization\common\vars\<locale>.xml
i'd like to use
<product>\Customization\common\vars\<document><locale>.xml
or just specify the specific vars file I want to use explicitly as a parameter and not have it built using existing other parameters. To get the additional parameter is this plugin time or is there a thing Im missing?
Radu
Posts: 9423
Joined: Fri Jul 09, 2004 5:18 pm

Re: newb question; custom parameters

Post by Radu »

Hi,

I agree with your goal of trying to have one customization PDF folder instead of multiple ones.

If you open this build file "DITA-OT3.x/plugins/org.dita.pdf2/build.xml' and look for this ANT build target:

Code: Select all

<target name="transform.topic2fo.main">
you will see that it calls the <xslt> task with a number of parameters including customizationDir.url. All these parameter values should be accessible directly to you in your custom.xsl. Maybe one of these params like "input.dir.url" may be useful to you. You can use xsl:message's in the XSLT stylesheet to output the value of each parameter and look in the console output to see what values they have.

Customization folders kept outside of the DITA OT folder are kind of deprecated and the preferred alternative is to create a DITA Open Toolkit plugin which contributes a customization folder.
About adding an extra custom build parameter, this can be done but only if the customization is bundled as a DITA Open Toolkit plugin instead of being external to the DITA Open Toolkit folder.
For example the DITA OT plugin we had for our user's guide before we switched to using CSS for PDF customization:
https://github.com/oxygenxml/com.oxygenxml.pdf2.ug
In the plugin.xml we refer to this XML file containing extra PDF params:

Code: Select all

<feature extension="dita.conductor.pdf2.param" file="pdf2ExtensionParameters.xml"/> 
https://github.com/oxygenxml/com.oxygen ... meters.xml

and these ANT parameters are passed to the XSLT stylesheets.

Also a link to the topic about PDF customization in the DITA OT docs:
https://www.dita-ot.org/dev/topics/pdf- ... ion_folder

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
peterd
Posts: 3
Joined: Tue Apr 18, 2023 4:43 am

Re: newb question; custom parameters

Post by peterd »

Thanks for your answer Radu - and also thanks for answering questions that are really more about the DITA-OT than oxygen.

Ok, when you said:
If you open this build file "DITA-OT3.x/plugins/org.dita.pdf2/build.xml' and look for this ANT build target:
<target name="transform.topic2fo.main">
you will see that it calls the <xslt> task with a number of parameters including customizationDir.url
Well, that worked - I should point out that I am using oXygen 20.1 which shipped with DITA-OT 2.5.4 (this will be relevant in a second). I checked in the pdf2 plugin's build.xml in the transform.topic2fo.main target and sure enough, there was a parameter declaration for $mappath:

Code: Select all

 <param name="mappath" expression="${args.input}"/>  
which just bundles up the input file in question into an xsl parameter. So, $mappath WAS available in my xsl - great - essentially how I use that is I strip off the path and extension of the ditamap file and look for an XML file with the same name to obtain some variables I want (which I don't want to dump in the \Customization\common\vars\<locale>.
The problem THEN was I discovered that our build environment was setup with DITA-OT 3.6. That mappath parameter was removed sometime between 2.5.4 and 3.6. So then, of course I start getting (when I go to transform my document with the DITA-OT 3.6 not the 2.5.4 in oXygen):

Code: Select all

 [pipeline] Static error at char 8 in xsl:value-of/@select on line 36 column 50 of custom.xsl:
 [pipeline]   XPST0008: Variable mappath has not been declared (or its declaration is not in scope)
errors as one would expect. THEN I tried putting that mappath parameter declaration back into the DITA-OT 3.6's build.xml but whatever I try I cannot get that parameter mappath to be accessible to my xsl.
AND, I can't use base-uri or document-uri to obtain the inputFile's path+filename because at this point the input file is a renamed file in DITA-OT's temp folder. I need the URL to the _original_ ditamap file.
So - Im running through the DITA-OT "quick setup to create a pdf plugin" tutorial to see if I can reintroduce it that way. OR, if you know of another way to obtain, in xslt the filename of the ditamap that is being transformed?
peterd
Posts: 3
Joined: Tue Apr 18, 2023 4:43 am

Re: newb question; custom parameters

Post by peterd »

Nope.. that isn't working. I created the simple 2 file plugin covered in
https://www.dita-ot.org/dev/topics/plug ... arams.html
to pass in a parameter called STEVE:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://www.dita-ot.org/rng/plugin.rnc" type="application/relax-ng-compact-syntax"?>

<plugin id="com.virtek.param">
    <require plugin="org.dita.pdf2"/>
    <feature extension="dita.conductor.pdf2.param" file="insertParameters.xml"/>
</plugin>
and insertParameters.xml:

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<dummy xmlns:if="ant:if" xmlns:unless="ant:unless">
    <!-- Any Ant code allowed in xslt task is possible. Example: -->
    <param name="STEVE" expression="${args.input}"
        if:set="args.input"/>
    
</dummy>
peterd
Posts: 3
Joined: Tue Apr 18, 2023 4:43 am

Re: newb question; custom parameters

Post by peterd »

Actually never mind.
What I was TRYING to do was get ditamap specific metadata variables INTO the PDF transforms. We used to do this by dumping them into \Customization\common\vars\<locale>.xml, but that paradigm breaks down if you're trying to use the same customization folder for multiple documents (unless you do some external doctoring of that vars.xml file between documents). So what I was trying to do was use the inputFile (the ditamap passed to dita-ot), strip off the path and the extension and use a similarly named xml file in the same location of the ditamap.

What I just realized was I can just dump the parameters I need into the ditamap iteself and query for them in the transform like:

Code: Select all

   <xsl:variable name="title.images">
        <xsl:value-of select="$map/keydef[@keys='title.images']/*/*/keyword/node()"/>
    </xsl:variable>
    
where in the ditamap these are keyrefs:

Code: Select all

  <keydef keys="title.images">
        <topicmeta>
            <keywords>
                <keyword>.\foo.jpg</keyword>
            </keywords>
        </topicmeta>
    </keydef>
Works.
But thanks for the feedback anyway Radu.
Last edited by peterd on Thu Apr 20, 2023 9:09 pm, edited 1 time in total.
Radu
Posts: 9423
Joined: Fri Jul 09, 2004 5:18 pm

Re: newb question; custom parameters

Post by Radu »

Hi,
Thanks for updating the forum thread, your solution makes sense.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply