Jump to content

how to find the unique value based on the attributes substring


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 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...