Need to change the footer value as per the parent and child topic attributes

boopathyks
Posts: 4
Joined: Thu Oct 24, 2019 2:43 pm

Need to change the footer value as per the parent and child topic attributes

Post by boopathyks » Fri Jun 25, 2021 1:46 am

Hi,

Now I'm working on creating the footer value for pdf using dita-ot pdf conversion. I'm having single parent topic with multiple child topics with outputclass attribute and I need to create the footer text for certain child topic

Input Dita Having:

Code: Select all

[i]<topic class="- topic/topic "  [b]outputclass="heading"[/b]>
   <title outputclass="CD_Map_Heading-hide">HIDE TOPIC</title>
   <topic class="- topic/topic " [b]outputclass="DEF"[/b]>
      <title>DEFINITION</title>
   </topic>
   <topic class="- topic/topic " [b]outputclass="REV"[/b]>
      <title>REVOLUTION</title>
   </topic>
</topic>[/i]
I have created the customized footnote for the pdf using static-content.xsl

Code: Select all

<xsl:template name="insertBodyOddFooter">
    <fo:static-content flow-name="odd-body-footer">
        <fo:block>&#160;</fo:block>
        <fo:block xsl:use-attribute-sets="__body__odd__footer">
            <xsl:choose>
                <xsl:when test="*[contains(@outputclass, 'DEF')]">
                           <xsl:text>DEF</xsl:text>
                  </xsl:when>
                  <xsl:when test="*[contains(@outputclass, 'REV')]">
                           <xsl:text>REV</xsl:text>
                  </xsl:when>
                <xsl:otherwise>
                    <fo:block-container position="absolute">
                        <fo:block padding-top="20pt"  text-align="center">
                            <fo:page-number/>
                        </fo:block>
                    </fo:block-container>
                </xsl:otherwise>
            </xsl:choose>
        </fo:block>
    </fo:static-content>
</xsl:template>
Now I'm getting DEF as footer for all the topics, but I need each child topic gets their corresponding footer value. Seems like it allowing only one topic for the footer. Please help me to get the footer value for each child topics. Thanks in advance!!!

Dan
Posts: 485
Joined: Mon Feb 03, 2003 10:56 am

Re: Need to change the footer value as per the parent and child topic attributes

Post by Dan » Mon Jun 28, 2021 3:32 pm

The template insertBodyOddFooter is called once, from the start of a fo:page-sequence.

The content it generates is static across the entire page sequence.

Code: Select all

<xsl:template name="processTopicPart">
        <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="page-sequence.part">
            <xsl:call-template name="startPageNumbering"/>
            <!-- The header and footer are inserted before the flow of topics -->
            <xsl:call-template name="insertBodyStaticContents"/>
            <fo:flow flow-name="xsl-region-body">
	            <!-- Here comes the list of fo elements for all the topics -->
There are a couple of solutions:
1. force the publishing process to create new fo:page-sequences for each of the topics you need to customize. This is not a trivial task and requires heavily changing DITA XSL-FO stylesheets.
2. use a special kind of variables (fo:markers) that are expanded by the FO processor in the static content of the page.

For the second solution: In your XSL customization overwrite the template that matches the title of a topic, then add an fo:marker next to the content it generates.
This variable you can use later in the insertBodyOddFooter template, by using a fo:retrieve-marker.

Code: Select all

 <xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
    <xsl:next-match/>
    
    <xsl:choose>
        <xsl:when test="../[contains(@outputclass,'DEF')]">
            <fo:marker marker-class-name="var">DEF</fo:marker>
        </xsl:when>
        <xsl:when test="../[contains(@outputclass,'REV')]">
            <fo:marker marker-class-name="var">REV</fo:marker>
        </xsl:when>
        <xsl:otherwise>
            <fo:marker marker-class-name="var"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="insertBodyOddFooter">
    <fo:static-content flow-name="odd-body-footer">
        <fo:block>&#160;</fo:block>
        <fo:block xsl:use-attribute-sets="__body__odd__footer">
            <!-- THE FO PROCESSOR WILL USE THE MARKER ON EACH FOOTER IT GENERATES -->
            <fo:retrieve-marker retrieve-class-name="var"/>
        
            <fo:block-container position="absolute">
            <fo:block padding-top="20pt" text-align="center">
            <fo:page-number/>
            </fo:block>
            </fo:block-container>
    </fo:block>
    </fo:static-content>
</xsl:template>
Another option would be to use the CSS based PDF transformation that is available in oXygen, is much easier to add text that is expanded in the footer, by using string sets ( a kind of variables). Here is a CSS snippet:

Code: Select all

*[class~= "topic/topic"][outputclass ~= "DEF"]{
    string-set: var "DEF";
}
*[class~= "topic/topic"][outputclass ~= "REV"] {
    string-set: var "REV";
}
*[class~= "topic/topic"][not(outputclass)] {
    string-set: var '';
}

@page chapter:right, chapter:left{
       
   @bottom-center {
       content: "Text that changes: " string('var')
   }

}
You can read more about customizing the PDF-CSS transformation here: https://www.oxygenxml.com/doc/versions/ ... n_css.html

boopathyks
Posts: 4
Joined: Thu Oct 24, 2019 2:43 pm

Re: Need to change the footer value as per the parent and child topic attributes

Post by boopathyks » Tue Jun 29, 2021 8:28 pm

Thanks Dan!!!! Its working well

Post Reply