0
votes

I am having trouble with XSL-FO using Apache FOP as a processor. I have a simple stylesheet and already have set a round border to an fo:block-container. The problem is: the text size is non-predictable given that the .fo file will be generated using a XSLT and a XML, so i need to tell FOP to adjust the border width according to the text width instead of applying the same width to all of the containers. Any ideas?

In XSLT file:

    <fo:block-container xsl:use-attribute-sets="right-side-itens">
        <fo:block-container xsl:use-attribute-sets="rounded-borders">                                    
            <fo:block>
                <xsl:value-of-select="./tagInsideXML/@attribute" />
                <!-- qwertyuiopasdfghjkl -->
            </fo:block>
        </fo:block-container>
    <fo:block-container>

`

In the styles.xsl external file:

<xsl:attribute-set name="right-side-itens">
    <xsl:attribute name="top">35px</xsl:attribute>
    <xsl:attribute name="right">45px</xsl:attribute>
    <xsl:attribute name="text-align">end</xsl:attribute>
    <xsl:attribute name="font-size">10px</xsl:attribute>
    <xsl:attribute name="height">10cm</xsl:attribute>
    <xsl:attribute name="width">200px</xsl:attribute>
    <xsl:attribute name="position">absolute</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="rounded-borders">
    <xsl:attribute name="margin-top">2px</xsl:attribute>
    <xsl:attribute name="margin-right">1.8px</xsl:attribute>
    <xsl:attribute name="padding-right">2px</xsl:attribute>
    <xsl:attribute name="float">right</xsl:attribute>
    <xsl:attribute name="line-height">18px</xsl:attribute>
    <xsl:attribute name="font-size">8px</xsl:attribute>
    <xsl:attribute name="border">solid 1.2px #000000</xsl:attribute>
    <xsl:attribute name="fox:border-radius">6px</xsl:attribute>
    <xsl:attribute name="position">relative</xsl:attribute>
    <xsl:attribute name="overflow">visible</xsl:attribute>
</xsl:attribute-set>

Here is a sample image showing the desired output

1
Can you give more details, such as sample XSL-FO or a screenshot and explanation of what's currently going wrong?Tony Graham
Hi there, I added a sample code and an edited image to clarify my goals. Thanks in advance.Evandro Teixeira

1 Answers

0
votes

A block-container usually has a fixed size, while a block can grow with its contents. So I'd put an fo:block inside the container, and apply the border to that block.