Passing parameters into XSLT transform

204 views
Skip to first unread message

Schildbach, Wolfgang

unread,
Aug 20, 2021, 4:09:57 AM8/20/21
to dita-o...@googlegroups.com

Hello friendly list,

 

I am stuck on an issue that I could need some help with. I am trying to make part of an existing plugin configurable by providing arguments/parameters to it that can be set on the dita-ot command line or in project files.

 

There are several places where parameters can be defined, and I am utterly confused about how they interact, and from where to where these parameters can then be passed. I believe I implemented everything as per the dita-ot documentation, but right now, no matter what I do, the parameters never seems to get to the transform – whether that is a default I set in plugin.xml, or an expression in params.xml, a command line parameter or a project file. Something however *does* get to the transform, but I don’t understand where that is coming from.

 

Before I go further, I also should say that I am fairly shaky about the dita-ot concepts of extension points, integration etc. so my language below may not be quite correct.

 

Here is what I have. A plugin com.dolby.word-etsi (“new plugin”) that extends on another plugin, com.elovirta.ooxml (“base plugin”). The new plugin inserts parameters into an extension point com.elovirta.ooxml.param defined in the base plugin. That extension point on the base plugin is in an xslt step calling “document.xsl”. The base document.xsl, also gets overridden in the new plugin with a new document.xsl (which ends up importing the base document.xsl).

 

In the new plugin, I define an additional parameter ooxml.live-links. I am expecting this parameter to show up as xsl:param inside the new document.xsl.

 

What happens instead is that something seems to pass in a parameter. I (think) I know this because I have made the parameter in the new document.xsl mandatory:

  <xsl:param name="ooxml.live-links"       select="true()"            as="xs:boolean"/>

… and am not getting an error. Also, the overridden parameter seems to be false() or false – I am printing it out.

 

  1. What part of dita-ot is setting my parameter to false, and why?
  2. Which files do I need to touch and insert a parameter definition? I have updated the new plugin.xml, the new params.xml, and the new document.xsl. Anywhere else?
  3. Can you spot any deficiencies in the code below?

 

Thanks for any and all insight you can provide on this.

 

  • Wolfgang

 

Code:

  1. com.dolby.word-etsi/plugin.xml :

 

<plugin id="com.dolby.word-etsi">
 
<require plugin="com.elovirta.ooxml"/>
 
<extension-point id="depend.word-etsi.merge.post" name="Target after merge process"/>
 
<transtype name="word-etsi" desc="ETSI Word">
   
<param name="debug" desc="Debug processing" type="enum">
     
<val>true</val>
     
<val default="true">false</val>
   
</param>
   <!—inserted this one -->

    <param name="ooxml.live-links" desc="make links live links" type="enum">
     
<val>true</val>
     
<val default="true">false</val>
   
</param>
 
</transtype>

[…]

 

  <feature extension="com.elovirta.ooxml.param" file="params.xml"/>

[…]

 

ooxml.live-links is the new parameter that I would like to use in XSLT.

 

  1. com.dolby.word-etsi/params.xml:

 

<params>
 
<param name="debug" expression="${debug}" type="BOOLEAN"/>
 
<param name="user.input.dir.uri" expression="${user.input.dir.uri}"/>
 
<param name="ooxml.live-links" expression="${ooxml.live-links}" type="BOOLEAN"/>
</params>

  1. com.elovirta.ooxml/build_template.xml:

 

[…]

    <property name="document.xsl" location="${docx.dir}/word/document.xsl"/>
   
<xslt style="${document.xsl}"
          in="${clean.input.file}"
          out="${dita.temp.dir}/docx/word/document.xml"
          force="true">
     
<dita:extension id="com.elovirta.ooxml.param" behavior="org.dita.dost.platform.InsertAction"/>
     
<param name="image.dir" expression="${image.dir}"/>
     
<!--param name="indent-base" expression="${indent-base}"/-->
     
<param name="template.dir" expression="${dotx.dir.uri}"/>
     
<param name="input.dir.url" expression="${user.input.dir.url}"/>
     
