This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Selecting distinct values based on an attribute


Hi, Perry,

For selecting distinct values , key and Muenchian method is one of reliable
approachs, especially when dealing with a large set of data in xml file.

Something like these;

<!-- define key using facilitytype attribute -->
<xsl:key name="facilityAtrr" match="facilities" use="@facilitytype"/>

<!-- define distinct set of facilities based on facility attributes -->
<xsl:variable name="facilityList"
select="//facilities[count(.|key('facilityAtrr', @facilitytype)[1]) = 1]"/>

<!-- data processing such as sorting,ouput...-->
<xsl:template match="/">
<xsl:for-each select="$facilityList">
<xsl:sort select="@facilitytype"/>
<xsl:value-of select="@facilitytype"/>
</xsl:for-each>
</xsl:template>

Hope it is useful to your applications.
Cheers,

Sun-fu Yang,


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]