Search

Hi All,

I have a nested for-each loop inside my template. But the nested loop only returns the first element. I can't really find an answer to this problem, maybe someone can help me out. I noticed if I use <xsl:copy-of select="item" /> instead of <xsl:value-of select="item" /> it does return all elements, but it doesn't seem to play nice with the <xsl:if> I'm using. I'm confused...

<xsl:for-each select="projecten-deadline/entry">
    <tr>
        <td>
            <a href="#"><xsl:value-of select="project-name" /></a>
            <br />
            <xsl:for-each select="team">
                <em class="muted">
                    <xsl:value-of select="item" /><xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
                </em>
            </xsl:for-each>
        </td>
        <td width="15">
            <a href="#"><i class="icon-eye-open"></i></a>
        </td>
    </tr>
</xsl:for-each>

Hi there,

Please post an example of your XML.

Certainly :)

<projecten-actief>
        <section id="7" handle="projecten">Projecten</section>
        <entry id="11">
          <project-name handle="concept">Concept</project-name>
          <team>
            <item handle="dion">Dion</item>
            <item handle="henk">Henk</item>
            <item handle="piet">Piet</item>
          </team>
          <klant>
            <item handle="klant-3">Klant 3</item>
          </klant>
        </entry>
        <entry id="10">
          <project-name handle="webdev-project">Webdev Project</project-name>
        </entry>
        <entry id="9">
          <project-name handle="intranet">Intranet</project-name>
          <team>
            <item handle="henkie">Henkie</item>
            <item handle="pietje">Pietje</item>
          </team>
        </entry>
        <entry id="7">
          <project-name handle="test-project-1">Test project 1</project-name>
          <team>
            <item handle="dion">Dion</item>
            <item handle="piet">Piet</item>
          </team>
          <klant>
            <item handle="klant-1">Klant 1</item>
          </klant>
        </entry>
      </projecten-actief>
<xsl:for-each select="team/item">

:o)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details