<xmlcatalog refid="dita.catalog"/>
   
</xslt>

[…]

 

  1. document.xml itself gets replaced by my plugin’s document.xsl, which imports com.elovirta.ooxml:docx/word/document.xsl.

com.dolby.word-etsi/…/document.xsl :

 

  <xsl:param name="ooxml.live-links"       select="true()"            as="xs:boolean"/>
 
<xsl:param name="ooxml.live-links.topic" select="$ooxml.live-links" as="xs:boolean?"/>
 
<xsl:param name="ooxml.live-links.fig"   select="$ooxml.live-links" as="xs:boolean?"/>
 
<xsl:param name="ooxml.live-links.fn"    select="$ooxml.live-links" as="xs:boolean?"/>
 
<xsl:param name="ooxml.live-links.table" select="$ooxml.live-links" as="xs:boolean?"/>
 
<xsl:param name="ooxml.live-links.bib"   select="$ooxml.live-links" as="xs:boolean?"/>
 
<xsl:param name="ooxml.live-links.li"    select="$ooxml.live-links" as="xs:boolean?"/>

 
<xsl:import href="plugin:com.elovirta.ooxml:docx/word/document.xsl"/>

 

Schildbach, Wolfgang

unread,
Aug 24, 2021, 4:52:59 AM8/24/21
to dita-o...@googlegroups.com

Just checking whether this email went out to the list.

 

  • Wolfgang

--
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.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/CO6PR06MB7329562AB57227B571A616D2AFC19%40CO6PR06MB7329.namprd06.prod.outlook.com.

Radu Coravu

unread,
Aug 24, 2021, 5:12:23 AM8/24/21
to Schildbach, Wolfgang, dita-o...@googlegroups.com
Hi Wolfgang,

As some quick suggestions, if you look in the "com.elovirta.ooxml/build.xml" build file after you run the integrator for "ooxml.live-links" you will see how the ANT parameter is passed as an XSLT parameter. That "type="BOOLEAN"" might not work, I have never used it myself so I do not have experience with it, so my advice to you would be to define "ooxml.live-links" in the XSLT as having string type, pass the "true" or "false" string value to it and then check it in the XSLT.

Regards,
Radu

Schildbach, Wolfgang

unread,
Aug 31, 2021, 1:16:38 PM8/31/21
to Radu Coravu, dita-o...@googlegroups.com

Hi Radu,

 

Thanks very much for your suggestions. This helped, I got parameters to work as expected. I had a number of hickups, listing them here for the benefit of others that might try the same thing.

  1. Make sure that every time you change something in these files, you re-run the integrator (dita –install)
  2. Try with strings first (as suggested by Radu below). Booleans probably go through some sort of translation; this does not ease debugging. Also, when using strings, it is easy to temporarily put other values in (like “uninitialized”)
  3. Test with the dita command line, rather than with OyxgenXML. At least in my version, I had to restart OxygenXML after making changes to plugins run through preferences->Document type association which can be confusing when debugging.

 

Again, thanks a bunch!

 

Regards,

  • Wolfgang

Radu Coravu

unread,
Sep 1, 2021, 12:52:55 AM9/1/21
to Schildbach, Wolfgang, dita-o...@googlegroups.com
Hi Wolfgang,

I'm glad this works for you. A couple of remarks:

Possible for (2) in order to make this work the value for the parameter would have been needed to be passed as the function "true()" because the literal "true" is just a string.

For (3) Oxygen runs the publishing by invoking the DITA Open Toolkit that has been configured in the Preferences->DITA page. It does scan the DITA Open Toolkit folder for parameters to present when creating or modifying transformation scenarios. If it does not know a plugin was added or that parameters have been added to it because you run the integrator from the command line, then Oxygen will not present those parameters when creating a transformation scenario.
Oxygen has its own way of running the DITA OT integrator from inside the application:
If you run the integration from inside the application, Oxygen will know to re-scan the DITA Open Toolkit and collect the new plugin types and parameter names.

Regards,
Radu
Reply all
Reply to author
Forward
0 new messages