title: When / Otherwise not working as expected (Microsoft Visual Studio)
body: <p>I've been struggling getting the output formatted the way I want but I'm just not using xsl often enough.</p>
  
  <p>This need to generate a table, it only extracts the information if there is a value in the node named 'Active' but when there is no data or value named 'Counted Licenses' it should put a blank field in by calling a template.</p>
  
  <p>It does create that field but always and not only when the 'Counted Licenses' entry doesn't exist. Where do I go wrong?</p>
  
  <p>Thanks for your time.</p>
  
  <p>This is the XSLT:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
                                xmlns:exsl="http://exslt.org/common"&gt;
  
    &lt;xsl:output method="html" encoding="utf-8" indent="yes"/&gt;
    &lt;xsl:template match="/"&gt;
      &lt;html&gt;
        &lt;body&gt;
          &lt;table border="1"&gt;
            &lt;tr&gt;
              &lt;td&gt;
                &lt;strong&gt;User&lt;/strong&gt;
              &lt;/td&gt;
              &lt;td&gt;
                &lt;strong&gt;Counted License&lt;/strong&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr style="text-align:center;font-seize:8px;"&gt;
              &lt;xsl:for-each select="registry/k/k/k/k/k/k/k/k/k"&gt;
                &lt;xsl:for-each select="k"&gt;
                  &lt;xsl:if test="@name='UserInfo'"&gt;
                    &lt;xsl:for-each select="k"&gt;
                      &lt;xsl:for-each select="v"&gt;
                        &lt;xsl:choose&gt;
                          &lt;xsl:when test="@name='Active'"&gt;
                            &lt;tr style="text-align:center;font-seize:8px;"&gt;
                              &lt;td&gt;&lt;xsl:value-of select="../@name"/&gt;&lt;/td&gt;
                              &lt;xsl:for-each select="../v"&gt;
                                &lt;xsl:choose&gt;
                                  &lt;xsl:when test="@name='Counted Licenses'"&gt;
                                    &lt;td&gt;&lt;xsl:value-of select="@value"/&gt;&lt;/td&gt;
                                  &lt;/xsl:when&gt;
                                  &lt;xsl:when test="@name='snCreated' or @name='snModified'"&gt;
                                    &lt;!-- DO NOTHING --&gt;
                                  &lt;/xsl:when&gt;
                                  &lt;xsl:otherwise&gt;
                                    &lt;!-- CREATE BLANK FIELD --&gt;
                                  &lt;xsl:call-template name="blank" /&gt;
                                  &lt;/xsl:otherwise&gt;
                                &lt;/xsl:choose&gt;
                              &lt;/xsl:for-each&gt;
                            &lt;/tr&gt;
                          &lt;/xsl:when&gt;
                        &lt;/xsl:choose&gt;
                      &lt;/xsl:for-each&gt;
                    &lt;/xsl:for-each&gt;
                  &lt;/xsl:if&gt;
                &lt;/xsl:for-each&gt;
              &lt;/xsl:for-each&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/body&gt;
      &lt;/html&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="green" name="blank"&gt;
      &lt;td&gt;blank&amp;#160;&lt;/td&gt;
  
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>This is the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;registry&gt;
    &lt;k name="HKEY_LOCAL_MACHINE"&gt;
      &lt;k name="SOFTWARE"&gt;
        &lt;k name="Interactive Intelligence"&gt;
          &lt;k name="EIC"&gt;
            &lt;k name="Directory Services"&gt;
              &lt;k name="Root"&gt;
                &lt;k name="CustomerSite"&gt;
                  &lt;k name="Production"&gt;
                    &lt;k name="AdminConfig"&gt;
                      &lt;v name="snCreated" value="0x00000006 (6)" type="REG_DWORD" /&gt;
                      &lt;v name="snModified" value="0x01434cf0 (21187824)" type="REG_DWORD" /&gt;
                      &lt;k name="StationInfo"&gt;
                        &lt;v name="snCreated" value="0x00000007 (7)" type="REG_DWORD" /&gt;
                        &lt;v name="snModified" value="0x01434cf2 (21187826)" type="REG_DWORD" /&gt;
                        &lt;k name="00a95557-c3f6-4c45-b2b8-ebc56c0d00f6"&gt;
                          &lt;v name="snCreated" value="0x00000008 (8)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x00000008 (8)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x00000009 (9)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x00000009 (9)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="01b01517-8743-4219-9535-20dd37600ee5"&gt;
                          &lt;v name="snCreated" value="0x0000000a (10)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x0000000a (10)" type="REG_DWORD" /&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x0000000b (11)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x0000000b (11)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="06e2a817-7399-417a-b462-6c0b5cf3baee"&gt;
                          &lt;v name="snCreated" value="0x0000000c (12)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x0000000c (12)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x0000000d (13)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x0000000d (13)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="NLISM002"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_LICENSE_BASIC_STATION" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x0000032e (814)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x0000032e (814)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x0000032f (815)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x0000032f (815)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="NLISM003"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_LICENSE_BASIC_STATION" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x00000330 (816)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x00000330 (816)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x00000331 (817)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x00000331 (817)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="PHGSM311"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_LICENSE_BASIC_STATION" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x012da8c6 (19769542)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x012dab55 (19770197)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x012da8c7 (19769543)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x012dab56 (19770198)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                      &lt;/k&gt;
                      &lt;k name="UserInfo"&gt;
                        &lt;v name="snCreated" value="0x0000046c (1132)" type="REG_DWORD" /&gt;
                        &lt;v name="snModified" value="0x01434cf1 (21187825)" type="REG_DWORD" /&gt;
                        &lt;k name="User.A"&gt;
                          &lt;v name="Counted Licenses" value="I3_ACCESS_ACD_MEDIA_3_PLUS I3_ACCESS_CLIENT I3_ACCESS_DIALER_ADDON I3_ACCESS_INTERACTION_SCRIPTER_ADDON I3_ACCESS_RECORDER" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x005c21b8 (6037944)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x005c2223 (6038051)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x005c21b9 (6037945)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x005c2224 (6038052)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="Test_USER_2"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_ACCESS_ACD_MEDIA_3_PLUS I3_ACCESS_CLIENT I3_ACCESS_DIALER_ADDON I3_ACCESS_DIALER_SUPERVISOR_PLUGIN I3_ACCESS_HISTORICAL_REPORT_SUPERVISOR_PLUGIN I3_ACCESS_INTERACTION_SCRIPTER_ADDON I3_ACCESS_RECORDER I3_ACCESS_WORKGROUP_SUPERVISOR_PLUGIN" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x00ec87e0 (15501280)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x00ec8862 (15501410)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x00ec87e1 (15501281)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x00ec8863 (15501411)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="User.B"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_ACCESS_ACD_MEDIA_3_PLUS I3_ACCESS_CLIENT I3_ACCESS_DIALER_ADDON I3_ACCESS_INTERACTION_SCRIPTER_ADDON I3_ACCESS_RECORDER" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x00000957 (2391)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x008cf75b (9238363)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x00000958 (2392)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x008cf75c (9238364)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="User_John"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_ACCESS_ACD_MEDIA_3_PLUS I3_ACCESS_CLIENT I3_ACCESS_DIALER_ADDON I3_ACCESS_DIALER_SUPERVISOR_PLUGIN I3_ACCESS_HISTORICAL_REPORT_SUPERVISOR_PLUGIN I3_ACCESS_INTERACTION_SCRIPTER_ADDON I3_ACCESS_RECORDER I3_ACCESS_REPORT_ASSISTANT_SUPERVISOR_PLUGIN I3_ACCESS_WORKGROUP_SUPERVISOR_PLUGIN" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x00000959 (2393)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x013e612f (20865327)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x0000095a (2394)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x013e6130 (20865328)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="Test_USER_1"&gt;
                          &lt;v name="Active" value="No" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x0000095b (2395)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x008c0239 (9175609)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x0000095c (2396)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x008c0238 (9175608)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="Theodora.User"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_ACCESS_ACD_MEDIA_3_PLUS I3_ACCESS_CLIENT I3_ACCESS_DIALER_ADDON I3_ACCESS_INTERACTION_SCRIPTER_ADDON I3_ACCESS_RECORDER" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x0000095d (2397)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x008cf75d (9238365)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x0000095e (2398)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x008cf75e (9238366)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                        &lt;k name="Thomas.Tank"&gt;
                          &lt;v name="Active" value="Yes" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="Counted Licenses" value="I3_ACCESS_ACD_MEDIA_3_PLUS I3_ACCESS_CLIENT I3_ACCESS_DIALER_ADDON I3_ACCESS_INTERACTION_SCRIPTER_ADDON I3_ACCESS_RECORDER" type="REG_MULTI_SZ" /&gt;
                          &lt;v name="snCreated" value="0x0000095f (2399)" type="REG_DWORD" /&gt;
                          &lt;v name="snModified" value="0x0000095f (2399)" type="REG_DWORD" /&gt;
                          &lt;k name="Qualifiers"&gt;
                            &lt;v name="snCreated" value="0x00000960 (2400)" type="REG_DWORD" /&gt;
                            &lt;v name="snModified" value="0x00000960 (2400)" type="REG_DWORD" /&gt;
                          &lt;/k&gt;
                        &lt;/k&gt;
                      &lt;/k&gt;
                    &lt;/k&gt;
                  &lt;/k&gt;
                &lt;/k&gt;
              &lt;/k&gt;
            &lt;/k&gt;
          &lt;/k&gt;
        &lt;/k&gt;
      &lt;/k&gt;
    &lt;/k&gt;
  &lt;/registry&gt;
  </code></pre>
  
  <p>below a screenshot from the output received and expected:</p>
  
  <p><a href="https://i.stack.imgur.com/ak3qB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ak3qB.png" alt="enter image description here"></a></p>