title: Facing issue while using XSL to generate another XSL
body: <p>I am trying to interpret a query builder structure and transform it into xsl format.
  I intend to use XSL to generate another XSL structure. For the same I am making use of xsl:namespace-alias tag.</p>
  
  <p>I have roughly the following xml structure</p>
  
  <pre><code>&lt;rule&gt;
      &lt;criteria&gt;
           &lt;queryelement&gt;
               &lt;key&gt;employee_id&lt;/key&gt;
               &lt;op&gt;
                   &lt;code&gt;eq&lt;/code&gt;
                   &lt;label&gt;Equals&lt;/label&gt;
               &lt;/op&gt;
               &lt;value&gt;emp1&lt;/value&gt;         
           &lt;/queryelement&gt;
           &lt;queryelement&gt;
                &lt;code&gt;and&lt;/code&gt;
           &lt;/queryelement&gt;
           &lt;queryelement&gt;
               &lt;key&gt;salary&lt;/key&gt;
               &lt;op&gt;
                   &lt;code&gt;eq&lt;/code&gt;
                   &lt;label&gt;Equals&lt;/label&gt;
               &lt;/op&gt;
               &lt;value&gt;10000&lt;/value&gt;
           &lt;/queryelement&gt;
          &lt;evaluation&gt;
              &lt;value&gt;10&lt;/value&gt;
              &lt;type&gt;CONSTANT&lt;/type&gt;
          &lt;/evaluation&gt;            
      &lt;/criteria&gt;
      &lt;criteria&gt;
           &lt;queryelement&gt;
               &lt;key&gt;fname&lt;/key&gt;
               &lt;op&gt;
                   &lt;code&gt;eq&lt;/code&gt;
                   &lt;label&gt;Equals&lt;/label&gt;
               &lt;/op&gt;
               &lt;value&gt;first&lt;/value&gt;        
           &lt;/queryelement&gt;
          &lt;evaluation&gt;
              &lt;value&gt;20&lt;/value&gt;
              &lt;type&gt;CONSTANT&lt;/type&gt;
          &lt;/evaluation&gt;            
      &lt;/criteria&gt; 
  &lt;/rule&gt;
  </code></pre>
  
  <p>I need to write xsl to generate following output</p>
  
  <p>Expected output:</p>
  
  <pre><code>   &lt;xxx:when test="employee_id eq emp1 and salary eq 10000"&gt;
        &lt;xxx:value-of select="10"/&gt;
      &lt;/xxx:when&gt;
      &lt;xxx:when test="fname eq first"&gt;
        &lt;xxx:value-of select="20"/&gt;
     &lt;/xxx:when&gt;
  </code></pre>
  
  <p>The closest I have been able to do the same is using the below xsl:</p>
  
  <p>xsl applied:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xxx="my:dummyNS" exclude-result-prefixes="xxx"&gt;
   &lt;xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/&gt;
  &lt;xsl:template match="/"&gt;        
      &lt;xsl:for-each select="rule/criteria"&gt;
              &lt;xxx:when&gt;
                  &lt;xsl:for-each select="queryelement"&gt;
                      &lt;xsl:choose&gt;
                          &lt;xsl:when test="code"&gt;
                              &lt;xsl:variable name="code" select="code" /&gt;
                              &lt;xxx:value-of select="{$code}" /&gt;
                          &lt;/xsl:when&gt;
                          &lt;xsl:otherwise&gt;
                              &lt;xsl:variable name="key" select="key" /&gt;
                              &lt;xsl:variable name="code2" select="op/code" /&gt;
                              &lt;xsl:variable name="value" select="value" /&gt;
                              &lt;xxx:value-of select="{$key} {$code2} {$value}" /&gt;
                          &lt;/xsl:otherwise&gt;
                      &lt;/xsl:choose&gt;
                  &lt;/xsl:for-each&gt;                 
                  &lt;xsl:variable name="evaluation" select="evaluation/value" /&gt;
                  &lt;xxx:value-of select="{$evaluation}" /&gt;
              &lt;/xxx:when&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>And the output obtained:</p>
  
  <pre><code>&lt;xxx:when&gt;
    &lt;xxx:value-of select="employee_id eq emp1"/&gt;
    &lt;xxx:value-of select="and"/&gt;
    &lt;xxx:value-of select="salary eq 10000"/&gt;
    &lt;xxx:value-of select="10"/&gt;
  &lt;/xxx:when&gt;
  &lt;xxx:when&gt;
    &lt;xxx:value-of select="fname eq first"/&gt;
    &lt;xxx:value-of select="20"/&gt;
  &lt;/xxx:when&gt;
  </code></pre>
  
  <p>The issue I am mainly facing is to create a variable which accumulates text content of the nodes and store into variable and use it in the test condition for </p>