cancel
Showing results for 
Search instead for 
Did you mean: 

CPI Mapping-Script to filter Compound Employee response

foufou
Explorer
0 Kudos

Hello Experts,

In my scenario ,I have the following XML input file (in a very shortened form):

When replicating employees with multiple records of "PersonalDetails, the mapping works intermittently.

How can I keep only the personal_information record where end_date > =current date ?

I have applied the below standard function :

Filter und XSLT mapping :

/queryCompoundEmployeeResponse/CompoundEmployee [xs:date(person/personal_information/end_date) ge xs:date(current-date())]
?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:mode on-no-match="shallow-copy" />
  <xsl:template match="/queryCompoundEmployeeResponse/CompoundEmployee[xs:date(person/personal_information/end_date) ge current-date()]"/>
</xsl:stylesheet>

<br>

But this is not woking for me.Please let me know how can resolve this issue ?(Using XSLT mapping or Custum Function...)

Regards,

Fathi

View Entire Topic
MortenWittrock
Active Contributor

Hi Fathi

You are on the right track with the XSLT mapping, but you got the XPath expression slightly wrong. This should work (but I can't test it without sample documents):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:mode on-no-match="shallow-copy" />
  <xsl:template match="/queryCompoundEmployeeResponse/CompoundEmployee/person/personal_information[xs:date(end_date) lt current-date()]"/>
</xsl:stylesheet>

The trick here is to remove all personal_information elements, where the date is before the current date. Thus you keep only the one where the date is today's date or later.

Regards,

Morten

foufou
Explorer

Hi Morten ,

Your suggested solution worked perfectly :),

Thanks for the explanation and your tips, that really helps me a lot.

Regards

fathi

MortenWittrock
Active Contributor
0 Kudos

Hi fethi_men

Glad to hear it!

Regards,

Morten