cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT not working as expected in SCPI

0 Kudos

Hello,

I am writing a compound employee transformation xslt for job transfers. In case of a job transfer, I want the movement code for original employee as 'TERM' and for new employee, it should be 'NEWHR'. There are more fields in the output, but I am only attaching some of them here.

Here is the sample payload( readyforcompoundemployee.txt).

Following is the expected output (which is working in OXYGEN XML editor)

<EmployeeExtract>
   <UserInfo>
      <MovementCode>TERM</MovementCode>
      <ActionType>SUB</ActionType>
   </UserInfo>
   <UserInfo>
      <MovementCode>NEWHR</MovementCode>
      <date_of_birth>23-SEP-1962</date_of_birth>
      <ActionType>ADD</ActionType>
   </UserInfo>
</EmployeeExtract>

Following is the xslt I am using to build the output. It creates the expected output when I run it in Oxyen XML editor, but when I use the same xslt in HCI, it only returns 'NEWHR' and does not return 'TERM'.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:template match="/queryCompoundEmployeeResponse">
        <EmployeeExtract>
            <xsl:apply-templates select="CompoundEmployee"/>
        </EmployeeExtract>
    </xsl:template>
    <xsl:template match="CompoundEmployee">
        <xsl:apply-templates select="person">
            <xsl:with-param name="personidexternal" select="person/person_id_external"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="person">
        <xsl:param name="personidexternal"/>
        <xsl:if test=" ('Terminated'=employment_information/job_information[end_date >= xs:date(current-date()) 
            and xs:date(current-date()) >= start_date 
            and 'NO CHANGE'!=action]/emplStatus)">
            <UserInfo>
                <MovementCode>TERM</MovementCode>
                <ActionType>SUB</ActionType>
            </UserInfo>
        </xsl:if>
        <xsl:if test="'INSERT'=action or 'INSERT'=employment_information/action or
            'Dormant'=employment_information/job_information/emplStatus_previous">
            <UserInfo>
                <MovementCode>NEWHR</MovementCode>
                <date_of_birth> <xsl:value-of select="format-date(date_of_birth,'[D01]-[MN,*-3]-[Y0001]')"/> </date_of_birth>
                <ActionType>ADD</ActionType>
            </UserInfo>   
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

Can you please help me to locate the problem?

Regards,

Prashant

Accepted Solutions (0)

Answers (1)

Answers (1)

MortenWittrock
Active Contributor

Hi Prashant

Using your input XML and your stylesheet in CPI, I get exactly the output you expect.

Regards,

Morten