Automatic numbering in <equation-block/>

Kot_1977
Posts: 10
Joined: Thu Dec 10, 2020 11:00 am

Automatic numbering in <equation-block/>

Post by Kot_1977 » Tue Mar 30, 2021 9:25 am

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!

Radu
Posts: 7528
Joined: Fri Jul 09, 2004 5:18 pm

Re: Automatic numbering in <equation-block/>

Post by Radu » Tue Mar 30, 2021 10:00 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Kot_1977
Posts: 10
Joined: Thu Dec 10, 2020 11:00 am

Re: Automatic numbering in <equation-block/>

Post by Kot_1977 » Tue Mar 30, 2021 12:24 pm

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.

Radu
Posts: 7528
Joined: Fri Jul 09, 2004 5:18 pm

Re: Automatic numbering in <equation-block/>

Post by Radu » Tue Mar 30, 2021 2:13 pm

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Kot_1977
Posts: 10
Joined: Thu Dec 10, 2020 11:00 am

Re: Automatic numbering in <equation-block/>

Post by Kot_1977 » Tue Mar 30, 2021 2:26 pm

Hi! I see. I'll try.
Thank you!

Post Reply