title: XSLT task: replicate a list of element for each element of a different list with exceptions
body: <p>I have some trouble trying to setup a template to solve address this situation:</p>
  
  <p>My xml looks like:</p>
  
  <pre><code>&lt;root&gt;
       &lt;recordset name="companies"&gt;
                 &lt;record&gt;
                      &lt;id&gt;1&lt;/id&gt;
                      &lt;description&gt;Company 1&lt;/description&gt;
                 &lt;/record&gt;
                 &lt;record&gt;&lt;id&gt;2&lt;/id&gt;&lt;description&gt;Company 2&lt;/description&gt;&lt;/record&gt;
                 ...
                 &lt;record&gt;&lt;id&gt;n&lt;/id&gt;&lt;description&gt;Company n&lt;/description&gt;&lt;/record&gt;
       &lt;/recordset&gt;
       &lt;gruppi&gt;
            &lt;supplier&gt;
                 &lt;agreement&gt;1&lt;/agreement&gt;
                 &lt;company&gt;
                      &lt;id&gt;3&lt;/id&gt;
                      &lt;description&gt;Compoany 3&lt;/description&gt;
                 &lt;/company&gt;
                 &lt;company&gt;
                      &lt;id&gt;7&lt;/id&gt;
                      &lt;description&gt;Company 7&lt;/description&gt;
                 &lt;/company&gt;
            &lt;/supplier&gt;
            ... &lt;!-- a lot of supplier --&gt; ...
            &lt;supplier&gt;
                 &lt;agreement&gt;3&lt;/agreement&gt;
                 &lt;company&gt;
                      &lt;id&gt;1&lt;/id&gt;
                      &lt;description&gt;Company 1&lt;/description&gt;
                 &lt;/company&gt;
                 &lt;company&gt;
                      &lt;id&gt;18&lt;/id&gt;
                      &lt;description&gt;Company 18&lt;/description&gt;
                 &lt;/company&gt;
            &lt;/supplier&gt;
       &lt;/gruppi&gt;        
  &lt;/root&gt;
  </code></pre>
  
  <p>My aim is to have a template able to perform the following processing: for each supplier within gruppi I wish to output a list of all record  within   recordset name="companies" EXCEPT for the record whose id is already contained in the  id element descendent of the current supplier element.</p>
  
  <p>In other words: for each supplier I should create a set of html options listing all the companies (id as values) not including the companies already included in the supplier</p>
  
  <p>I am tried to use xsl:key and some recursion but I found this task quite involved and I am running out of ideas. Someone has a hint to solve this problem?</p>
  
  <p>Thanks for any help!</p>
  
  <p>@polishchuk: the xml input is quite a big file, so I extracted the structure I am interested in filling with few generic data. About the output I am looking for something like this:</p>
  
  <pre><code>&lt;h1&gt;Agreement: 1&lt;/h1&gt;
  &lt;select&gt;
       &lt;option value="1"&gt;&lt;/option&gt;
            ....                                                  &lt;!-- WITHOUT values 3 and 7 --&gt;
       &lt;option value="N"&gt;&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;h1&gt;Agreement: 3&lt;/h1&gt;
  &lt;select&gt;
       &lt;option value="1"&gt;&lt;/option&gt;
            ....                                                  &lt;!-- WITHOUT values 1 and 18 --&gt;
       &lt;option value="N"&gt;&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>