1

我有一个 xsl:when 显示:

  • 类别
  • 图片

我想要的是显示所有图像,但只在它们上方显示一次类别名称,因为它们对于该图像集都是相同的。

问:我该如何做到这一点?

<xsl:for-each select="/data/commissions/entry">
    <xsl:variable name="category-path" select="commission-category"/>

    <xsl:for-each select="imageset/item">               
            <xsl:variable name="image-path" select="image/filename"/>

            <li>
                    <!-- this is the category name --> 
                    <xsl:value-of select="$name-path" />

                    <!-- this is the photo -->
                    <img src="{$image-path}" alt="" />
            </li>
    </xsl:for-each>

4

1 回答 1

1

移动这个:

<xsl:value-of select="$name-path" />

<xsl:for-each>指令

<xsl:for-each select="/data/commissions/entry">
    <xsl:variable name="category-path" select="commission-category"/>

    <!-- this is the category name --> 
    <xsl:value-of select="$name-path" />

    <xsl:for-each select="imageset/item">               
            <xsl:variable name="image-path" select="image/filename"/>

            <li>

                    <!-- this is the photo -->
                    <img src="{$image-path}" alt="" />
            </li>
    </xsl:for-each>
于 2012-11-24T15:52:08.263 回答