Topics

FEEDBACK REQUESTED: control over specialized figure and table numbering #DITA-OT #specialization

Chris Papademetrious
 

Hi all,

I'm working on a plugin that provides independent numbering for specialized figures and tables. I'd like to make this functionality publicly available via either a plugin or a DITA-OT enhancement.

Let's say you have figure specializations mybigfigure and mysmallfigure and table specializations mybigtable and mysmalltable. By default, they are numbered and labeled like this by the HTML5 transformation:

mybigfigure: Figure 1
mysmallfigure: Figure 2
mybigfigure: Figure 3
mysmallfigure: Figure 4

mybigtable: Table 1
mysmalltable: Table 2
mybigtable: Table 3
mysmalltable: Table 4

With my enhancement, you can define per-specialization label strings:

  <str name="Figure-mybigfigure">Big Figure</str>
  <str name="Figure-mysmallfigure">Small Figure</str>
  <str name="Table-mybigtable">Big Table</str>
  <str name="Table-mysmalltable">Small Table</str>

and the HTML5 transformation would label them as follows:

mybigfigure: Big Figure 1
mysmallfigure: Small Figure 1
mybigfigure: Big Figure 2
mysmallfigure: Small Figure 2

mybigtable: Big Table 1
mysmalltable: Small Table 1
mybigtable: Big Table 2
mysmalltable: Small Table 2

My question is, is having a single on/off switch that affects all figure and table specializations good enough? Or would anyone need to have some -- but not all -- specializations have independent numbering and labels?

Thanks!

 - Chris

ekimber@contrext.com
 

I would want to have a choice of which figure or table specializations participate in a particular numbering stream as not all specializations will be motivated by a need for different numbering.

This (and pretty much anything that isn't a bug fix to existing base OT code) should be packaged as a plugin.

Cheers,

E.

--
Eliot Kimber
http://contrext.com


On 1/1/20, 7:51 AM, "Chris Papademetrious" <dita-users@groups.io on behalf of chrispitude@...> wrote:

Hi all,

I'm working on a plugin that provides independent numbering for specialized figures and tables. I'd like to make this functionality publicly available via either a plugin or a DITA-OT enhancement.

Let's say you have figure specializations mybigfigure and mysmallfigure and table specializations mybigtable and mysmalltable. By default, they are numbered and labeled like this by the HTML5 transformation:

mybigfigure: Figure 1
mysmallfigure: Figure 2
mybigfigure: Figure 3
mysmallfigure: Figure 4


mybigtable: Table 1
mysmalltable: Table 2
mybigtable: Table 3
mysmalltable: Table 4

With my enhancement, you can define per-specialization label strings:

<str name="Figure-mybigfigure">Big Figure</str>
<str name="Figure-mysmallfigure">Small Figure</str>
<str name="Table-mybigtable">Big Table</str>
<str name="Table-mysmalltable">Small Table</str>

and the HTML5 transformation would label them as follows:

mybigfigure: Big Figure 1
mysmallfigure: Small Figure 1
mybigfigure: Big Figure 2
mysmallfigure: Small Figure 2


mybigtable: Big Table 1
mysmalltable: Small Table 1
mybigtable: Big Table 2
mysmalltable: Small Table 2

My question is, is having a single on/off switch that affects all figure and table specializations good enough? Or would anyone need to have some -- but not all -- specializations have independent numbering and labels?

Thanks!

- Chris

Jarno Elovirta
 

With the current PDF2 code, changing the figure/table autogenerated separator and title to be categorizable is pretty easy. Just add a mode to define the category for each fig/table and choose the autogenerated variable based on that. This could be part of PDF2 itself, but .the problem you will run into will be category specific styling and numbering.

St
yling and numbering use `@mode` and `@xsl:use-attribute-sets` and those attributes have to use a hard coded values. Thus, you can't e.g. have that mode that categorizes the different fig elements and then use `{$category}.title` styling or `{$category}.title-number` mode for numbering. This is the gotcha that has prevented us from implementing categorization in PDF2.

Jarno

Jarno Elovirta
 

Thinking about this out loud, the numbering mode is not really an issue, because you could just handle the categorization in the moded templates and generate matching number per category. The styling can be circumvented by the pattern where you generate the styling attributes into a carrier element and copy the attributes into the actual output element. I just don't like this overhead for the normal use case, where you don't have table categories.

The current code looks something like this

<xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]">
    <fo:block xsl:use-attribute-sets="fig.title">
        <xsl:call-template name="commonattributes"/>
        <xsl:apply-templates select="." mode="customTitleAnchor"/>
        <xsl:call-template name="getVariable">
            <xsl:with-param name="id" select="'Figure.title'"/>
            <xsl:with-param name="params">
                <number>
                    <xsl:apply-templates select="." mode="fig.title-number"/>
                </number>
                <title>
                    <xsl:apply-templates/>
                </title>
            </xsl:with-param>
        </xsl:call-template>
    </fo:block>
</xsl:template>

<xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]" mode="fig.title-number">
  <xsl:value-of select="count(key('enumerableByClass', 'topic/fig')[. &lt;&lt; current()][dita-ot:notExcludedByDraftElement(.)])"/>
</xsl:template>

Updating this would be something like like

<xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]">
    <fo:block><!-- strip styling form here -->
        <xsl:apply-templates select="." mode="fig.title.style"/><!-- generate styling in this template mode -->
        <xsl:call-template name="commonattributes"/>
        <xsl:apply-templates select="." mode="customTitleAnchor"/>
        <xsl:call-template name="getVariable">
            <xsl:with-param name="id"><!-- use mode to choose variable id -->
              <xsl:apply-templates select="." mode="fig.title.gen-text"/>
            </xsl:with-param>

            <xsl:with-param name="params">
                <number>
                    <xsl:apply-templates select="." mode="fig.title-number"/>
                </number>
                <title>
                    <xsl:apply-templates/>
                </title>
            </xsl:with-param>
        </xsl:call-template>
    </fo:block>
</xsl:template>

<!-- override this for categories -->
<xsl:template match="*" mode="fig.title.style" as="attribute()*">
  <xsl:variable name="dummy" as="element()">
    <dummy xsl:use-attribute-sets="fig.title"/>
  </xsl:variable>
  <xsl:sequence select="$dummy/@*"/>
</xsl:template>

<!-- Override to change which variable to use -->

<xsl:template match="*" mode="fig.title.style" as="xs:string">
  <xsl:text>
Figure.title</xsl:text>>
</xsl:template>


<!-- override this for categories so each category is counted separately -->
<xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]" mode="fig.title-number">
  <xsl:value-of select="count(key('enumerableByClass', 'topic/fig')[. &lt;&lt; current()][dita-ot:notExcludedByDraftElement(.)])"/>
</xsl:template>

So two new modes would be needed, and this would need to be adopted to link generation and List of Figures/Tables generation too.

Jarno