1

我有xml的以下部分。

    <para>There are three types of investment vehicles available for foreign investors, i.e. Chinese-Foreign equity joint venture, Chinese-Foreign cooperative joint venture and wholly foreign-owned enterprises.<footnote num="8">
                    </footnote>
</para>

在这里,当我尝试应用我的模板时,它会创建一个空白区域,如下所示。

<xsl:template match="footnote">
        <sup><a><xsl:attribute name="name"><xsl:text>f</xsl:text><xsl:value-of select="@num"/></xsl:attribute>
                <xsl:attribute name="href"><xsl:text>#ftn.</xsl:text><xsl:value-of select="@num"/></xsl:attribute>
                <xsl:attribute name="class"><xsl:text>tr_ftn</xsl:text></xsl:attribute>
                <xsl:value-of select="@num"/>
            </a>
        </sup>
<xsl:apply-templates/>

我得到的输出是

<sup>
<a name="f8" href="#ftn.8" class="tr_ftn">8</a>
</sup>

但是当我尝试下面的模板时

    <xsl:template match="footnote">
        <sup><xsl:text>Hi</xsl:text><a><xsl:attribute name="name"><xsl:text>f</xsl:text><xsl:value-of select="@num"/></xsl:attribute>
                <xsl:attribute name="href"><xsl:text>#ftn.</xsl:text><xsl:value-of select="@num"/></xsl:attribute>
                <xsl:attribute name="class"><xsl:text>tr_ftn</xsl:text></xsl:attribute>
                <xsl:value-of select="@num"/>
            </a>
        </sup>
<xsl:apply-templates/>

我得到的输出是

<sup>Hi<a name="f8" href="#ftn.8" class="tr_ftn">8</a>
</sup>

实际预期输出为

<sup><a name="f8" href="#ftn.8" class="tr_ftn">8</a>
    </sup>

如果有办法在我的模板中获得第三个输出(即没有空格且没有显示文本),请告诉我。

第一种情况的 Html 输出(这里实际上是 8 上标)是

外商独资​​企业。8见,

对于第二种情况是

外商独资​​企业。嗨8看,

预期的

外商独资​​企业。8见,

谢谢

4

1 回答 1

2

我的猜测是你有<xsl:output indent="yes"/>,你可以删除它或使用<xsl:output indent="no"/>.

于 2013-09-04T14:11:16.553 回答