2

I'm working on (my first) DITA project using Oxygen, and invoking FOP to generate PDF output. Trying to figure out what everything along the chain does, where the chain is: document -> element -> class -> class template definition in .xsl -> attribute settings in attr.xsl

I'm doing fine with all except the class template definition, which invariably seems to involve the line: <xsl:call-template name="commonattributes"/>

Where is that template stored and how is it configured?

(I found a lot of questions that show the correct syntax for invoking this template, or others, but not what doing this actually means.)

jelovirt
  • 5,844
  • 8
  • 38
  • 49
M. Rivera
  • 21
  • 1
  • 1
    The expression calls the template with name commonattributes – Madeyedexter Feb 01 '17 at 17:37
  • 1
    "*Where is that template stored ...*" It's stored either in the same stylesheet that calls it or in another stylesheet that your stylesheet includes or imports. -- "*... and how is it configured?*" We don't see it, so we have no way of telling. – michael.hor257k Feb 01 '17 at 17:42
  • Thank you! From this I finally figured out what to search for. Mischief managed. – M. Rivera Feb 01 '17 at 18:05
  • @M.Rivera: If you have found a solution to you own problem, let SO participate by posting an answer to you own question. – zx485 Feb 01 '17 at 18:50
  • I can't explain it well enough to compose an answer! But the answer below is great. – M. Rivera Feb 01 '17 at 19:38

2 Answers2

2

I assume you are using the DITA Open Toolkit (OT). In version 2.2.4 of the OT this named template is in the following file:

DITA-OT/plugins/org.dita.pdf2/xsl/fo/commons.xsl

This template applies other templates to some common attributes like @id. I doubt that you will need to "configure" it, and it does not have any parameters. Here it is:

<!-- Process common attributes -->
<xsl:template name="commonattributes">
  <xsl:apply-templates select="@id"/>
  <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')] |
                               *[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="flag-attributes"/>
</xsl:template>
markg
  • 424
  • 3
  • 10
0

XSLT templates can be matched against the input document when written with a @match attribute or called procedurally when written with a @name attribute.

You've encountered a procedural call of a template named commonattributes, which would be defined directly within your XSLT file or indirectly via xsl:include or xsl:import.

Without seeing the definition of commonattributes we can easily guess that its purpose is to consolidate the definition of a common set of attributes to a single location so that they be centrally managed and applied via xsl:call-template to multiple elements generated by your XSLT. This is a common pattern in XSLT.

kjhughes
  • 106,133
  • 27
  • 181
  • 240