由于xml格式化而产生的空间

时间:2016-10-14 11:11:22

标签: xml xslt formatting

我在转换输出中获得空格。我相信这是因为xml格式化。我怎么能避免它?

Xml来源:

<?xml version="1.0" encoding = "UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<index>
    <item value="golden ratio">
        <pages>
            <single value="574"></single>
        </pages>
    </item>
</index>

Xsl来源:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template match="/">
<xsl:for-each select="index/item">
<xsl:value-of select="@value"/>
<xsl:apply-templates select="./pages"/>
</xsl:for-each>
</xsl:template>

<xsl:template match="pages/*">
<xsl:value-of select="@value"/><br />
</xsl:template>

不需要的空格结果: enter image description here

0 个答案:

没有答案
相关问题