cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Mapping - Condition

Former Member
0 Kudos

Hello All,

I have a requirement to check the condition and apply the values for a given field in an xml.

I need to check the value of phoneType and replace the value with different value stored in parameter.

Like H is to be replaced with '450' and C with '452'.How to do this.Please help.

<PerPhone>

<PerPhone>

<phoneType>H</phoneType>

<phoneNumber>778-085-2109</phoneNumber> <personIdExternal>154</personIdExternal>

<isPrimary>t</isPrimary>

</PerPhone>

<PerPhone>

<phoneType>C</phoneType>

<phoneNumber>778-085-2109</phoneNumber> <personIdExternal>154</personIdExternal>

<isPrimary>f</isPrimary>

</PerPhone>

</PerPhone>


I tried below.

<xsl:template match="/Employee/PerPhone/PerPhone/phonetype[contains(text(),'H')]">

<xsl:if test="/Employee/PerPhone/PerPhone[contains(phoneType,'H')]">

<xsl:value-of select="$PhoneType_H"/> </xsl:if> </xsl:template> <xsl:template match="/Employee/PerPhone/PerPhone/phonetype[contains(text(),'C')]">

<xsl:if test="/Employee/PerPhone/PerPhone[contains(phoneType,'C')]"> <xsl:value-of select="$PhoneType_C"/>

</xsl:if>

</xsl:template


Reagrds,

Tibin

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Sriprasad,

I am getting H and C 'internal code' values querying PICKLIST api from successfactors.

I need to replace H and C values with those Internal code ..In dev for example , 450 and 452 explained in above post.

Once I get this internal code values I am setting it in HCI content modifier property ( PhoneType_H and PhoneType_C) using groovy script.

I am doing the same for employee class as below and Is working .Since we have multiple phone type's ( occurrence is 2) , I am unable to refer which occurrence is for H and which is for C in my input xml to replace the value dynamically .I hope you understood my problem.

<xsl:template match="/Employee/EmpJob/EmpJob/employeeClass/text()">
		<xsl:value-of select="$EmployeeClass"/>
	</xsl:template>

Reagrds,
Tibin
Former Member
0 Kudos

input-xml.txtHello Sriprasad,

Thank you for the technical input,

Basically, I don't want to hardcode the value 450 and 452 in mapping,because those parameter values are coming dynamically, varies in DEV and PRD systems. I am filling the below values for 450 (PhoneType_H)and 452(PhoneType_C), How can I make use of this.Also I have other nodes as well in the XSLT .

<xsl:param name="PhoneType_H"/>

<xsl:param name="PhoneType_C"/>

Attached the xslt and input and output xml I got.Please guide.

Regards,

Tibin

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Tibin,

Got your requirement.To set the values dynamically you must have 2 information.

1) To set the dynamic value you must have values right i.e for Prod and Dev and want to know from where you are getting values like 450 and 452 ,whether its part of your incoming XML.

2) Condition on which you will decide what value needs to be passed [ May be If you have some field in incoming XML will give this info like SYSID= QA or SYSID= DEV ].

Regards,

Sriprasad Shivaram Bhat

Former Member
0 Kudos

Hi Sriprasad,

I am getting H and C 'internal code' values querying PICKLIST api from successfactors.

I need to replace H and C values with those Internal code ..In dev for example , 450 and 452 explained in above post.

Once I get this internal code values I am setting it in HCI content modifier property ( PhoneType_H and PhoneType_C) using groovy script.

I am doing the same for employee class as below and Is working .Since we have multiple phone type's ( occurrence is 2) , I am unable to refer which occurrence is for H and which is for C in my input xml to replace the value dynamically .I hope you understood my problem.

<xsl:template match="/Employee/EmpJob/EmpJob/employeeClass/text()">
		<xsl:value-of select="$EmployeeClass"/>
	</xsl:template>

Reagrds,
Tibin
Sriprasadsbhat
Active Contributor
0 Kudos

Hello Tibin,

Below code will do the same.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="/">
        <PerPhone>
            <xsl:for-each select="//PerPhone/PerPhone">
                <PerPhone>
                    <xsl:variable name="Var_PhoneType">
                        <xsl:value-of select="phoneType"/>                    
                    </xsl:variable>    
                    <phoneType>
                        <xsl:call-template name="PHONE_TYPE_LOOKUP">
                            <xsl:with-param name="PHONETYPE" select="$Var_PhoneType"/>
                        </xsl:call-template>
                    </phoneType>
                    <phoneNumber>
                        <xsl:value-of select="phoneNumber"/>                               
                    </phoneNumber>
                    <personIdExternal>
                        <xsl:value-of select="personIdExternal"/>
                    </personIdExternal>
                    <isPrimary>
                        <xsl:value-of select="isPrimary"/>
                    </isPrimary>
                </PerPhone>
            </xsl:for-each>
        </PerPhone>
    </xsl:template>    

    <xsl:template name="PHONE_TYPE_LOOKUP">
        <xsl:param name="PHONETYPE"/>
        <xsl:choose>
            <xsl:when test="$PHONETYPE='H'">
                <xsl:text>450</xsl:text>
            </xsl:when>
        </xsl:choose>        
        <xsl:choose>
            <xsl:when test="$PHONETYPE='C'">
                <xsl:text>452</xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>    
</xsl:stylesheet>

Regards

Sriprasad Shivaram Bhat