I have a xSLT file like this
<?xml version="1.0" encoding="UTF-8" ?>
<!-- New document created with EditiX at Thu Feb 18 19:08:23 IST 2016 -->
<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">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="DIVISION_CODE">
47
</xsl:variable>
<xsl:variable name="DEPT_CODE">
KT
</xsl:variable>
<xsl:variable name="JOB_LEVEL">
4B
</xsl:variable>
<xsl:variable name="MI_GROUP">
</xsl:variable>
<xsl:variable name="A_Div_Code">
47,48,49,50
</xsl:variable>
<xsl:variable name="A_Dept_Code">
KT,VT,SF,MQ
</xsl:variable>
<xsl:variable name="A_Job_Level">
4B,2B,7B
</xsl:variable>
<xsl:variable name="D_Div_Code">
70,65,42,31
</xsl:variable>
<xsl:variable name="D_Dept_Code">
LM,MX,PQ
</xsl:variable>
<xsl:variable name="D_Job_Level">
4D,2D,3D
</xsl:variable>
<xsl:variable name="C_Div_Code">
12,76,31
</xsl:variable>
<xsl:variable name="C_Dept_Code">
ML,KL,KO
</xsl:variable>
<xsl:variable name="C_Job_Level">
4C,2C,7C
</xsl:variable>
</xsl:stylesheet>
So basically I have 3 variables which will have data from server
<xsl:variable name="DIVISION_CODE">
47
</xsl:variable>
<xsl:variable name="DEPT_CODE">
KT
</xsl:variable>
<xsl:variable name="JOB_LEVEL">
4B
</xsl:variable>
I have to check these variables against the other predefined variables.
My Sudo Code is as follow
If ( A_Div_Code contain '$DIVISION_CODE') and ( A_Dept_Code contains '$DEPT_CODE') and (A_job_Level contains '$JOB_LEVEL)
MP_GROUP='A'
I learnt on W3chools that I will have to use
<xsl:choose></xsl:choose>
But I don't know how to target the variable
Can any one give me an example?
UPDATED XSLT FILES
<?xml version="1.0" encoding="UTF-8" ?>
<!-- New document created with EditiX at Thu Feb 18 19:08:23 IST 2016 -->
<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">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="DIVISION_CODE" select="'47'" />
<xsl:variable name="DEPT_CODE" select="'KT'" />
<xsl:variable name="JOB_LEVEL" select="4B''" />
<xsl:variable name="A_Div_Code" select="'47,48,49,50
'" />
<xsl:variable name="A_Dept_Code" select="'KT,VT,SF,MQ
'" />
<xsl:variable name="A_Job_Level" select="'4B,2B,7B
'" />
<xsl:variable name="D_Div_Code" select="'70,65,42,12,76,31,47,48,49,50
'" />
<xsl:variable name="D_Dept_Code" select="'LM,MX,PQ,ML,KL,KO
,KT,VT,SF,MQ
'" />
<xsl:variable name="D_Job_Level" select="'4D,2D,3D
,4C,2C,7C,4B,2B,7B'" />
<xsl:variable name="C_Div_Code" select="'12,76,31,47,48,49,50
'" />
<xsl:variable name="C_Dept_Code" select="'ML,KL,KO
,KT,VT,SF,MQ
'" />
<xsl:variable name="C_Job_Level" select="'4C,2C,7C,4B,2B,7B
'" />
<xsl:choose>
<xsl:when test="contains($A_Div_Code, $DIVISION_CODE) and contains($A_Dept_Code, $DEPT_CODE) and contains($A_job_level, $JOB_LEVEL)">
<xsl:variable name="MI_GROUP" select="'A
'" />
</xsl:when>
<xsl:when test="contains($C_Div_Code, $DIVISION_CODE) and contains($C_Dept_Code, $DEPT_CODE) and contains($C_job_level, $JOB_LEVEL)">
<xsl:variable name="MI_GROUP" select="'A
,C'" />
</xsl:when>
<xsl:when test="contains($D_Div_Code, $DIVISION_CODE) and contains($D_Dept_Code, $DEPT_CODE) and contains($D_job_level, $JOB_LEVEL)">
<xsl:variable name="MI_GROUP" select="'A
,C,D'" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="MI_GROUP" select="'A
,C,D,Z'" />
</xsl:otherwise>
</xsl:choose>
</xsl:stylesheet>
Error
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.
Thanks