How to insert a white space between two (inline) elements?

Adrian Maire picture Adrian Maire · Aug 17, 2014 · Viewed 15.3k times · Source

Context

I am creating an XSL-FO document to convert my XML text to PDF.

In the XSL-FO, I have two consecutive inline elements, I would like a white space between them:

<fo:block>
    <xsl:number/> <xsl:value-of select="@title"/>
</fo:block>

The expected result would be:

1 Introduction

Instead, I get

1Introduction

It seem XML do not consider this white space.

Attempts

I have tried several possible solutions, without success:

<fo:block>
    <xsl:number/><fo:inline white-space="pre">  </fo:inline><xsl:value-of select="@title"/>
</fo:block>

or

<fo:block>
    <xsl:number/><fo:inline margin-left="0.5cm"><xsl:value-of select="@title"/></fo:inline>
</fo:block>

None of those ideas produce an acceptable result.

The question:

How to include a white space between two (inline) elements?

Answer

michael.hor257k picture michael.hor257k · Aug 17, 2014

Try:

<fo:block>
    <xsl:number/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="@title"/>
</fo:block>

Or:

<fo:block>
    <xsl:number/>
    <xsl:value-of select="concat(' ', @title)"/>
</fo:block>