title: Looking up XML attributes with wildcard values, using XSL
body: <p>The task of my little piece of XSL is to go through all the OptionRef tags in the XML file and to print the id and the displayName attributes for the OptionRef tags. The id´s are looked-up in the Options section to find displayName.</p>
  
  <p>And now, the problem: 
  Some of the OptionRef id attributes use wildcards (*) as part of their values. These id´s cannot be looked-up with regards to displayName, unless they first get resolved to real id´s found in the Options section. Is there some way to extend the XSL to do this kind of "globbing"?</p>
  
  <p>I would like to print the id´s and displayNames of all the id´s that are matching the wildcard.
  For instance "A01*" will match both "A0101" and "A0102" in the Options section, so these id´s and their display names should be printed.</p>
  
  <p>This is a sample of the XML:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;OptionList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
          &lt;Group&gt;
              &lt;OptionRef id="A0102"/&gt;
              &lt;OptionRef id="A03"/&gt;
              &lt;OptionRef id="A04"/&gt;
              &lt;OptionRef id="A0101"/&gt;
              &lt;OptionRef id="A0102"/&gt;
              &lt;OptionRef id="B01"/&gt;
          &lt;/Group&gt;
          &lt;Options&gt;
              &lt;Option displayName="Option A02" id="A02"/&gt;
              &lt;Option displayName="Option A03" id="A03"/&gt;
              &lt;Option displayName="Option A0101" id="A0101"/&gt;
              &lt;Option displayName="Option A0102" id="A0102"/&gt;
              &lt;Option displayName="Option A04" id="A04"/&gt;
              &lt;Option displayName="Option B01" id="B01"/&gt;
          &lt;/Options&gt;
          &lt;Rules&gt;
              &lt;Opportunities&gt;
                  &lt;OptionRef id="A01*"&gt;
                      &lt;OptionRef id="A03"/&gt;
                      &lt;OptionRef id="A04"/&gt;
                  &lt;/OptionRef&gt;
              &lt;/Opportunities&gt;
              &lt;Problems&gt;
                  &lt;Problem&gt;
                      &lt;OptionRef id="A03"/&gt;
                      &lt;OptionRef id="A04"/&gt;
                  &lt;/Problem&gt;
              &lt;/Problems&gt;
          &lt;/Rules&gt;
      &lt;/OptionList&gt;
  </code></pre>
  
  <p>This is the XSL:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
          &lt;xsl:output method="text" indent="yes"/&gt;
  
          &lt;xsl:key name="Option_Key" match="Option" use="@id"/&gt;
  
          &lt;xsl:template match="OptionRef" &gt;
             &lt;xsl:value-of select="@id"/&gt;: 
                  &lt;xsl:value-of select="key('Option_Key', @id)/@displayName"/&gt;
          &lt;/xsl:template&gt;
  
      &lt;/xsl:stylesheet&gt;
  </code></pre>