title: XSLT checking duplicate values
body: <p>I have an incoming XML like this:</p>
  
  <pre><code>&lt;comm&gt;
   &lt;source id ="1"&gt;TV&lt;/source&gt;
   &lt;source id ="2"&gt;Radio&lt;/source&gt;
   &lt;source id ="3"&gt;TV&lt;/source&gt;
   &lt;source id ="4"&gt;Computer&lt;/source&gt;
  &lt;/comm&gt;
  </code></pre>
  
  <p>I need an XSLT to make the output XML like this:</p>
  
  <pre><code>&lt;comm&gt;
   &lt;type id ="1"&gt;TV&lt;/source&gt;
   &lt;type id ="2"&gt;Radio&lt;/source&gt;
   &lt;type id ="4"&gt;Computer&lt;/source&gt;
  &lt;/comm&gt;
  </code></pre>
  
  <p>basically I want the XSLT to go through  every <code>&lt;source&gt;</code> element and create a <code>&lt;type&gt;</code> element. But if the value of the <code>&lt;type&gt;</code> element already exists, the XSLT will skip creating the element.
  As an example, if you look at the incoming XML the 'TV' value occurs twice; so the XSLT would create the element with the TV value only once.</p>
  
  <p>I am having a hard time figuring this out. I am using XSLT 2.0.</p>
  
  <p>I tried to do this by dynamically updating a variable, then removing duplicate values. But XSLT cant change variables.</p>