我要求为员工收到的每个奖金打印一行以及薪资和津贴
请参阅报告中的XML -
(Bonus_Assignment是我需要在每个奖金的不同行中打印的节点)
<wd:Report_Data xmlns:wd="urn:com.workday.report/XMLNAME_1475b_-_Amit">
<wd:Report_Entry>
<wd:Employee_Compensation_Type_OfferSalary>OfferSalary</wd:Employee_Compensation_Type_OfferSalary>
<wd:Employee_Compensation_Type_OfferBonus>OfferBonus</wd:Employee_Compensation_Type_OfferBonus>
<wd:Allowance_Assignments>
<wd:Employee_Compensation_Type_OfferAllowance>OffersAutoAllowance</wd:Employee_Compensation_Type_OfferAllowance>
<wd:Allowance_Amount>700</wd:Allowance_Amount>
<wd:Flsa_Status_Code_Allowance wd:Descriptor="USA Car Allowance">
<wd:ID wd:type="WID">32bd01e62b27101f0c5d34bc3e398d93</wd:ID>
<wd:ID wd:type="Compensation_Plan_ID">USA_Car_Allowance</wd:ID>
</wd:Flsa_Status_Code_Allowance>
</wd:Allowance_Assignments>
<wd:Candidate_ID>C02271</wd:Candidate_ID>
<wd:Job_Application wd:Descriptor="Stefen Salvatore (Referral) - R00010 Sr Analyst Delivery Specialist_175328BR (C02271)">
<wd:ID wd:type="WID">c820a3cdb761900dcf51dc132e290529</wd:ID>
<wd:ID wd:type="Job_Application_ID">JOB_APPLICATION-6-2270</wd:ID>
</wd:Job_Application>
<wd:Worker_Sub-Type wd:Descriptor="Regular">
<wd:ID wd:type="WID">bc914f6ed6aa101d83de5572d1e46422</wd:ID>
<wd:ID wd:type="Employee_Type_ID">Regular</wd:ID>
</wd:Worker_Sub-Type>
<wd:Job_Application_Offer_Status wd:Descriptor="Offer Accepted">
<wd:ID wd:type="WID">bc914f6ed6aa101e1a6e235e35f5706c</wd:ID>
<wd:ID wd:type="Offer_Status_ID">OFFER_STATUS_Offer_Accepted</wd:ID>
</wd:Job_Application_Offer_Status>
<wd:Job_Requisition>
<wd:Employee_Num>R00010</wd:Employee_Num>
<wd:Currency_Code wd:Descriptor="AUD">
<wd:ID wd:type="WID">8a96ee707a264afe888d90ef93253305</wd:ID>
<wd:ID wd:type="Currency_ID">AUD</wd:ID>
<wd:ID wd:type="Currency_Numeric_Code">036</wd:ID>
</wd:Currency_Code>
<wd:Worker_Type wd:Descriptor="Regular">
<wd:ID wd:type="WID">bc914f6ed6aa101d83de5572d1e46422</wd:ID>
<wd:ID wd:type="Employee_Type_ID">Regular</wd:ID>
</wd:Worker_Type>
<wd:Req_Salary>0</wd:Req_Salary>
<wd:Req_Bonus>0</wd:Req_Bonus>
<wd:Req_Allowance>0</wd:Req_Allowance>
<wd:Bonus_Effective_Date>2017-01-19-08:00</wd:Bonus_Effective_Date>
</wd:Job_Requisition>
<wd:Salary_Assignments>
<wd:Salary_Amount>75000</wd:Salary_Amount>
<wd:Flsa_Status_Code_Salary wd:Descriptor="Base Salary">
<wd:ID wd:type="WID">32bd01e62b27101f0c622c47a20f911a</wd:ID>
<wd:ID wd:type="Compensation_Plan_ID">Base_Salary</wd:ID>
</wd:Flsa_Status_Code_Salary>
</wd:Salary_Assignments>
<wd:Bonus_Assignments>
<wd:Bonus_Amount>11199.56</wd:Bonus_Amount>
<wd:Flsa_Status_Code_Bonus wd:Descriptor="IBP Semi-Annual EMC">
<wd:ID wd:type="WID">32bd01e62b27101f0c6300373ce89192</wd:ID>
<wd:ID wd:type="Compensation_Plan_ID">IBP_Semi-Annual_EMC</wd:ID>
</wd:Flsa_Status_Code_Bonus>
</wd:Bonus_Assignments>
<wd:Bonus_Assignments>
<wd:Bonus_Amount>22399.11</wd:Bonus_Amount>
<wd:Flsa_Status_Code_Bonus wd:Descriptor="IBP Corporate">
<wd:ID wd:type="WID">32bd01e62b27101f0c631f69f96491bd</wd:ID>
<wd:ID wd:type="Compensation_Plan_ID">IBP_Corporate</wd:ID>
</wd:Flsa_Status_Code_Bonus>
</wd:Bonus_Assignments>
</wd:Report_Entry>
</wd:Report_Data>
目前的结果:
"OfferSalary" R00010 AUD 0 "Base Salary" 75000 "OfferBonus" R00010 AUD "IBP Semi-Annual IBP Corporate" 11199.56 22399.11 "OffersAutoAllowance" R00010 AUD "USA Car Allowance" 700
预期 -
"OfferSalary" R00010 AUD 0 "Base Salary" 75000 "OfferBonus" R00010 AUD "IBP Semi-Annual" 11199.56 "OfferBonus" R00010 AUD "IBP Corporate" 22399.11 "OffersAutoAllowance" R00010 AUD "USA Car Allowance" 700
当前的XSLT
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wd="urn:com.workday.report/XMLNAME_1475b_-_Amit" version="1.0">
<xsl:output method="text" encoding="UTF-8" indent="yes" />
<xsl:variable name="Tab" select="'	'" />
<xsl:variable name="quote" select="'"'" />
<xsl:variable name="newline" select="'
'" />
<xsl:template match="/*">
<xsl:for-each select="wd:Report_Entry">
<xsl:value-of select="$quote" />
<xsl:choose>
<xsl:when test="wd:Employee_Compensation_Type_OfferSalary">
<xsl:value-of select="wd:Employee_Compensation_Type_OfferSalary" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Employee_Compensation_Type_TOfferSalary" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$quote" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Job_Requisition/wd:Employee_Num" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Job_Requisition/wd:Currency_Code/@wd:Descriptor" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="0" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="$quote" />
<xsl:value-of select="wd:Salary_Assignments/wd:Flsa_Status_Code_Salary/@wd:Descriptor" />
<xsl:value-of select="$quote" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="''" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Salary_Assignments/wd:Salary_Amount" />
<xsl:value-of select="$newline" />
<xsl:if test="wd:Bonus_Assignments/wd:Flsa_Status_Code_Bonus/@wd:Descriptor != ''">
<xsl:value-of select="$quote" />
<xsl:choose>
<xsl:when test="wd:Employee_Compensation_Type_OfferBonus">
<xsl:value-of select="wd:Employee_Compensation_Type_OfferBonus" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Employee_Compensation_Type_TOfferBonus" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$quote" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Job_Requisition/wd:Employee_Num" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Job_Requisition/wd:Currency_Code/@wd:Descriptor" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Bonus_Incl_Excl_Bonus" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="$quote" />
<xsl:value-of select="wd:Bonus_Assignments/wd:Flsa_Status_Code_Bonus/@wd:Descriptor" />
<xsl:value-of select="$quote" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Bonus_Effective_Date" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Bonus_Assignments/wd:Bonus_Amount" />
<xsl:value-of select="$newline" />
</xsl:if>
<xsl:if test="wd:Allowance_Assignments/wd:Flsa_Status_Code_Allowance/@wd:Descriptor != ''">
<xsl:value-of select="$quote" />
<xsl:choose>
<xsl:when test="(wd:Allowance_Assignments/wd:Employee_Compensation_Type_OfferAllowance) and (wd:Job_Requisition/wd:Worker_Type/@wd:Descriptor != 'Fixed Term')">
<xsl:value-of select="wd:Allowance_Assignments/wd:Employee_Compensation_Type_OfferAllowance" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="wd:Allowance_Assignments/Employee_Compensation_Type_TOfferAllowance" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$quote" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Job_Requisition/wd:Employee_Num" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Job_Requisition/wd:Currency_Code/@wd:Descriptor" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="''" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Bonus_Incl_Excl_Allowance" />
<xsl:value-of select="$Tab" />
<xsl:value-of select="$quote" />
<xsl:value-of select="wd:Allowance_Assignments/wd:Flsa_Status_Code_Allowance/@wd:Descriptor" />
<xsl:value-of select="$quote" />
<xsl:value-of select="$Tab" />
<xsl:text />
<xsl:value-of select="$Tab" />
<xsl:value-of select="wd:Allowance_Assignments/wd:Allowance_Amount" />
<xsl:value-of select="$newline" />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:transform>
答案 0 :(得分:0)
诀窍是使用模板匹配。
您有多个wd:Bonus_Assignments
元素,每个元素都应转换为输出行。
这是<xsl:apply-templates>
/ <xsl:template>
对的完美情况。
比较(还要注意模板中稍微改变的相对路径):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wd="urn:com.workday.report/XMLNAME_1475b_-_Amit" version="1.0">
<xsl:output method="text" encoding="UTF-8" indent="yes" />
<xsl:variable name="Tab" select="'	'" />
<xsl:variable name="quote" select="'"'" />
<xsl:variable name="newline" select="'
'" />
<xsl:template match="/*">
<xsl:apply-templates select="wd:Report_Entry" />
</xsl:template>
<xsl:template match="wd:Report_Entry">
<xsl:value-of select="$quote" />
<xsl:choose>
<xsl:when test="wd:Employee_Compensation_Type_OfferSalary">
<xsl:value-of select="wd:Employee_Compensation_Type_OfferSalary" />
</xsl:when>
<xsl:otherwise>l
<xsl:value-of select="Employee_Compensation_Type_TOfferSalary" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$quote" />
<xsl:value-of select="concat($Tab, wd:Job_Requisition/wd:Employee_Num)" />
<xsl:value-of select="concat($Tab, wd:Job_Requisition/wd:Currency_Code/@wd:Descriptor)" />
<xsl:value-of select="concat($Tab, 0)" />
<xsl:value-of select="concat($Tab, $quote, wd:Salary_Assignments/wd:Flsa_Status_Code_Salary/@wd:Descriptor, $quote)" />
<xsl:value-of select="concat($Tab, '')" />
<xsl:value-of select="concat($Tab, wd:Salary_Assignments/wd:Salary_Amount)" />
<xsl:value-of select="$newline" />
<!-- here ****************************************************** -->
<xsl:apply-templates select="wd:Bonus_Assignments[wd:Flsa_Status_Code_Bonus/@wd:Descriptor != '']" />
<xsl:apply-templates select="wd:Allowance_Assignments[wd:Flsa_Status_Code_Allowance/@wd:Descriptor != '']" />
</xsl:template>
<xsl:template match="wd:Bonus_Assignments">
<xsl:value-of select="$quote" />
<xsl:choose>
<xsl:when test="../wd:Employee_Compensation_Type_OfferBonus">
<xsl:value-of select="../wd:Employee_Compensation_Type_OfferBonus" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../Employee_Compensation_Type_TOfferBonus" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$quote" />
<xsl:value-of select="concat($Tab, ../wd:Job_Requisition/wd:Employee_Num)" />
<xsl:value-of select="concat($Tab, ../wd:Job_Requisition/wd:Currency_Code/@wd:Descriptor)" />
<xsl:value-of select="concat($Tab, ../wd:Bonus_Incl_Excl_Bonus)" />
<xsl:value-of select="concat($Tab, $quote, wd:Flsa_Status_Code_Bonus/@wd:Descriptor, $quote)" />
<xsl:value-of select="concat($Tab, ../wd:Bonus_Effective_Date)" />
<xsl:value-of select="concat($Tab, wd:Bonus_Amount)" />
<xsl:value-of select="$newline" />
</xsl:template>
<xsl:template match="wd:Allowance_Assignments">
<xsl:value-of select="$quote" />
<xsl:choose>
<xsl:when test="wd:Employee_Compensation_Type_OfferAllowance and ../wd:Job_Requisition/wd:Worker_Type/@wd:Descriptor != 'Fixed Term'">
<xsl:value-of select="wd:Employee_Compensation_Type_OfferAllowance" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="wd:Employee_Compensation_Type_TOfferAllowance" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$quote" />
<xsl:value-of select="concat($Tab, ../wd:Job_Requisition/wd:Employee_Num)" />
<xsl:value-of select="concat($Tab, ../wd:Job_Requisition/wd:Currency_Code/@wd:Descriptor)" />
<xsl:value-of select="concat($Tab, ../wd:Bonus_Incl_Excl_Allowance)" />
<xsl:value-of select="concat($Tab, $quote, wd:Flsa_Status_Code_Allowance/@wd:Descriptor, $quote)" />
<xsl:value-of select="concat($Tab, '')" />
<xsl:value-of select="concat($Tab, wd:Allowance_Amount)" />
<xsl:value-of select="$newline" />
</xsl:template>
</xsl:transform>
结果:
"OfferSalary" R00010 AUD 0 "Base Salary" 75000 "OfferBonus" R00010 AUD "IBP Semi-Annual EMC" 11199.56 "OfferBonus" R00010 AUD "IBP Corporate" 22399.11 "OffersAutoAllowance" R00010 AUD "USA Car Allowance" 700