Jump to content

how to find the unique value based on the attributes substring


amsathishkumar

Recommended Posts

With XSLT 2.0:

<xsl:value-of select="distinct-values(//sample/@name/substring-after(., '_'))"/>

With XSLT 1.0 you can use Muenchian grouping:

<xsl:key name="k1" match="sample/@name" use="substring-after(., '_')"/> <xsl:template match="/">  <xsl:apply-templates select="//sample/@name[generate-id() = generate-id(key('k1', substring-after(., '_'))[1])]"/></xsl:template> <xsl:template match="sample/@name">  <xsl:if test="position() > 1"><xsl:text> </xsl:text></xsl:if>  <xsl:value-of select="substring-after(., '_')"/></xsl:template>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...