title: How to apply if else statement on XSLT variable
body: <p>I have a xSLT file like this </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;!-- New document created with EditiX at Thu Feb 18 19:08:23 IST 2016 --&gt;
  
  &lt;xsl:stylesheet version="2.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fn="http://www.w3.org/2005/xpath-functions"
      xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
      xmlns:err="http://www.w3.org/2005/xqt-errors"
      exclude-result-prefixes="xs xdt err fn"&gt;
  
      &lt;xsl:output method="xml" indent="yes"/&gt;
  
      &lt;xsl:variable name="DIVISION_CODE"&gt;
      47
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="DEPT_CODE"&gt;
      KT
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="JOB_LEVEL"&gt;
      4B
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="MI_GROUP"&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="A_Div_Code"&gt;
      47,48,49,50
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="A_Dept_Code"&gt;
      KT,VT,SF,MQ
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="A_Job_Level"&gt;
      4B,2B,7B
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="D_Div_Code"&gt;
      70,65,42,31
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="D_Dept_Code"&gt;
      LM,MX,PQ
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="D_Job_Level"&gt;
      4D,2D,3D
      &lt;/xsl:variable&gt; 
  
      &lt;xsl:variable name="C_Div_Code"&gt;
      12,76,31
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="C_Dept_Code"&gt;
      ML,KL,KO
      &lt;/xsl:variable&gt;
      &lt;xsl:variable name="C_Job_Level"&gt;
      4C,2C,7C
      &lt;/xsl:variable&gt;  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>So basically I have 3 variables which will have data from server </p>
  
  <pre><code>&lt;xsl:variable name="DIVISION_CODE"&gt;
      47
  &lt;/xsl:variable&gt;
  &lt;xsl:variable name="DEPT_CODE"&gt;
      KT
  &lt;/xsl:variable&gt;
  &lt;xsl:variable name="JOB_LEVEL"&gt;
      4B
  &lt;/xsl:variable&gt;
  </code></pre>
  
  <p>I have to check these variables against the other predefined variables.</p>
  
  <p>My Sudo Code is as follow</p>
  
  <pre><code>If ( A_Div_Code contain '$DIVISION_CODE') and  ( A_Dept_Code contains '$DEPT_CODE') and (A_job_Level contains '$JOB_LEVEL)
  MP_GROUP='A'
  </code></pre>
  
  <p>I learnt on W3chools that I will have to use </p>
  
  <pre><code>&lt;xsl:choose&gt;&lt;/xsl:choose&gt;
  </code></pre>
  
  <p>But I don't know how to target the variable </p>
  
  <p>Can any one give me an example?</p>
  
  <p><strong>UPDATED XSLT FILES</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;!-- New document created with EditiX at Thu Feb 18 19:08:23 IST 2016 --&gt;
  
  &lt;xsl:stylesheet version="2.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fn="http://www.w3.org/2005/xpath-functions"
      xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
      xmlns:err="http://www.w3.org/2005/xqt-errors"
      exclude-result-prefixes="xs xdt err fn"&gt;
  
      &lt;xsl:output method="xml" indent="yes"/&gt;
  
      &lt;xsl:variable name="DIVISION_CODE" select="'47'" /&gt; 
      &lt;xsl:variable name="DEPT_CODE" select="'KT'" /&gt; 
      &lt;xsl:variable name="JOB_LEVEL" select="4B''" /&gt; 
  
  
  
  
  &lt;xsl:variable name="A_Div_Code" select="'47,48,49,50
  '" /&gt; 
  
  &lt;xsl:variable name="A_Dept_Code" select="'KT,VT,SF,MQ
  
  '" /&gt; 
  
  
  &lt;xsl:variable name="A_Job_Level" select="'4B,2B,7B
  '" /&gt; 
  
  
  
  &lt;xsl:variable name="D_Div_Code" select="'70,65,42,12,76,31,47,48,49,50
  
  '" /&gt; 
  
  &lt;xsl:variable name="D_Dept_Code" select="'LM,MX,PQ,ML,KL,KO
  ,KT,VT,SF,MQ
  
  
  '" /&gt; 
  
  
  &lt;xsl:variable name="D_Job_Level" select="'4D,2D,3D
  
  ,4C,2C,7C,4B,2B,7B'" /&gt;
  
  
  
  
  
  &lt;xsl:variable name="C_Div_Code" select="'12,76,31,47,48,49,50
  
  '" /&gt; 
  
  &lt;xsl:variable name="C_Dept_Code" select="'ML,KL,KO
  ,KT,VT,SF,MQ
  
  '" /&gt; 
  
  
  &lt;xsl:variable name="C_Job_Level" select="'4C,2C,7C,4B,2B,7B
  '" /&gt;
  
  
  
  
  &lt;xsl:choose&gt;
          &lt;xsl:when test="contains($A_Div_Code, $DIVISION_CODE) and contains($A_Dept_Code, $DEPT_CODE) and contains($A_job_level, $JOB_LEVEL)"&gt;
  
  
  &lt;xsl:variable name="MI_GROUP" select="'A
  '" /&gt; 
          &lt;/xsl:when&gt;
      &lt;xsl:when test="contains($C_Div_Code, $DIVISION_CODE) and contains($C_Dept_Code, $DEPT_CODE) and contains($C_job_level, $JOB_LEVEL)"&gt;
  
  
  &lt;xsl:variable name="MI_GROUP" select="'A
  ,C'" /&gt; 
          &lt;/xsl:when&gt;
         &lt;xsl:when test="contains($D_Div_Code, $DIVISION_CODE) and contains($D_Dept_Code, $DEPT_CODE) and contains($D_job_level, $JOB_LEVEL)"&gt;
  
  
  &lt;xsl:variable name="MI_GROUP" select="'A
  ,C,D'" /&gt; 
          &lt;/xsl:when&gt;
           &lt;xsl:otherwise&gt;
              &lt;xsl:variable name="MI_GROUP" select="'A
  ,C,D,Z'" /&gt; 
          &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>ERROR - Looks like XML you provided is not valid: Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.
  </code></pre>
  
  <p>Thanks </p>