for-each不适用于我的xslt

时间:2013-02-05 16:51:14

标签: xslt filemaker

我有一个问题,尽管经过广泛搜索我无法解决... 这是XML的一部分。

<contributors>
<authors>
<author>Willett, C G</author>
<author>Tepper, J E</author>
<author>Kaufman, D S</author>
<author>Shellito, P C</author>
<author>Eliseo, R</author>
<author>Convery, K</author>
<author>Wood, W C</author>
</authors>
</contributors>

我尝试使用此xsl(摘录)

将所有作者导入Filemaker单元格
<FIELD EMPTYOK="YES" MAXREPEAT="15" NAME="Author" TYPE="TEXT"/>
    <COL>
<DATA>
<xsl:for-each select="contributors/authors">
<xsl:value-of select="author">
</xsl:value-of>
</xsl:for-each>
</DATA>
</COL>

不幸的是只导入了第一个名字。为什么?少了什么东西?

如果有人可以帮助我,我会很高兴......

干杯

2 个答案:

答案 0 :(得分:3)

您需要遍历author,而不是authors,因为只有一个authors,但很多author s:

<xsl:for-each select="contributors/authors/author">
    <xsl:value-of select="concat(., ' ')" />
</xsl:for-each>

答案 1 :(得分:0)

<FIELD EMPTYOK="YES" MAXREPEAT="15" NAME="Author" TYPE="TEXT"/>
  <COL>
    <DATA>
      <xsl:for-each select="contributors/authors/author">
        <xsl:value-of select="."/>
        <xsl:if test="position() &lt; last()">; </xsl:if>
      </xsl:for-each>
    </DATA>
  </COL>

这将生成一个以分号分隔的所有作者值列表。 <xsl:if>用于避免在最后一个作者姓名后添加一个尾随分号。