简体   繁体   中英

XSL-FO whitespaces between elements

I'm using this code to make two-level numbering, like "1.1. Chapter One", for example.

    <fo:inline>
      <xsl:number from="Book" count="Chapter"/>.
      <xsl:number from="Chapter" count="Chapter"/>.
      <xsl:text> </xsl:text>
      <xsl:apply-templates select="....."/>
    </fo:inline>

But I discovered that this code generates the following text:

1. 1. Chapter One

- with a space between xsl:number elements. And this is what I do not want to happen. I already have

<xsl:strip-space elements="*"/>

but it does not help anything.

How do I get rid of these parasite spaces?

set the periods . in xsl:text tag

<fo:inline>
  <xsl:number from="Book" count="Chapter"/><xsl:text>.</xsl:text>
  <xsl:number from="Chapter" count="Chapter"/><xsl:text>.</xsl:text>
  <xsl:text> </xsl:text>
  <xsl:apply-templates select="....."/>
</fo:inline>

A simple way is to avoid the new-line outside of the tags as in:

<fo:inline>
  <xsl:number from="Book" count="Chapter"/>.<xsl:number
              from="Chapter" count="Chapter"/>.
  <xsl:apply-templates select="....."/>
</fo:inline>

And you certainly do not need the <xsl:text> since you'll get a newline there. Although if you do not want a newline, again you can remove it like this:

<fo:inline>
  <xsl:number from="Book" count="Chapter"/>.<xsl:number
              from="Chapter" count="Chapter"/>. <xsl:apply-templates
              select="....."/>
</fo:inline>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM