j'ai XSL:éléments du groupe transformé à son parent
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xmlns:pi="urn:com.workday/picof"
version="2.0">
<xsl:output indent="yes" method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<pi:Payroll_Extract_Employees>
<xsl:copy-of select="//pi:Header"/>
<xsl:for-each select="//pi:Employee">
<pi:Employee>
<xsl:copy-of select="pi:Summary"/>
</pi:Employee>
</xsl:for-each>
<xsl:apply-templates select="//pi:Employee/pi:Additional_Information/*"/>
</pi:Payroll_Extract_Employees>
</xsl:template>
<xsl:template match="pi:Additional_Information/*">
<xsl:apply-templates select="ancestor::pi:Payroll_Extract_Employees">
<xsl:with-param name="UnpaidTO" select="current()"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="pi:Payroll_Extract_Employees">
<xsl:param name="UnpaidTO"/>
<pi:Time_Off>
<pi:Code_Name>Unpaid Time Off</pi:Code_Name>
<pi:Time_Off_Type><xsl:value-of select="substring-after(substring-before($UnpaidTO,'('),'=')"/></pi:Time_Off_Type>
<pi:Time_Off_Date><xsl:value-of select="substring-before($UnpaidTO,',')"/></pi:Time_Off_Date>
<pi:Quantity><xsl:value-of select="substring-before(substring-after($UnpaidTO,','),' ')"/></pi:Quantity>
<pi:Unit_of_Time><xsl:value-of select="substring-after(substring-before($UnpaidTO,'='),' ')"/></pi:Unit_of_Time>
</pi:Time_Off>
</xsl:template>
</xsl:stylesheet>
Et un fichier XML initial:
<?xml version="1.0" encoding="UTF-8"?>
<pi:Payroll_Extract_Employees xmlns:pi="urn:com.workday/picof">
<pi:Header>
<pi:Updated_From>2017-09-07T02:23:04.000-07:00</pi:Updated_From>
</pi:Header>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>00000001</pi:Employee_ID>
</pi:Summary>
<pi:Additional_Information>
<pi:Strike_1>2017-09-11,2 Hours=9570</pi:Strike_1>
</pi:Additional_Information>
</pi:Employee>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>00000002</pi:Employee_ID>
</pi:Summary>
<pi:Additional_Information>
<pi:Strike_1>2017-09-22,8 Hours=9570</pi:Strike_1>
<pi:Unjustified_Absence_1>2017-09-25,8 Hours=9700</pi:Unjustified_Absence_1>
</pi:Additional_Information>
</pi:Employee>
</pi:Payroll_Extract_Employees>
Mon code fonctionne bien. Le seul problème est que les éléments transformés (pi: TIME_OFF et ses éléments enfants) ne sont pas un groupe à leur noeud parent respectif (pi: employé)
Je voudrais que le résultat final d'être comme celui-ci:
<?xml version="1.0" encoding="UTF-8"?>
<pi:Payroll_Extract_Employees xmlns:pi="urn:com.workday/picof">
<pi:Header>
<pi:Updated_From>2017-09-07T02:23:04.000-07:00</pi:Updated_From>
</pi:Header>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>00000001</pi:Employee_ID>
</pi:Summary>
<pi:Time_Off>
<pi:Code_Name>Unpaid Time Off</pi:Code_Name>
<pi:Time_Off_Type>9570</pi:Time_Off_Type>
<pi:Time_Off_Date>2017-09-11</pi:Time_Off_Date>
<pi:Quantity>2</pi:Quantity>
<pi:Unit_of_Time>Hours</pi:Unit_of_Time>
</pi:Time_Off>
</pi:Employee>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>00000002</pi:Employee_ID>
</pi:Summary>
<pi:Time_Off>
<pi:Code_Name>Unpaid Time Off</pi:Code_Name>
<pi:Time_Off_Type>9570</pi:Time_Off_Type>
<pi:Time_Off_Date>2017-09-22</pi:Time_Off_Date>
<pi:Quantity>8</pi:Quantity>
<pi:Unit_of_Time>Hours</pi:Unit_of_Time>
</pi:Time_Off>
<pi:Time_Off>
<pi:Code_Name>Unpaid Time Off</pi:Code_Name>
<pi:Time_Off_Type>9700</pi:Time_Off_Type>
<pi:Time_Off_Date>2017-09-25</pi:Time_Off_Date>
<pi:Quantity>8</pi:Quantity>
<pi:Unit_of_Time>Hours</pi:Unit_of_Time>
</pi:Time_Off>
</pi:Employee>
</pi:Payroll_Extract_Employees>
Que dois-je faire pour avoir le résultat souhaité? Veuillez m'aider à résoudre celui-ci. Merci beaucoup!