应用xsl模板时如何避免不必要的空间

时间:2016-11-20 07:48:41

标签: xml xslt xsl-fo

我的xml

<person>
    <fullName>
        <firstName>Name</firstName>
        <lastName>Lastname</lastName>
        <secondName>Secondname</secondName>
    </fullName>
    ...
</person>

当我使用我的模板<xsl:apply-templates select="person"/>

<xsl:template match="person">
    <fo:block>
        <xsl:apply-templates select="fullName"/>.
    </fo:block>
    ...
</xsl:template>

我在该点之前有一个额外空格的输出。

  

名称姓氏SecondName。

如何预防呢?现在我正在做这个

<xsl:template match="person">
    <fo:block>
        <xsl:value-of select="fullName/lastName"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="fullName/firstName"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="fullName/secondName"/>.
    </fo:block>
</xsl:template>

当你已经预定义并形成了xml时,它不方便在它们之间添加空格,就像这样

0 个答案:

没有答案