thanks for the solution. I have 1 more minor question if you don't mind, how do I apply alternating row color for this case (using css class)?
Main Topics
Browse All TopicsI have the following XML :
<Product>
<RequirementList>
<Requirement>
<RequirementId>55</Require
<RequirementValue>TEST</Re
</Requirement>
<Requirement>
<RequirementId>55</Require
<RequirementValue>TEST</Re
</Requirement>
<Requirement>
<RequirementId>56</Require
<RequirementValue>APPLE</R
</Requirement>
<Requirement>
<RequirementId>56</Require
<RequirementValue>APPLE</R
</Requirement>
</RequirementList>
</Product>
I would like to return a List of RequirementId and RequirementValue with Distinct RequirementID
Expected result :
Requirements
------------------
55 TEST
56 APPLE
I'm using XSLT, however the code below only returned me a list of distinct requirementId, how do I make it to return also the associated RequirementValue?
<table border="0" width="500" id="tblDetReq" cellpadding="0">
<tr>
<Th colspan="2">Requirements</
</tr>
<xsl:for-each select="Product/Requiremen
<tr class="outputtext">
<td align="left">
<xsl:value-of select="."/>
</td>
<td align="left">
<xsl:value-of select ="RequirementValue"/>
</td>
</tr>
</xsl:for-each>
</table>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
you can use the position() function of an element for this. If the position mod 2 is 1, then it's an odd row ... otherwise an even row, and you can apply different css classes.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.o
xmlns:saxon="http://icl.co
<xsl:template match="/">
<table border="0" width="500" id="tblDetReq" cellpadding="0">
<tr>
<Th colspan="2">Requirements</
</tr>
<xsl:for-each
select="Product/Requiremen
<tr class="outputtext">
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">evenRow</xsl:
</xsl:if>
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="class">oddRow</xsl:a
</xsl:if>
<td align="left">
<xsl:value-of select="."/>
</td>
<td align="left">
<xsl:value-of select="../RequirementValu
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Business Accounts
Answer for Membership
by: enachemcPosted on 2006-11-30 at 00:43:03ID: 18043711
<table border="0" width="500" id="tblDetReq" cellpadding="0"> Th> tList/Requ irement/Re quirementI d[not(.=pr eceding::R equirement Id)]"> e"/>
<tr>
<Th colspan="2">Requirements</
</tr>
<xsl:for-each select="Product/Requiremen
<tr class="outputtext">
<td align="left">
<xsl:value-of select="."/>
</td>
<td align="left">
<xsl:value-of select="../RequirementValu
</td>
</tr>
</xsl:for-each>
</table>