By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,192 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,192 IT Pros & Developers. It's quick & easy.

XSLT selecting unique records

P: 17
How do you select unique records?
For example, if my data is like the following and I only want the repeated data (address information) to appear once for each theater_id.
<xsl:for-each select="Table"> ????



<Table>
<device_id>26</device_id>
<serial_number>200102</serial_number>
<is_active>true</is_active>
<commission_date>2006-01-10T00:00:00-05:00</commission_date>
<theater_id>00000056</theater_id>
<theater_name>Ultra Star La Costa 6</theater_name>
<street_address1>6941 El Camino Real</street_address1>
<street_address2 />
<street_city>Carlsbad</street_city>
<street_state>CA </street_state>
<street_zip_code>92009-4108</street_zip_code>
<street_country_id>USA</street_country_id>
<screen_no>1</screen_no>
</Table>
<Table>
<device_id>27</device_id>
<serial_number>200713</serial_number>
<is_active>true</is_active>
<commission_date>2006-01-10T00:00:00-05:00</commission_date>
<theater_id>00000056</theater_id>
<theater_name>Ultra Star La Costa 6</theater_name>
<street_address1>6941 El Camino Real</street_address1>
<street_address2 />
<street_city>Carlsbad</street_city>
<street_state>CA </street_state>
<street_zip_code>92009-4108</street_zip_code>
<street_country_id>USA</street_country_id>
<screen_no>1</screen_no>
</Table>
Jul 23 '07 #1
Share this Question
Share on Google+
3 Replies


jkmyoung
Expert 100+
P: 2,057
http://www.jenitennison.com/xslt/grouping/muenchian.html

The easiest way would be something like:
<xsl:for-each select="Table[not (theater_id = previous-sibling::Table/theater_id)]">

A more efficient way would involve use of keys, see the link provided.
Jul 23 '07 #2

P: 17
Thanks!
I already tried your recommendation and it works.
I also looked at using the "keys" method but can't get it to work. I'll keep trying.
Jul 24 '07 #3

jkmyoung
Expert 100+
P: 2,057
Would look something like this:
<xsl:for-each select="Table[count(. | key('TableByTheaterid', theater_id)[1]) = 1]">
Jul 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.