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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create list of unique elements? 1

Status
Not open for further replies.

corsair2

IS-IT--Management
Feb 21, 2001
55
GB
Hi,

can anyone tell me if it's possible to generate a list of unique items (eg names) from an xml document using xslt?
I have a report in xml format which, among other things, lists userid with multiple occurrances of each. I'd like to be able to create a list of unique 'userid's to populate a drop-down list when the document is viewed in a browser.
Any ideas?

Regards
 
Have a look at this:

XML:
Code:
<list>
  <id>1</id>
  <id>2</id>
  <id>3</id>
  <id>2</id>
  <id>1</id>
</list>

XSL:
Code:
<xsl:template match=&quot;list&quot;>
  <xsl:for-each select=&quot;id&quot;>
    <xsl:sort select=&quot;.&quot;/>
    <xsl:if test=&quot;not(.=preceding::id)&quot;>
      <xsl:value-of select=&quot;.&quot;/>
    </xsl:if>
  </xsl:for-each>
</xsl:template>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top