Tuesday, December 27, 2011

Get Unique values in XSLT

While working with dataview webpart, we some times have the requirement to get unique values from the xml data. The following code will help us to fetch unique values from an xml data

If you observe the xslt of the webpart, there will be a variable which is populated with all the rows

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />

change the above line of code with the below line

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[not (@Title=preceding-
sibling::Row/@Title)]" />

This will fetch the unique "Titles" from the xml data.



No comments:

Post a Comment