Page 1 of 1

Automatic numbering in <equation-block/>

Posted: Tue Mar 30, 2021 9:25 am
by Kot_1977
I use:
oXygen XML Editor 22.1, build 2020100710
transformation scenario - DITA Map PDF - based on XSL-FO
customization directory - according to oXygen's instructions

I want to get an automatic numbering in <equation-block/> and right alignmet too, so I use the tempalate:

<xsl:template match="*[contains(@class, ' equation-d/equation-block ')]">
<fo:table text-align="right" border = "0pt" margin-top="5mm">
<fo:table-column column-width="87.5mm"/>
<fo:table-column column-width="87.5mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border = "0pt" height="10.0mm">
<fo:block><xsl:apply-templates select="*[contains(@class,' topic/image ')]"/></fo:block>
</fo:table-cell>
<fo:table-cell border = "0pt">
<fo:block>
<xsl:text>(</xsl:text>
<xsl:value-of select="count(preceding::equation-block[not(descendant::equation-block)])+1" />
<xsl:text>)</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>

It's working template, but I have lost working formulas references:
for example <xref href="#topicID/equation-blockID" format="dita">see formula</xref> - it's just blue text.

I want working formulas reference and an automatic numbering in <equation-block/>.
Moreover, I want the links to be displayed as formula numbers that appear in the text.
Thanks in advance!

Re: Automatic numbering in <equation-block/>

Posted: Tue Mar 30, 2021 10:00 am
by Radu
Hi,

The original DITA formula element probably has an @id attribute defined on it and your XSL template does not use that ID to generate an equivalent ID on the fo:table that it creates, so the original @id attribute is not propagated to the XSL-FO elements.
I think something like this might work:

Code: Select all

<xsl:template match="*[contains(@class, ' equation-d/equation-block ')]">
<fo:table text-align="right" border = "0pt" margin-top="5mm">
 <xsl:call-template name="commonattributes"/>
 ........
That call-template to the "commonattributes" should propagate the ID attribute value from the DITA element as an ID attribute on the fo:table element.

Regards,
Radu

Re: Automatic numbering in <equation-block/>

Posted: Tue Mar 30, 2021 12:24 pm
by Kot_1977
Thank you! Links work.
Is the formula number in links difficult to do? I mean the automatic display of the formula number in the links.

Re: Automatic numbering in <equation-block/>

Posted: Tue Mar 30, 2021 2:13 pm
by Radu
Hi,

About the link text, I think this is feasible but a little bit harder to do. The link text is computed in the pre-processing stage, before the XSL-FO output is generated from the DITA content.
If you look inside this XSLT stylesheet dita-ot/plugins/org.dita.base/xsl/preprocess/topicpullImpl.xsl
there is a template which computes the link text for links to figures for example:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/fig ')][*[contains(@class,' topic/title ')]]" mode="topicpull:resolvelinktext">
and you probably need something similar for computing the link text for equations.

To add extra XSLT templates to the preprocessing stage a PDF customization folder is not enough, you need to create your own PDF plugin and in the plugin.xml you need to extend this extension point dita.xsl.topicpull to provide an XSLT stylesheet which can override templates or add new templates to the base XSLT processing. Something like:

Code: Select all

  <feature extension="dita.xsl.topicpull" file="topicpullCustom.xsl" xml:base="."/>
An alternative to adding a template in the pre-processing stage might be to override the template named "topic.xref" from dita-ot/plugins/org.dita.pdf2/xsl/fo/links.xsl which can be done with a PDF customization folder and somehow compute the title of the target element there.

Regards,
Radu

Re: Automatic numbering in <equation-block/>

Posted: Tue Mar 30, 2021 2:26 pm
by Kot_1977
Hi! I see. I'll try.
Thank you!