Skip to Content

XSLT not working as expected in SCPI

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 21, 2019 at 08:53 AM

    Hi Prashant

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

    Regards,

    Morten

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.