Search code examples
apache-fopditadita-ot

Strip whitespace in FOP inline element


I fail stripping whitespaces inside of inline elements in FOP with DITA-OT PDF2. This is my code snippet:

<p>1 BEFORE <uicontrol>test</uicontrol> AFTER</p>
<p>2 BEFORE <uicontrol> test</uicontrol> AFTER</p>
<p>3 BEFORE <uicontrol>test </uicontrol> AFTER</p>
<p>4 BEFORE <uicontrol><keyword keyref="test"/> </uicontrol> AFTER</p>
<p>5 BEFORE <uicontrol> <keyword keyref="test"/></uicontrol> AFTER</p>
<p>6 BEFORE <uicontrol>
  <keyword keyref="test"/>
</uicontrol> AFTER</p>
<p>7 BEFORE <uicontrol>  
  <keyword keyref="test"/>
</uicontrol> AFTER</p>

Renders to:

This is my attribute set:

<xsl:attribute-set name="uicontrol">
    <xsl:attribute name="white-space">nowrap</xsl:attribute>
    <xsl:attribute name="white-space-treatment">ignore</xsl:attribute>
    <xsl:attribute name="white-space-collapse">true</xsl:attribute>
    <xsl:attribute name="linefeed-treatment">treat-as-zero-width-space</xsl:attribute>
    <xsl:attribute name="background-color">#ff0000</xsl:attribute>
</xsl:attribute-set>

All red whitespaces have to be stripped. Where is my mistake?


Solution

  • FOP seems to have difficulty in "white-space-treatment":

    XSL-FO Property Support Table (§7)

    So it may be needed to use <xsl:strip-space elements="uicontrol"> plus normalize-space() function for text() in uicontrol.

    Following is the result when specifying <xsl:strip-space elements="uicontrol">

    After applying xsl:strip-space

    For your reference, Antenna House renders your original style definition as follows:

    AHF render result

    Hope this helps your development.