|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Counting matching elements across two documents
I process two documents with this stylesheet. The main document is a file called "matches.xml". The secondary document is a file called "roster.xml" (accessed via the document() function). The structures of the two input documents are:
matches.xml
===========
<matches>
<week>
<number>1</number>
<match>
<race-to>60</race-to>
<player>
<number>1</number>
<spot>0</spot>
<score>51</score>
<lag>L</lag>
<paid>2.50</paid>
</player>
<player>
<number>2</number>
<spot>16</spot>
<score>60</score>
<lag>W</lag>
<paid>5</paid>
</player>
</match>
<!-- More matches here -->
<week>
<!-- More weeks here -->
</matches>
roster.xml
===========
<players>
<player established="yes" >
<number>5</number>
<lname>Knell</lname>
<fname>Charles</fname>
<handy-cap-history>
<rating week-num="1">55.0</rating>
</handy-cap-history>
</player>
<!-- More players here -->
</players>
The section of the stylesheet that's giving me problems is this:
================================================================
<xsl:for-each select="$roster/players/player">
<xsl:sort select="lname" data-type="text" order="ascending" />
<tr><td><xsl:value-of select="concat(lname,', ', fname)" /></td><td><xsl:value-of select="count(//player[number = ./number])" /></td></tr>
</xsl:for-each>
The shorthand way of saying what I'm looking for is "I want to count all the W's for each player."
A more detailed, but more long-winded explanation is, I am trying to count all the "/matches/week/match/player/lag" elements with a value of "W" for each "$roster/players/player" element where the value of the "number" child of the current "$roster/players/player" matches any "/matches/week/match/player/number" element, but so far I can't work out the proper XPath expression. I have been successful in returning the total number of players in the roster or the total number of matches played, unfortunately, neither is what I'm looking for.
Can someone point out the correct XPath expression, please?
--
Charles Knell
cknell@xxxxxxxxxx - email
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








