Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • vikram anand bhushan 1 post 71 karma points
    Feb 19, 2016 @ 06:16
    vikram anand bhushan
    0

    How to use Choose condition on XSLT variable

    Hello Guys,

    I am new to XSLT , So putting up maybe really basic question .

    Well I will keep it short ,

    What I have to do is create three dummy variables (Which will be updated from server--LDAP ) and compare this against another set of variables ,After comparison I have to update the result in another variable and return that variable ,

    Here is the SUDO 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'
    If (C_Div_Code contain '$DIVISION_CODE') and  (C_Dept_Code contains '$DEPT_CODE') and (C_job_Level contains '$JOB_LEVEL)
    MP_GROUP='A,C'
    

    and the variables will be like this

    1.DIVISION_CODE : This variable will store the Division code received from LDAP for a user/file_id.
    Example :DIVISION_CODE":"48
    2.DEPT_CODE : This varaible will store the Department code received from LDAP for a user/file_id.
    Example :DEPT_CODE":"LT"
    3.JOB_LEVEL : This variable will store the Job level received from LDAP for a user/file_id 
    Example :JOB_LEVEL":"4B
    

    MI_GROUP : Which basically we be finding logically and sending to backend web server.

    Based on this I created following XSLT file ,

    <?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="MI_GROUP"  /> 
    
        <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="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:template match="/">
    
            <xsl:apply-templates/>
        </xsl:template>
    
    </xsl:stylesheet>
    

    So basically I will have to compare the Three variable against those department codes and update the MI_GROUP variable

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 24, 2016 @ 20:03
    Chriztian Steinmeier
    0

    Hi Vikram,

    I would love to see what you're really trying to output.

    E.g.: Is the macro only responsible for returning a value like A or A,C?

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft