Jump to content
amsathishkumar

how to find the unique value based on the attributes substring

Recommended Posts

how to find the unique value based on the attributes substringExample<sample name="ao1_test"><sample name="ao2_test">I need the unique value of attribute name after underscore that'sOnly "test"

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...