Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to count matching nodes

Status
Not open for further replies.

mmormann

MIS
Sep 5, 2003
3
US
I have an xml file where I picked out several matching nodes and I want to count the matching nodes I find so I can put the items I test for from my xml file into a 4 column table. If there is another alternative please let me know.

Example of part of xsl so far...

<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?>
<xsl:stylesheet version=&quot;1.0&quot;
xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>
<html>
<body>
<h2>My CD Collection</h2>
<table border=&quot;1&quot;>
<tr bgcolor=&quot;#9acd32&quot;>
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select=&quot;catalog/cd&quot;>
<xsl:if test=&quot;price=10 or price=20 or price= 30&quot;>
<tr>
<td><xsl:value-of select=&quot;title&quot;/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

But I want the output to be in a table in 4 columns showing
the matching titles to the price I am looking for. I think if I can count the nodes that match, I could be able to do this, but above only puts it in 1 column where I would like 4 columns.

Output I want should look like below:
<tr>
<td>Empire Burlesque</td>
<td>Romanza</td>
<td>Black Angel</td>
<td>1999 grammee nominees</td></tr>
tr>
<td>Long Road</td>
<td>White Stripes</td>
<td>Black Album</td>
<td>Where is it?</td></tr>
 
Your xsl is confusing;
the table heading has 2 columns for title and artist, while the for-each part has only 1 column
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top