Comparing two lists in xslt

We are currently displaying our naviagtion menu on our website from an XSLT that is retrieving nodes from the content tree under a certain node id. I have been attempting to put some security around which links are shown based on some user groups set in the Asp.Net session. For each content node that is showing as a link, we have a list of checkboxs defined in the document type, that relate to security groups the user might be in, and we only select the checkboxes for the users that should see the link/page. My hope is, using the xslt that already exists, if the user is in one of the groups checked when defining the link/page in the content tree , the link will show for them. So currently we have an xslt:for each that is grabbing each node > a certain id. Then I was attempting to nest two xslt: for-eachs, the outer iterating through the lists of groups the user is in (pulled from asp session) and the inner a list of which those groups has been selected from my custom check box. In my xslt  I'm using umbraco.libary:split which is going to give me two xml lists each of which are going to contain basically the following data:

Asp session value, UserGroup1,UserGroup2,UserGroup3

Values checked in checkbox for this page: UserGroup1,UserGroup3

So in my inner loop I compare my outer loop value to my inner loop value, and if they're the same, I show the user the link to the page. But if you see my example of data, the user is in both UserGroup1 and UserGroup3, and the page has both UserGroup1 and UserGroup3 boxes checked, so the user is going to see the same link twice. So I very quickly toyed with the idea of setting a flag in my inner loop and then checking it after my outer loop was done. Cant do that because of scope.

So, if I haven't totally confused you...how do I do this. I've seen examples of doing away with foreach and using recursive templates. That just made my head hurt.

 


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/29534-comparing-two-lists-in-xslt