我在使用xsl-fo正确显示循环中的选择值时遇到了问题。在具有相同节点的xsl-fo中循环显示结果
正如您在xml中可以看到的,每个<firstname>
有多个<visited>
节点。我试图在fo:block标记中显示每个<visited>
的值,但此刻它只是在一个fo:block中显示它们,导致值在一行中压缩到一起,我无法弄清楚。
XSL:
<xsl:template match="/">
<xsl:for-each select="company/staff">
<fo:block>
<xsl:value-of select="@id" />
</fo:block>
<xsl:for-each select="firstname">
<fo:block>
<xsl:value-of select="@name" />
</fo:block>
<fo:block>
<xsl:value-of select="." />
</fo:block>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
XML:
<company>
<staff id="1">
<firstname name="name_1">
<visited>location_1</visited>
<visited>location_2</visited>
<visited>location_3</visited>
<visited>location_4</visited>
...
</firstname>
<firstname name="name_2">
<visited>location_1</visited>
...
</firstname>
</staff>
<staff id="2">
...
</staff>
</company>
啊谢谢!我很近,但没有雪茄 – iswinky 2014-10-10 10:21:20