Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ove Andersen 435 posts 1541 karma points c-trib
    Jan 13, 2010 @ 12:42
    Ove Andersen
    0

    Combining nodes

    Im making a Statistics module for a local football (soccer) club where I list the top 5 when it comes to rating, goals or assists.
    Everything is set up using Umbraco 4 and Repeatable Custom Content 2.0.

    The matches are organized in"TeamA" and "TeamB", and here comes the problem:

    I am able to get all the statistics for the player using this xslt:

        <xsl:variable name="source" select="umbraco.library:GetXmlNodeById($matches-source)"/>
       
        <xsl:variable name="all_players_thisyear">
          <xsl:for-each select="$source/node [substring(data [@alias='Date'],1,4)=substring(umbraco.library:CurrentDate(),1,4)]/data [@alias='TeamA']/items/item | $source/node [substring(data [@alias='Date'],1,4)=substring(umbraco.library:CurrentDate(),1,4)]/data [@alias='TeamB']/items/item">
            <xsl:copy-of select="."/>
          </xsl:for-each>
        </xsl:variable>

        <xsl:variable name="all_players_thisyear_nodeset" select="msxsl:node-set($all_players_thisyear)"/>
        <xsl:for-each select="$all_players_thisyear_nodeset/item [string(data [@alias='Rating']) != '']">
              <xsl:sort select="sum($all_players_thisyear_nodeset/item [data [@alias='Player']=current()/data [@alias='Player']]/data [@alias='Rating']) div count($all_players_thisyear_nodeset/item [data [@alias='Player']=current()/data [@alias='Player']])" data-type="number" order="descending"/>

              <xsl:variable name="totalmatches_thisyear" select="count($source/node [substring(data [@alias='Date'],1,4)=substring(umbraco.library:CurrentDate(),1,4)]/data [@alias='TeamA']/items/item [data [@alias='Player']=current()/data [@alias='Player']]) + count($source/node [substring(data [@alias='Date'],1,4)=substring(umbraco.library:CurrentDate(),1,4)]/data [@alias='TeamB']/items/item [data [@alias='Player']=current()/data [@alias='Player']])"/>
              <xsl:variable name="totalrating_thisyear" select="sum($source/node [substring(data [@alias='Date'],1,4)=substring(umbraco.library:CurrentDate(),1,4)]/data [@alias='TeamA']/items/item [data [@alias='Player']=current()/data [@alias='Player']]/data [@alias='Rating']) + sum($source/node [substring(data [@alias='Date'],1,4)=substring(umbraco.library:CurrentDate(),1,4)]/data [@alias='TeamB']/items/item [data [@alias='Player']=current()/data [@alias='Player']]/data [@alias='Rating'])"/>

              <xsl:if test="position() &lt;= '5'">
                <tr>
                  <td>
                    <a href="{umbraco.library:NiceUrl(data [@alias='Player'])}">
                      <xsl:value-of select="umbraco.library:GetXmlNodeById(data [@alias='Player'])/@nodeName"/>
                    </a>
                  </td>
                  <td>
                    <xsl:value-of select="$totalrating_thisyear div $totalmatches_thisyear"/>
                  </td>
                </tr>
              </xsl:if>
            </xsl:for-each>

    However, the result is that a player that has played for both TeamA and TeamB is returned as two different persons (although with the same @id).

    Does anyone have an idea how to combine these two into one person?

Please Sign in or register to post replies

Write your reply to:

Draft