Сell vertical borders not showing

Here should go questions about transforming XML with XSLT and FOP.
Yuriy_1977
Posts: 8
Joined: Thu Jan 20, 2022 8:05 am

Сell vertical borders not showing

Post by Yuriy_1977 »

Hi!
I use custom.xsl against css.
I need to display an empty row after the header before the body in every table.
This row must have the same number of cells as the last header row.
So I am using the following template

Code: Select all

    
<xsl:template match="*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ') and position()=last()]">
        <fo:table-row>
        	<xsl:apply-templates/>
        </fo:table-row>
        <fo:table-row>
            <xsl:for-each select="entry">
	            <fo:table-cell height="5mm" xsl:use-attribute-sets="thead.row.entry" border-width="1mm"/>
            </xsl:for-each>
        </fo:table-row>
    </xsl:template>    
But cell vertical borders not showing. I tried to use many border-properties but it didn't help.
Need help, advice :D .
Thanks in advance.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Сell vertical borders not showing

Post by Radu »

Hi,

Can you do some debugging on your side? Maybe add an xsl:message inside your xsl:template to see if it gets called?
If the template gets called, you can set the "clean.temp=no" transformation parameter and look in the transformation temporary files folder at the generated "topic.fo" to see if your content was included in the xsl:fo table structure.
Also maybe you can try to replace:

Code: Select all

<fo:table-row>
        	<xsl:apply-templates/>
        </fo:table-row>
with

Code: Select all

<xsl:next-match/>
which should apply the base template which handles rows.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Yuriy_1977
Posts: 8
Joined: Thu Jan 20, 2022 8:05 am

Re: Сell vertical borders not showing

Post by Yuriy_1977 »

If I replace my code with

Code: Select all

<xsl:next-match/>
I get the same in the output file: cell vertical borders not showing
The answer was in the topic.fo: I copied from the topic.fo all attributes of a good cell and found out the required attribute for my template cell:

Code: Select all

  border-end-style="solid" 
Thanks a lot for your reply!
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Сell vertical borders not showing

Post by Radu »

Hi,
So:
If I replace my code with <xsl:next-match/>I get the same in the output file: cell vertical borders not showing
Using xsl:next-match is better. You can look in the XSLT stylesheet used by the base PDF plugin and find the original template which matches "*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ')"", as you see it generates an <fo:table-row> but it has certain attributes on it. So if you override it and do not generate the same attributes on the table-row, you might break things. For example a DITA table row may have an ID attribute set on it, attribute which may be used when linking to the row from another part of the topic. If you do not generate an ID for the row in the XSL-Fo output, you may break a link. So using "xsl:next-match" you apply exactly the same processing in the base to generate the next to last row exactly as it was generated before.
The answer was in the topic.fo: I copied from the topic.fo all attributes of a good cell and found out the required attribute for my template cell:
border-end-style="solid"
This may depend on the individual table, DITA tables have various attributes which specify if the user creating the table wants borders all around, if they want borders between rows and cells. So what you did may not be good in all cases.
Maybe as another approach you could copy the last row's XSL:FO content as it is but without the text inside the cells. Something like this (but I have not tested if it works):

Code: Select all

  <xsl:template match="*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ') and position()=last()]">
    <xsl:variable name="lastRow">
      <xsl:next-match/>
    </xsl:variable>
    <!-- Copy the last row as it is -->
    <xsl:copy-of select="$lastRow"/>
    <!-- Copy the last row without text -->
    <xsl:apply-templates select="$lastRow" mode="removeText"/>
  </xsl:template>
  
  <!-- Ignore text -->
  <xsl:template match="text()" mode="removeText"/>
  
  <xsl:template match="* | @*" mode="removeText">
    <xsl:copy>
      <xsl:apply-templates select="* | @*"/>
    </xsl:copy>
  </xsl:template>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply