Changing font-size of the list used in table cells

Here should go questions about transforming XML with XSLT and FOP.
girishkanmas
Posts: 8
Joined: Thu Apr 14, 2022 8:37 am

Changing font-size of the list used in table cells

Post by girishkanmas »

Hi,
Through my custom plugin, I did the following to change font-size of the <li> elements used in the <table>:

Added following in the <custom-plugn>\cfg\fo\attrs]\custom.xsl file:

Code: Select all

<xsl:attribute-set name="table_ul" use-attribute-sets="common.block">
    <xsl:attribute name="font-size">8pt</xsl:attribute>
 </xsl:attribute-set>
And added following in the <custom-plugn>\cfg\fo\xsl\custom.xsl

Code: Select all

<xsl:template match="*[contains(@class,' topic/entry ')]/*[contains(@class,' topic/li ')]">
    <fo:list-item>
      <fo:list-item-label/>
      <fo:list-item-body>
            <fo:block xsl:use-attribute-sets="table_ul">
              <xsl:call-template name="commonattributes"/>
              <xsl:apply-templates/>
            </fo:block>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template>
But it's not working. The generated PDF is using the default font-size to format lists in tables.
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Changing font-size of the list used in table cells

Post by Radu »

Hi,

Maybe you can create a very small DITA Map and topics sample to quickly publish and then try to debug the problem, for example in the Oxygen transformation scenario in the Parameters tab you can set the parameter "clean.temp" to value "no", then publish.
After this, look in the transformation temporary files folder at the generated "topic.fo" file and try to find that XSL-FO element produced by your customization.
Also inside an xsl:template you can add <xsl:message> elements to send a message to the console view.
Looking at your template match:
<xsl:template match="*[contains(@class,' topic/entry ')]/*[contains(@class,' topic/li ')]">

you seem to be matching a <li> element placed directly inside a table <entry> but usually the <li> is inside an <ul> or <ol>, so maybe you actually want to match:
<xsl:template match="*[contains(@class,' topic/entry ')]/*[contains(@class,' topic/ul ')]"/*[contains(@class,' topic/li ')]">

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
girishkanmas
Posts: 8
Joined: Thu Apr 14, 2022 8:37 am

Re: Changing font-size of the list used in table cells

Post by girishkanmas »

Hi Radu,
I tried using your suggested condition:

Code: Select all

<xsl:template
    match="*[contains(@class,' topic/entry ')]/*[contains(@class,' topic/ul ')]/*[contains(@class,' topic/li ')]">
The PDF is still using the default font. Looks like the <li> element is overridden by the lower-level element with default font-size. How to avoid such overriding?
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Changing font-size of the list used in table cells

Post by Radu »

Hi,

The closer ancestor element containing a font-size attribute to the text will always win. You probably need to match also on that element and increase that font size.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
girishkanmas
Posts: 8
Joined: Thu Apr 14, 2022 8:37 am

Re: Changing font-size of the list used in table cells

Post by girishkanmas »

Hi Radu,
Thank you very much for your suggestion. It worked!
I used the condition as follows:

Code: Select all

<xsl:when test="ancestor::*[contains(@class, ' topic/entry ')]">
Regards,
Girish Kanmas
Post Reply