I have the following xml:
<?xml version="1.0" encoding="utf-8"?>
<peci:Worker_Effective_Stack_Aggregate xmlns:peci="urn:com.workday/peci">
<peci:Workers_Effective_Stack xmlns:peci="urn:com.workday/peci">
<peci:Summary>
<peci:Integration_Event>6d374dcbe3a81024090d271cab840000</peci:Integration_Event>
</peci:Summary>
<peci:Worker>
<peci:Worker_Summary>
<peci:Employee_ID>328556</peci:Employee_ID>
</peci:Worker_Summary>
<peci:Effective_Change peci:Sequence="0">
<peci:Derived_Event_Code>HIR</peci:Derived_Event_Code>
<peci:Effective_Moment>2022-07-27T00:00:00.000-07:00</peci:Effective_Moment>
<peci:Entry_Moment>2022-07-27T03:24:11.531-07:00</peci:Entry_Moment>
</peci:Effective_Change>
<peci:Effective_Change peci:Sequence="1">
<peci:Derived_Event_Code>DTA</peci:Derived_Event_Code>
<peci:Effective_Moment>2022-07-27T03:30:05.861-07:00</peci:Effective_Moment>
<peci:Entry_Moment>2022-07-27T03:30:05.861-07:00</peci:Entry_Moment>
</peci:Effective_Change>
</peci:Worker>
<peci:Worker>
<peci:Worker_Summary>
<peci:Employee_ID>328557</peci:Employee_ID>
</peci:Worker_Summary>
<peci:Effective_Change peci:Sequence="0">
<peci:Derived_Event_Code>HIR</peci:Derived_Event_Code>
<peci:Effective_Moment>2022-07-27T00:00:00.000-07:00</peci:Effective_Moment>
<peci:Entry_Moment>2022-07-27T04:44:30.864-07:00</peci:Entry_Moment>
</peci:Effective_Change>
</peci:Worker>
<peci:Worker>
<peci:Worker_Summary>
<peci:Employee_ID>1111132</peci:Employee_ID>
</peci:Worker_Summary>
<peci:Effective_Change peci:Sequence="0">
<peci:Derived_Event_Code>DTA</peci:Derived_Event_Code>
<peci:Effective_Moment>2022-07-25T00:00:00.000-07:00</peci:Effective_Moment>
<peci:Entry_Moment>2022-07-25T04:44:30.864-07:00</peci:Entry_Moment>
</peci:Effective_Change>
</peci:Worker>
</peci:Workers_Effective_Stack>
</peci:Worker_Effective_Stack_Aggregate>
I would like to get something like (only employees with hire event and only an event that is a hire):
<?xml version="1.0" encoding="UTF-8"?>
<peci:Worker_Effective_Stack_Aggregate xmlns:peci="urn:com.workday/peci">
<peci:Workers_Effective_Stack>
<peci:Summary>
<peci:Integration_Event>6d374dcbe3a81024090d271cab840000</peci:Integration_Event>
</peci:Summary>
<peci:Worker>
<peci:Worker_Summary>
<peci:Employee_ID>328556</peci:Employee_ID>
</peci:Worker_Summary>
<peci:Effective_Change peci:Sequence="0">
<peci:Derived_Event_Code>HIR</peci:Derived_Event_Code>
<peci:Effective_Moment>2022-07-27T00:00:00.000-07:00</peci:Effective_Moment>
<peci:Entry_Moment>2022-07-27T03:24:11.531-07:00</peci:Entry_Moment>
</peci:Effective_Change>
</peci:Worker>
<peci:Worker>
<peci:Worker_Summary>
<peci:Employee_ID>328557</peci:Employee_ID>
</peci:Worker_Summary>
<peci:Effective_Change peci:Sequence="0">
<peci:Derived_Event_Code>HIR</peci:Derived_Event_Code>
<peci:Effective_Moment>2022-07-27T00:00:00.000-07:00</peci:Effective_Moment>
<peci:Entry_Moment>2022-07-27T04:44:30.864-07:00</peci:Entry_Moment>
</peci:Effective_Change>
</peci:Worker>
</peci:Workers_Effective_Stack>
</peci:Worker_Effective_Stack_Aggregate>
This is my code
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:peci="urn:com.workday/peci">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='peci:Effective_Change[peci:Derived_Event_Code != "HIR"]'/>
</xsl:stylesheet>
Unfortunately it does not remove the worker without HIR event code (the last one). I tried adding this
<xsl:template match="peci:Worker[peci:Effective_Change/peci:Derived_Event_Code!='HIR']"/>
but it removed the first worker (with two transactions as well).
Thanks in advance
Przemek