Pages: 1
Print
Author Topic: Adjustment for <p> formatting when nested in other elements  (Read 3048 times)
dduffy
Member

Posts: 15


« on: April 21, 2010, 11:11:52 AM »

We had modified the fo/attrs/custom.xsl file to add space after the <p> as follows:

<xsl:attribute-set name="p">
<xsl:attribute name="text-indent">0em</xsl:attribute>
<xsl:attribute name="padding-before">6pt</xsl:attribute>          
<xsl:attribute name="padding-after">6pt</xsl:attribute>
<xsl:attribute name="space-after.optimum">3pt</xsl:attribute>
<xsl:attribute name="space-before">0pt</xsl:attribute>
<xsl:attribute name="space-after">0pt</xsl:attribute>
</xsl:attribute-set>

This works great in PDF for when the <p> stands alone but when it is nested within other elements, such as an <li> tag, the space after is too large and we would like to reset it to 0em. I have tried several workarounds trying to adjus the ul.li__body statements without avail.

Does anyone have advice on adding an <xsl:template match= to the fo/xsl/custom.xsl that could allow for such exceptions or would code have to be written for each exception?
Logged
severin.foreman
Member

Posts: 47



« Reply #1 on: April 21, 2010, 11:23:31 AM »

I think something like the following would override the attribute set value for space-after.optimum.

<xsl:template match="*[contains(@class, ' topic/p ')]">
        <fo:block xsl:use-attribute-sets="p" id="{@id}">
            <xsl:if test="not(contains(parent::*/@class,' topic/body '))">
                <xsl:attribute name="space-after.optimum">0em</xsl:attribute>
            </xsl:if>
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

In human terms, if the parent topic is not a body element, or some specialization of it, set the space after to zero.

Hth,
Severin
Logged
dduffy
Member

Posts: 15


« Reply #2 on: April 22, 2010, 07:30:45 AM »

Thanks Severin. That did it!
Logged
Pages: 1
Print
Jump to:  

email us