JC G
JC G

Reputation: 23

XSL FO 2 blocks on the same row without table

Hello any clue to align the title with the OPTION text without using table?

<xsl:choose>
                <xsl:when test="@product='OPTION'">
                <fo:block-container keep-together.within-line="always"> 
                    <fo:block>  
                        <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
                    </fo:block>
                    <fo:block xsl:use-attribute-sets="title__option">   
                        <xsl:text>OPTION&#160;</xsl:text>
                            <xsl:text>&#160;</xsl:text>
                    </fo:block> 
                </fo:block-container>   
                </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
            </xsl:otherwise>
        </xsl:choose>

Thanks, cheers

Upvotes: 1

Views: 1780

Answers (3)

Tony Graham
Tony Graham

Reputation: 8068

It's not clear to me what you are trying to do, but you could:

  • Put the "OPTION" text in an fo:float and float it to the side
  • Use fo:list-block, etc., and use the "OPTION" fo:block in the fo:list-item-label
  • Use fo:inline-container for one or both blocks
  • If the title is never going to make two lines, use fo:leader to keep the two pieces of text apart
  • If you are using AH Formatter, put "OPTION" in an fo:change-bar-begin (see https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#fo.change-bar-begin)

Part of my confusion is that you have non-breaking spaces after the "OPTION" text.

Upvotes: 1

Greg
Greg

Reputation: 471

My sollution:

        <fo:block>
            <fo:inline-container inline-progression-dimension="49.9%">
                <fo:block text-align="left">
                    content1
                </fo:block>
            </fo:inline-container>
            <fo:inline-container inline-progression-dimension="49.9%">
                <fo:block text-align="right">
                    content2
                </fo:block> 
            </fo:inline-container>
        </fo:block>

Upvotes: 1

JC G
JC G

Reputation: 23

Thanks for your answer.

I am actually trying to float right an OPTION "label" next to the title using the attributes sets for creating a background color on the OPTION text

3 ways failed:

List Block throws error: FOPException: Only non-null Positions with an index can be checked

<xsl:choose>
        <xsl:when test="@product='OPTION'">
            <fo:list-block>
                <fo:list-item>
                    <fo:list-item-label>
                        <fo:block xsl:use-attribute-sets="title__option">
                            <xsl:text>OPTION&#160;</xsl:text>
                        </fo:block>
                    </fo:list-item-label>
                    <fo:list-item-body>
                        <fo:block>
                            <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
                        </fo:block>
                    </fo:list-item-body>
                </fo:list-item>
            </fo:list-block>
        </xsl:when>
        <xsl:otherwise>
            <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
        </xsl:otherwise>
    </xsl:choose>

Float throws the error : [fop] [ERROR] No LayoutManager maker for class class org.apache.fop.fo.flow.Float and the OPTION text is not displayed

<xsl:choose>
        <xsl:when test="@product='OPTION'">
            <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
            <fo:float float="right"> 
                <fo:block xsl:use-attribute-sets="title__option">
                    <xsl:text>OPTION&#160;</xsl:text>
                </fo:block>
            </fo:float> 
        </xsl:when>
        <xsl:otherwise>
            <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
        </xsl:otherwise>
    </xsl:choose>

Inline-container throws no error but the paragraph is ignored and not displayed

<xsl:choose>
            <xsl:when test="@product='OPTION'">
                <fo:inline-container>
                    <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
                    <fo:block xsl:use-attribute-sets="title__option">
                        <xsl:text>OPTION&#160;</xsl:text>
                    </fo:block>
                </fo:inline-container>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
            </xsl:otherwise>
        </xsl:choose>

Upvotes: 0

Related Questions