xslTNG icon indicating copy to clipboard operation
xslTNG copied to clipboard

abstract titles

Open hutchkintoot opened this issue 9 months ago • 1 comments

Hi, this is more of a question / help request than an actual issue

I'm porting features from our XSLT 1.0 FOP based output to the new XSLTNG stylesheets.

One feature that I'm struggling to port is how to define title page templates for an abstract elements with an info/title.

Given this section

<?xml version="1.0"?>
<section xmlns="http://docbook.org/ns/docbook" xmlns:xinfo="http://ns.expertinfo.se/cms/xmlns/1.0" version="5.0" xinfo:resource="UUID-0cbcaed8-4f0a-69d3-5929-89d2dafb6794" xinfo:resource-id="1980434" xinfo:resource-title="The Topic" xinfo:resource-titlelabel="" xinfo:resource-type="component" xinfo:version-major="1" xinfo:version-minor="0" xml:id="UUID-0cbcaed8-4f0a-69d3-5929-89d2dafb6794" xml:lang="en">
  <info>
    <title xinfo:text="1980435">Section title</title>
    <abstract>
      <info>
        <title>Abstract Title</title>
      </info>
      <para xinfo:text="1980512">Abstract Para</para>
    </abstract>
  </info>
  <para xinfo:text="1980482">A section paragraph</para>
</section>

I get the following output in our FOP based pipeline.

Image

By the help of the first custom template in the example below I have managed to get the abstract paras content in the xsltng output. But I can't figure out how to get the title added as well.

...
           <db:section context="parent::db:article">
                <header>
                    <tmp:apply-templates select="db:title">
                        <h2><tmp:content/></h2>
                    </tmp:apply-templates>
                    <tmp:apply-templates select="db:subtitle">
                        <h3><tmp:content/></h3>
                    </tmp:apply-templates>
                    <tmp:apply-templates select="db:abstract"/>
                </header>
            </db:section>
            
            <db:abstract context="parent::db:section">
                <div class="abstract-title">
                    <tmp:apply-templates select="db:title">
                        <h3><tmp:content/></h3>
                    </tmp:apply-templates>
                </div>
            </db:abstract>
...

Anyone have some pointers on how to achieve this?

hutchkintoot avatar Mar 19 '25 07:03 hutchkintoot

I think it's a bug. The <tmp:apply-templates select="db:abstract"/> line will apply the template for the abstract element in the regular mode. It will not apply your custom template.

The solution would be to apply a template in mode m:generate-titlepage to the abstract element. You can do this in xsl/modules/info.xsl:

<xsl:template match="db:abstract|db:legalnotice
                     |db:authorgroup[parent::db:info]">
  <div>
    <xsl:apply-templates select="." mode="m:attributes"/>
    <xsl:apply-templates select="." mode="m:generate-titlepage"/> <!-- Add this line -->
    <xsl:apply-templates/>
  </div>
</xsl:template>

(But i have not checked yet if this has any unwanted effect on legalnotice or authorgroup.)

As a workaround, i would suggest to define a template for section in mode m:generate-titlepage in a customization layer.

Greetings, Frank

fsteimke avatar Mar 29 '25 08:03 fsteimke

Fixed by #592

ndw avatar Jun 21 '25 08:06 ndw