title: Removing Duplicate Values in Nodes using XSLT
body: <p>I have below XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;SLOCDETAILS&gt;
      &lt;INPUT&gt;
      &lt;/INPUT&gt;
      &lt;TABLES&gt;
          &lt;OUTPUT&gt;
              &lt;item&gt;
                  &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
                  &lt;SLOC&gt;T150&lt;/SLOC&gt;
                  &lt;MATNR&gt;220250&lt;/MATNR&gt;
                  &lt;CHARG&gt;112233&lt;/CHARG&gt;
              &lt;/item&gt;
              &lt;item&gt;
                  &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
                  &lt;SLOC&gt;T152&lt;/SLOC&gt;
                  &lt;MATNR&gt;220250&lt;/MATNR&gt;
                  &lt;CHARG&gt;223344&lt;/CHARG&gt;
              &lt;/item&gt;
              &lt;item&gt;
                  &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
                  &lt;SLOC&gt;T152&lt;/SLOC&gt;
                  &lt;MATNR&gt;220250&lt;/MATNR&gt;
                  &lt;CHARG&gt;445566&lt;/CHARG&gt;
              &lt;/item&gt;
              &lt;item&gt;
                  &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
                  &lt;SLOC&gt;T152&lt;/SLOC&gt;
                  &lt;MATNR&gt;220250&lt;/MATNR&gt;
                  &lt;CHARG&gt;667788&lt;/CHARG&gt;
              &lt;/item&gt;
              &lt;item&gt;
                  &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
                  &lt;SLOC&gt;T152&lt;/SLOC&gt;
                  &lt;MATNR&gt;220250&lt;/MATNR&gt;
                  &lt;CHARG&gt;998877&lt;/CHARG&gt;
              &lt;/item&gt;
          &lt;/OUTPUT&gt;
      &lt;/TABLES&gt;
  &lt;/SLOCDETAILS&gt;
  </code></pre>
  
  <p>My XSLT is as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" version="1.0"&gt;
      &lt;xsl:template match="/"&gt;
          &lt;Rowsets&gt;
              &lt;Rowset Name="List"&gt;
                  &lt;xsl:for-each select="SLOCDETAILS/TABLES/OUTPUT/item"&gt;
                      &lt;Row&gt;
                          &lt;PLANT&gt;
                              &lt;xsl:value-of select="PLANT"/&gt;
                          &lt;/PLANT&gt;
                          &lt;SLOC&gt;
                              &lt;xsl:value-of select="SLOC"/&gt;
                          &lt;/SLOC&gt;
                          &lt;Material&gt;
                              &lt;xsl:value-of select="MATNR"/&gt;
                          &lt;/Material&gt;
                          &lt;Batch&gt;
                              &lt;xsl:value-of select="CHARG"/&gt;
                          &lt;/Batch&gt;
                      &lt;/Row&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/Rowset&gt;
          &lt;/Rowsets&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>My resultant XML IS:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Rowsets&gt;
      &lt;Rowset Name="List"&gt;
          &lt;Row&gt;
              &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
              &lt;SLOC&gt;T150&lt;/SLOC&gt;
              &lt;Material&gt;220250&lt;/Material&gt;
              &lt;Batch&gt;112233&lt;/Batch&gt;
          &lt;/Row&gt;
          &lt;Row&gt;
              &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
              &lt;SLOC&gt;T152&lt;/SLOC&gt;
              &lt;Material&gt;220250&lt;/Material&gt;
              &lt;Batch&gt;223344&lt;/Batch&gt;
          &lt;/Row&gt;
          &lt;Row&gt;
              &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
              &lt;SLOC&gt;T152&lt;/SLOC&gt;
              &lt;Material&gt;220250&lt;/Material&gt;
              &lt;Batch&gt;445566&lt;/Batch&gt;
          &lt;/Row&gt;
          &lt;Row&gt;
              &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
              &lt;SLOC&gt;T152&lt;/SLOC&gt;
              &lt;Material&gt;220250&lt;/Material&gt;
              &lt;Batch&gt;667788&lt;/Batch&gt;
          &lt;/Row&gt;
          &lt;Row&gt;
              &lt;PLANT&gt;INDIA&lt;/PLANT&gt;
              &lt;SLOC&gt;T152&lt;/SLOC&gt;
              &lt;Material&gt;220250&lt;/Material&gt;
              &lt;Batch&gt;998877&lt;/Batch&gt;
          &lt;/Row&gt;
      &lt;/Rowset&gt;
  &lt;/Rowsets&gt;
  </code></pre>
  
  <p>Now I want only SLOC that are unique. So for this XML, the SLOC that should be populated should be <code>&lt;SLOC&gt;T150&lt;/SLOC&gt;</code> &amp; <code>&lt;SLOC&gt;T152&lt;/SLOC&gt;</code></p>
  
  <p><code>&lt;SLOC&gt;T152&lt;/SLOC&gt;</code> is being repeated 4 times. i want to avoid that.</p>
  
  <p>How can I achieve that using XSLT?</p>
  
  <p>I'm sure there is a grouping method that can be used. Also does XSLT provide distinct-value kind of function that we can plug &amp; play? Different approaches to resolve this issue will be very helpful.</p>
  
  <p>Thanks !</p>