Re: [xsl] for-each attributes test

Subject: Re: [xsl] for-each attributes test
From: "Jason S" <jasonsmith@xxxxxxxxxxx>
Date: Thu, 24 Oct 2002 12:34:19 -0400
I came up with a similar solution without the count function, but I like
yours better.
Many thanks!

----- Original Message -----
From: "DeptC2.Hugelier Alain" <Alain.Hugelier@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, October 24, 2002 7:06 AM
Subject: RE: [xsl] for-each attributes test


> Since every event contains the team the file belongs to, there are two
easy
> candidate-file-owners: the teams in the first event. You could determine
the
> file owner by simply counting the number of occurrences of these two
> candidate-file-owners:
>
> <xsl:template match="root">
> <!-- determine the two candidate-file-owners -->
> <xsl:variable name="team1"
> select="event[1]/team[1]/team-metadata/@team-key"/>
> <xsl:variable name="team2"
> select="event[1]/team[2]/team-metadata/@team-key"/>
> <!-- count their occurrences -->
> <xsl:variable name="nbr_team1"
> select="count(event/team/team-metadata[@team-key=$team1])"/>
> <xsl:variable name="nbr_team2"
> select="count(event/team/team-metadata[@team-key=$team2])"/>
> <!-- select the one with the most occurrences -->
> <xsl:element name="team-owner">
> <xsl:choose>
> <xsl:when test="$nbr_team1 >=  $nbr_team2">
> <xsl:value-of select="$team1"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$team2"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:element>
> </xsl:template>
>
> Alain
> -----Original Message-----
> From: Jason S [mailto:jasonsmith@xxxxxxxxxxx]
> Sent: woensdag 23 oktober 2002 22:10
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] for-each attributes test
>
>
> Hello.
>
> I have many xml files containing event elements as show below. Each file
is
> specific to a certain team. The only way I have to determine which team
goes
> with which file is by examining the team-key attributes within the
> team-metadata elements. As you see, team-6 repeats in each set of
> team-metadata for each event, thus, this file belongs to team-6. I need to
> be able to loop through the teams and determine which team key is
repeating
> in multiple events. In the end, I am trying to capture the recurring
> team-key for each file in order to identify which team the file belongs
to.
> Any suggestions?
>
> Thanks in advance
> Jason S
>
> <event>
>   <team>
>      <team-metadata team-key="team-18">
>      </team-metadata>
>   </team>
>   <team>
>      <team-metadata team-key="team-6" >
>      </team-metadata>
>   </team>
> </event>
>
> <event>
>  <team>
>      <team-metadata team-key="team-6">
>      </team-metadata>
>  </team>
>   <team>
>      <team-metadata team-key="team-18" >
>      </team-metadata>
>   </team>
> </event>
>
> <event>
>  <team>
>      <team-metadata team-key="team-3">
>      </team-metadata>
>  </team>
>  <team>
>      <team-metadata team-key="team-6" >
>      </team-metadata>
>
>  </team>
> </event>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread