需要一个函数来使用xslt获取LV记录上的LP记录值

问题描述 投票:0回答:1

我需要在字段:LV_Reason 中获取 LV 记录上 RecordType: LP 的 LP_Leave_Reason 值。如果每个 Emp 有两个以上 LP 记录,则需要获取 LP 记录的第一个 LP_Leave_Reason。 对于每一张 LV 唱片,我们应该至少有一张 LP 唱片。

输入xml数据:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <Worker>
        <Employee_ID>150547</Employee_ID>
        <Leave_Details>
            <RecordType>LV</RecordType>
            <Leave_ID>NTN-2988510-ABS-194587</Leave_ID>
            <LV_Leave_Date>2023-12-06 04:58:34.000</LV_Leave_Date>
            <LV_Open_Close>Open</LV_Open_Close>
            <LV_Status>Open</LV_Status>
            <LV_Reason>New</LV_Reason>
            <LV_Reason_Code/>
            <LV_Indicator>New</LV_Indicator>
        </Leave_Details>
        <Leave_Details>
            <RecordType>LP</RecordType>
            <Leave_ID>NTN-2988510-ABS-194587</Leave_ID>
            <LP_Leave_Reason>Child Bonding</LP_Leave_Reason>
            <LP_Leave_Reason_Attributes>Newborn</LP_Leave_Reason_Attributes>
            <LP_Leave_Plan/>
            <LP_Leave_Plan_Code>562354</LP_Leave_Plan_Code>
            <LP_Leave_Type>Family Medical Leave</LP_Leave_Type>
            <LP_PlanStartDate>2023-11-21</LP_PlanStartDate>
            <LP_PlanEndDate>2024-02-12</LP_PlanEndDate>
            <LP_Status>NY Paid Family Leave </LP_Status>
        </Leave_Details>
        <Company_leave_CONT>False</Company_leave_CONT>
        <Federal_Leave_CONT>False</Federal_Leave_CONT>
        <State_Leave_CONT>False</State_Leave_CONT>
        <Company_leave_INT>False</Company_leave_INT>
        <Federal_Leave_INT>False</Federal_Leave_INT>
        <State_Leave_INT>False</State_Leave_INT>
    </Worker>
    <Worker>
        <Employee_ID>172317</Employee_ID>
        <Leave_Details>
            <RecordType>LV</RecordType>
            <Leave_ID>NTN-3012201-ABS-200370</Leave_ID>
            <LV_Leave_Date>2023-12-04 10:21:40.000</LV_Leave_Date>
            <LV_Open_Close>Open</LV_Open_Close>
            <LV_Status>Open</LV_Status>
            <LV_Reason>New</LV_Reason>
            <LV_Reason_Code/>
            <LV_Indicator>New</LV_Indicator>
        </Leave_Details>
        <Leave_Details>
            <RecordType>LP</RecordType>
            <Leave_ID>NTN-3012201-ABS-200370</Leave_ID>
            <LP_Leave_Reason>Child Bonding</LP_Leave_Reason>
            <LP_Leave_Reason_Attributes>Newborn</LP_Leave_Reason_Attributes>
            <LP_Leave_Plan/>
            <LP_Leave_Plan_Code>578862</LP_Leave_Plan_Code>
            <LP_Leave_Type>Family Medical Leave</LP_Leave_Type>
            <LP_PlanStartDate>2023-09-11</LP_PlanStartDate>
            <LP_PlanEndDate>2023-10-15</LP_PlanEndDate>
            <LP_Status>NY Paid Family Leave </LP_Status>
        </Leave_Details>
        <Company_leave_CONT>False</Company_leave_CONT>
        <Federal_Leave_CONT>False</Federal_Leave_CONT>
        <State_Leave_CONT>False</State_Leave_CONT>
        <Company_leave_INT>False</Company_leave_INT>
        <Federal_Leave_INT>False</Federal_Leave_INT>
        <State_Leave_INT>False</State_Leave_INT>
    </Worker>
    <Worker>
        <Employee_ID>163091</Employee_ID>
        <Leave_Details>
            <RecordType>LV</RecordType>
            <Leave_ID>NTN-3023061-ABS-203450</Leave_ID>
            <LV_Leave_Date>2023-12-06 05:02:28.000</LV_Leave_Date>
            <LV_Open_Close>Open</LV_Open_Close>
            <LV_Status>Open</LV_Status>
            <LV_Reason>New</LV_Reason>
            <LV_Reason_Code/>
            <LV_Indicator>New</LV_Indicator>
        </Leave_Details>
        <Leave_Details>
            <RecordType>LP</RecordType>
            <Leave_ID>NTN-3023061-ABS-203450</Leave_ID>
            <LP_Leave_Reason>Child Bonding</LP_Leave_Reason>
            <LP_Leave_Reason_Attributes>Newborn</LP_Leave_Reason_Attributes>
            <LP_Leave_Plan/>
            <LP_Leave_Plan_Code>583744</LP_Leave_Plan_Code>
            <LP_Leave_Type>Family Medical Leave</LP_Leave_Type>
            <LP_PlanStartDate>2023-09-19</LP_PlanStartDate>
            <LP_PlanEndDate>2023-12-11</LP_PlanEndDate>
            <LP_Status>NY Paid Family Leave </LP_Status>
        </Leave_Details>
        <Company_leave_CONT>False</Company_leave_CONT>
        <Federal_Leave_CONT>False</Federal_Leave_CONT>
        <State_Leave_CONT>False</State_Leave_CONT>
        <Company_leave_INT>False</Company_leave_INT>
        <Federal_Leave_INT>False</Federal_Leave_INT>
        <State_Leave_INT>False</State_Leave_INT>
    </Worker>
</root>

我期待 LV 上 LV_Reason 的输出如下:

<?xml version="1.0" encoding="UTF-8"?>
    <root>
        <Worker>
            <Employee_ID>150547</Employee_ID>
            <Leave_Details>
                <RecordType>LV</RecordType>
                <Leave_ID>NTN-2988510-ABS-194587</Leave_ID>
                <LV_Leave_Date>2023-12-06 04:58:34.000</LV_Leave_Date>
                <LV_Open_Close>Open</LV_Open_Close>
                <LV_Status>Open</LV_Status>
                <LV_Reason>Child Bonding</LV_Reason>
                <LV_Reason_Code/>
                <LV_Indicator>New</LV_Indicator>
            </Leave_Details>
            <Leave_Details>
                <RecordType>LP</RecordType>
                <Leave_ID>NTN-2988510-ABS-194587</Leave_ID>
                <LP_Leave_Reason>Child Bonding</LP_Leave_Reason>
                <LP_Leave_Reason_Attributes>Newborn</LP_Leave_Reason_Attributes>
                <LP_Leave_Plan/>
                <LP_Leave_Plan_Code>562354</LP_Leave_Plan_Code>
                <LP_Leave_Type>Family Medical Leave</LP_Leave_Type>
                <LP_PlanStartDate>2023-11-21</LP_PlanStartDate>
                <LP_PlanEndDate>2024-02-12</LP_PlanEndDate>
                <LP_Status>NY Paid Family Leave </LP_Status>
            </Leave_Details>
            <Company_leave_CONT>False</Company_leave_CONT>
            <Federal_Leave_CONT>False</Federal_Leave_CONT>
            <State_Leave_CONT>False</State_Leave_CONT>
            <Company_leave_INT>False</Company_leave_INT>
            <Federal_Leave_INT>False</Federal_Leave_INT>
            <State_Leave_INT>False</State_Leave_INT>
        </Worker>
        <Worker>
            <Employee_ID>172317</Employee_ID>
            <Leave_Details>
                <RecordType>LV</RecordType>
                <Leave_ID>NTN-3012201-ABS-200370</Leave_ID>
                <LV_Leave_Date>2023-12-04 10:21:40.000</LV_Leave_Date>
                <LV_Open_Close>Open</LV_Open_Close>
                <LV_Status>Open</LV_Status>
                <LV_Reason>Child Bonding</LV_Reason>
                <LV_Reason_Code/>
                <LV_Indicator>New</LV_Indicator>
            </Leave_Details>
            <Leave_Details>
                <RecordType>LP</RecordType>
                <Leave_ID>NTN-3012201-ABS-200370</Leave_ID>
                <LP_Leave_Reason>Child Bonding</LP_Leave_Reason>
                <LP_Leave_Reason_Attributes>Newborn</LP_Leave_Reason_Attributes>
                <LP_Leave_Plan/>
                <LP_Leave_Plan_Code>578862</LP_Leave_Plan_Code>
                <LP_Leave_Type>Family Medical Leave</LP_Leave_Type>
                <LP_PlanStartDate>2023-09-11</LP_PlanStartDate>
                <LP_PlanEndDate>2023-10-15</LP_PlanEndDate>
                <LP_Status>NY Paid Family Leave </LP_Status>
            </Leave_Details>
            <Company_leave_CONT>False</Company_leave_CONT>
            <Federal_Leave_CONT>False</Federal_Leave_CONT>
            <State_Leave_CONT>False</State_Leave_CONT>
            <Company_leave_INT>False</Company_leave_INT>
            <Federal_Leave_INT>False</Federal_Leave_INT>
            <State_Leave_INT>False</State_Leave_INT>
        </Worker>
        <Worker>
            <Employee_ID>163091</Employee_ID>
            <Leave_Details>
                <RecordType>LV</RecordType>
                <Leave_ID>NTN-3023061-ABS-203450</Leave_ID>
                <LV_Leave_Date>2023-12-06 05:02:28.000</LV_Leave_Date>
                <LV_Open_Close>Open</LV_Open_Close>
                <LV_Status>Open</LV_Status>
                <LV_Reason>Child Bonding</LV_Reason>
                <LV_Reason_Code/>
                <LV_Indicator>New</LV_Indicator>
            </Leave_Details>
            <Leave_Details>
                <RecordType>LP</RecordType>
                <Leave_ID>NTN-3023061-ABS-203450</Leave_ID>
                <LP_Leave_Reason>Child Bonding</LP_Leave_Reason>
                <LP_Leave_Reason_Attributes>Newborn</LP_Leave_Reason_Attributes>
                <LP_Leave_Plan/>
                <LP_Leave_Plan_Code>583744</LP_Leave_Plan_Code>
                <LP_Leave_Type>Family Medical Leave</LP_Leave_Type>
                <LP_PlanStartDate>2023-09-19</LP_PlanStartDate>
                <LP_PlanEndDate>2023-12-11</LP_PlanEndDate>
                <LP_Status>NY Paid Family Leave </LP_Status>
            </Leave_Details>
            <Company_leave_CONT>False</Company_leave_CONT>
            <Federal_Leave_CONT>False</Federal_Leave_CONT>
            <State_Leave_CONT>False</State_Leave_CONT>
            <Company_leave_INT>False</Company_leave_INT>
            <Federal_Leave_INT>False</Federal_Leave_INT>
            <State_Leave_INT>False</State_Leave_INT>
        </Worker>
    </root>

下面是我需要包含此内容的 xslt 代码:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/Cigna_LOA_AllWorkers">
        <root>
            <xsl:for-each select="/Cigna_LOA_AllWorkers/Worker_Details">
                <xsl:variable name="NotificationCaseID">        
                    
                    <xsl:value-of select="NotificationCaseID"/>
                </xsl:variable>
                
                <xsl:variable name="AbsenceCaseID">     
                    
                    <xsl:value-of select="AbsenceCaseID"/>
                </xsl:variable>
                
                <xsl:variable name="EmployeeID">
                    <xsl:if test="RecordTypeCode = 'LV'">
                        <xsl:value-of select="EmployeeNumber"/>
                    </xsl:if>
                </xsl:variable>
                <xsl:variable name="FollowingNodeEmployeeID">
                    <xsl:value-of select="following-sibling::Worker_Details[1]/EmployeeNumber"/>
                </xsl:variable>
                <xsl:variable name="PrecedingNodeEmployeeID">
                    <xsl:value-of select="preceding-sibling::Worker_Details[1]/EmployeeNumber"/>
                </xsl:variable>
                <xsl:variable name="LeaveID">
                    
                    
                    <xsl:if test="RecordTypeCode = 'LV'">
                        <xsl:value-of select="concat($NotificationCaseID,'-',$AbsenceCaseID)"/>
                    </xsl:if>
                </xsl:variable>
                <xsl:variable name="NewWorker">
                    <xsl:choose>
                        <xsl:when test="RecordTypeCode = 'LV'">
                            <xsl:value-of select="'True'"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="'False'"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                
                              
                
                <xsl:choose>
                    <xsl:when test="$NewWorker = 'True'">
                        <Worker>
                            <Employee_ID>
                                <xsl:value-of select="$EmployeeID"/>
                            </Employee_ID>
                            <Leave_Details>
                                <RecordType>
                                    <xsl:value-of select="'LV'"/>
                                </RecordType>
                                <Leave_ID>
                                    <xsl:value-of select="$LeaveID"/>
                                </Leave_ID>
                                <LV_Leave_Date>
                                    <xsl:value-of select="col5"/>
                                </LV_Leave_Date>
                                <LV_Open_Close>
                                    <xsl:value-of select="col6"/>
                                </LV_Open_Close>
                                <LV_Status>
                                    <xsl:value-of select="col6"/>
                                </LV_Status>
                                <LV_Reason>
                                    <xsl:value-of select="col7"/>
                                </LV_Reason>
                                <LV_Reason_Code>
                                    <xsl:value-of select="col8"/>
                                </LV_Reason_Code>
                                <LV_Indicator>
                                    <xsl:value-of select="col7"/>
                                </LV_Indicator>
                            </Leave_Details>
                            <xsl:for-each select="following-sibling::Worker_Details[concat(EmployeeNumber,NotificationCaseID,'-',AbsenceCaseID)=concat($EmployeeID,$LeaveID) ]">
                                <xsl:if test="RecordTypeCode = 'LP'">
                                    <Leave_Details>
                                        <RecordType>
                                            <xsl:value-of select="'LP'"/>
                                        </RecordType>
                                        <Leave_ID>
                                            <xsl:value-of select="$LeaveID"/>
                                        </Leave_ID>
                                        
                                        <LP_Leave_Reason>
                                            <xsl:value-of select="col6"/>
                                        </LP_Leave_Reason>    
                                        
                                        <LP_Leave_Reason_Attributes>
                                            <xsl:value-of select="col7"/>
                                        </LP_Leave_Reason_Attributes>    
                                        
                                        
                                        <LP_Leave_Plan>
                                            <xsl:value-of select="col4"/>
                                        </LP_Leave_Plan>
                                        <LP_Leave_Plan_Code>
                                            <xsl:value-of select="col5"/>
                                        </LP_Leave_Plan_Code>
                                        <LP_Leave_Type>
                                            <xsl:value-of select="col11"/>
                                        </LP_Leave_Type>
                                        <LP_PlanStartDate>
                                            <xsl:value-of select="col12"/>
                                        </LP_PlanStartDate>
                                        <LP_PlanEndDate>
                                            <xsl:value-of select="col13"/>
                                        </LP_PlanEndDate>
                                        <LP_Status>
                                            <xsl:value-of select="col9"/>
                                        </LP_Status>
                                    </Leave_Details>
                                </xsl:if>
                                <xsl:if test="RecordTypeCode = 'TO'">
                                    <Leave_Details>
                                        <RecordType>
                                            <xsl:value-of select="'TO'"/>
                                        </RecordType>
                                        <Leave_ID>
                                            <xsl:value-of select="LeaveID"/>
                                        </Leave_ID>
                                        <TO_RequestDate>
                                            <xsl:value-of select="col4"/>
                                        </TO_RequestDate>
                                        <TO_Reason>
                                            <xsl:value-of select="col5"/>
                                        </TO_Reason>
                                        <TO_Hours>
                                            <xsl:value-of select="format-number(col6,'##.##')"/>
                                        </TO_Hours>
                                    </Leave_Details>
                                </xsl:if>
                            </xsl:for-each> 
                            
                            <!-- SPENUMA -->
                            
                            <xsl:variable name="CountContinuesCompanyLeave" select="count(following-sibling::Worker_Details[concat(EmployeeNumber,LeaveID)=concat($EmployeeID,$LeaveID) and (col4 = 'Medical Leave' or col4 = 'Maternity Leave' or col4 = 'Parental Leave' or col4 = 'Personal Leave' or col4 = 'Personal Family Care') and RecordTypeCode = 'LP' and col6 = 'CONT'])"/>
                            <xsl:variable name="CountContinuesFederalLeave" select="count(following-sibling::Worker_Details[concat(EmployeeNumber,LeaveID)=concat($EmployeeID,$LeaveID) and (col4 = 'FMLA' or col4 = 'USERRA') and RecordTypeCode = 'LP' and col6 = 'CONT'])"/>
                            <xsl:variable name="CountContinuesStateLeave" select="count(following-sibling::Worker_Details[concat(EmployeeNumber,LeaveID)=concat($EmployeeID,$LeaveID) and (col4 = 'CFRA' or col4 = 'CA-PDL' or col4 = 'NJFL' or col4 = 'CFML' or col4 = 'DCFML' or col4 = 'NJFLA'  or col4 = 'AR- BoneOrgaDonation' or col4 = 'CA-Exigency' or col4 = 'CA-BoneMarrow' or col4 = 'CA-OrganDonation' or col4 = 'CO-FML' or col4 = 'CO-PDL' or col4 = 'CT-InjServicemember' or col4 = 'CT-PDL' or col4 = 'DC-EML' or col4 = 'DC-FML' or col4 = 'DC-PDL' or col4 = 'DE-PDL' or col4 = 'HI-BoneMarrowBlood' or col4 = 'HI-OrganDonation' or col4 = 'HI-FML' or col4 = 'HI-PDL' or col4 = 'IA-PDL' or col4 = 'IL-ExigencyLeave'  or col4 = 'IL-BloodDonation' or col4 = 'IL-PDL' or col4 = 'IN-ExigencyLeave' or col4 = 'KS-PDL' or col4 = 'LA-PDL' or col4 = 'LA-PL' or col4 = 'LA-BoneMarrow' or col4 = 'MD-ExigencyLeave' or col4 = 'MA-PL' or col4 = 'MA-PDL' or col4 = 'ME-FML' or col4 = 'ME-ExigencyLeave' or col4 = 'MN-BoneMarrow' or col4 = 'MN-InjServiceMember' or col4 = 'MN-PL' or col4 = 'MN-ExigencyLeave' or col4 = 'MT-PDL' or col4 = 'ND-PDL' or col4 = 'NE-FamMilLeave' or col4 = 'NE PDL' or col4 = 'NJ-PDL' or col4 = 'NY-BloodDonation' or col4 = 'NY-BoneMarrow' or col4 = 'NH-PDL' or col4 = 'NY-ExigencyLeave' or col4 = 'OH-FamMilLeave' or col4 = 'OH-PDL' or col4 = 'OR-Exigency' or col4 = 'OR-PDL' or col4 = 'OFLA' or col4 = 'OR Parental' or col4 = 'ORSCL' or col4 = 'RI-FML' or col4 = 'RI-PDL' or col4 = 'RI-ExigencyLeave' or col4 = 'SC-PDL' or col4 = 'SC-BoneMarrow' or col4 = 'TN-PL' or col4 = 'UT-PDL' or col4 = 'VT-PDL' or col4 = 'VT-FamilyObligation' or col4 = 'VT-FML' or col4 = 'WA-Exigency' or col4 = 'WA-FLA' or col4 = 'WA-PDL' or col4 = 'WV-PDL' or col4 = 'WI-BoneOrganDonation' or col4 = 'WI-FML' or col4 = 'WI-PL') and RecordTypeCode = 'LP' and col6 = 'CONT'])"/>
                            <xsl:variable name="CountIntermittentCompanyLeave" select="count(following-sibling::Worker_Details[concat(EmployeeNumber,LeaveID)=concat($EmployeeID,$LeaveID) and (col4 = 'Medical Leave' or col4 = 'Maternity Leave' or col4 = 'Parental Leave' or col4 = 'Personal Leave' or col4 = 'Personal Family Care') and RecordTypeCode = 'LP' and col6 = 'INT'])"/>
                            <xsl:variable name="CountIntermittentFederalLeave" select="count(following-sibling::Worker_Details[concat(EmployeeNumber,LeaveID)=concat($EmployeeID,$LeaveID) and (col4 = 'FMLA' or col4 = 'USERRA') and RecordTypeCode = 'LP' and col6 = 'INT'])"/>
                            <xsl:variable name="CountIntermittentStateLeave" select="count(following-sibling::Worker_Details[concat(EmployeeNumber,LeaveID)=concat($EmployeeID,$LeaveID) and (col4 = 'CFRA' or col4 = 'CA-PDL' or col4 = 'NJFL' or col4 = 'CFML' or col4 = 'DCFML' or col4 = 'NJFLA' or col4 = 'AR- BoneOrgaDonation' or col4 = 'CA-Exigency' or col4 = 'CA-BoneMarrow' or col4 = 'CA-OrganDonation' or col4 = 'CO-FML' or col4 = 'CO-PDL' or col4 = 'CT-InjServicemember' or col4 = 'CT-PDL' or col4 = 'DC-EML' or col4 = 'DC-FML' or col4 = 'DC-PDL' or col4 = 'DE-PDL' or col4 = 'HI-BoneMarrowBlood' or col4 = 'HI-OrganDonation' or col4 = 'HI-FML' or col4 = 'HI-PDL' or col4 = 'IA-PDL' or col4 = 'IL-ExigencyLeave'  or col4 = 'IL-BloodDonation' or col4 = 'IL-PDL' or col4 = 'IN-ExigencyLeave' or col4 = 'KS-PDL' or col4 = 'LA-PDL' or col4 = 'LA-PL' or col4 = 'LA-BoneMarrow' or col4 = 'MD-ExigencyLeave' or col4 = 'MA-PL' or col4 = 'MA-PDL' or col4 = 'ME-FML' or col4 = 'ME-ExigencyLeave' or col4 = 'MN-BoneMarrow' or col4 = 'MN-InjServiceMember' or col4 = 'MN-PL' or col4 = 'MN-ExigencyLeave' or col4 = 'MT-PDL' or col4 = 'ND-PDL' or col4 = 'NE-FamMilLeave' or col4 = 'NE PDL' or col4 = 'NJ-PDL' or col4 = 'NY-BloodDonation' or col4 = 'NY-BoneMarrow' or col4 = 'NH-PDL' or col4 = 'NY-ExigencyLeave' or col4 = 'OH-FamMilLeave' or col4 = 'OH-PDL' or col4 = 'OR-Exigency' or col4 = 'OR-PDL' or col4 = 'OFLA' or col4 = 'OR Parental' or col4 = 'ORSCL' or col4 = 'RI-FML' or col4 = 'RI-PDL' or col4 = 'RI-ExigencyLeave' or col4 = 'SC-PDL' or col4 = 'SC-BoneMarrow' or col4 = 'TN-PL' or col4 = 'UT-PDL' or col4 = 'VT-PDL' or col4 = 'VT-FamilyObligation' or col4 = 'VT-FML' or col4 = 'WA-Exigency' or col4 = 'WA-FLA' or col4 = 'WA-PDL' or col4 = 'WV-PDL' or col4 = 'WI-BoneOrganDonation' or col4 = 'WI-FML' or col4 = 'WI-PL') and RecordTypeCode = 'LP' and col6 = 'INT'])"/>
                            
                            <Company_leave_CONT>
                                <xsl:choose>
                                    <xsl:when test="($CountContinuesCompanyLeave &gt; 0)">True</xsl:when>
                                    <xsl:otherwise>False</xsl:otherwise>
                                </xsl:choose>
                            </Company_leave_CONT>
                            <Federal_Leave_CONT>
                                <xsl:choose>
                                    <xsl:when test="($CountContinuesFederalLeave &gt; 0)">True</xsl:when>
                                    <xsl:otherwise>False</xsl:otherwise>
                                </xsl:choose>
                            </Federal_Leave_CONT>
                            <State_Leave_CONT>
                                <xsl:choose>
                                    <xsl:when test="($CountContinuesStateLeave &gt; 0)">True</xsl:when>
                                    <xsl:otherwise>False</xsl:otherwise>
                                </xsl:choose>
                            </State_Leave_CONT>
                            <Company_leave_INT>
                                <xsl:choose>
                                    <xsl:when test="($CountIntermittentCompanyLeave &gt; 0)">True</xsl:when>
                                    <xsl:otherwise>False</xsl:otherwise>
                                </xsl:choose>
                            </Company_leave_INT>
                            <Federal_Leave_INT>
                                <xsl:choose>
                                    <xsl:when test="($CountIntermittentFederalLeave &gt; 0)">True</xsl:when>
                                    <xsl:otherwise>False</xsl:otherwise>
                                </xsl:choose>
                            </Federal_Leave_INT>
                            <State_Leave_INT>
                                <xsl:choose>
                                    <xsl:when test="($CountIntermittentStateLeave &gt; 0)">True</xsl:when>
                                    <xsl:otherwise>False</xsl:otherwise>
                                </xsl:choose>
                            </State_Leave_INT>
                        </Worker>
                    </xsl:when>
                </xsl:choose>
            </xsl:for-each>
        </root>
    </xsl:template>
</xsl:stylesheet>
xml xslt xslt-1.0
1个回答
0
投票

我用它来得到我的结果:

<xsl:template match="Worker_Details[RecordTypeCode='LV']">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
            <!-- Get the corresponding LP record -->
            <xsl:variable name="lpRecord" select="../Worker_Details[RecordTypeCode='LP' and concat(NotificationCaseID, '-', AbsenceCaseID) = concat(current()/NotificationCaseID, '-', current()/AbsenceCaseID)]" />
            <!-- If LP record is found, insert its LP_Leave_Reason value, otherwise use a default value -->
            <LV_Reason>
                <xsl:choose>
                    <xsl:when test="$lpRecord">
                        <xsl:value-of select="$lpRecord/LP_Leave_Reason"/>
                    </xsl:when>
                    <xsl:otherwise>Default Value</xsl:otherwise>
                </xsl:choose>
            </LV_Reason>
        </xsl:copy>
    </xsl:template>
© www.soinside.com 2019 - 2024. All rights reserved.