我正在尝试计算下面xml中有多少员工有操作!= NONE和pi:Code_Name = ESPP Base Salary。理想情况下答案应该是1.
我想知道如何实现这一目标。我使用Oxygen作为XSLT编写器。
XML
<?xml version="1.0" encoding="UTF-8"?>
<pi:Payroll_Extract_Employees xmlns:pi="urn:com.workday/picof">
<pi:PayGroup>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>2350</pi:Employee_ID>
<pi:Name>Delvin Jay ABAN</pi:Name>
<pi:Payroll_Company_Name>United States External Pay Entity</pi:Payroll_Company_Name>
<pi:Pay_Group_Name>United States Pay Group - Semi-Monthly</pi:Pay_Group_Name>
<pi:Contain_Corrections_or_Rescinds>true</pi:Contain_Corrections_or_Rescinds>
</pi:Summary>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">Overtime</pi:Code_Name>
<pi:Code pi:PriorValue="">E002</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">E</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20140701</pi:Start_Date>
<pi:Amount pi:PriorValue="">193.96</pi:Amount>
<pi:Prorated_Amount pi:PriorValue="">193.96</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">Base Salary</pi:Code_Name>
<pi:Code pi:PriorValue="">E790</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">E</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20140701</pi:Start_Date>
<pi:Amount pi:PriorValue="">193.96</pi:Amount>
<pi:Prorated_Amount pi:PriorValue="">193.96</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Additional_Information>
<pi:EffDateStockForm>2015-03-01</pi:EffDateStockForm>
<pi:CNUM pi:PriorValue="123U87">135632</pi:CNUM>
</pi:Additional_Information>
</pi:Employee>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>4471</pi:Employee_ID>
<pi:Name>Vergel LIRIO</pi:Name>
<pi:Payroll_Company_Name>United States External Pay Entity</pi:Payroll_Company_Name>
<pi:Pay_Group_Name>United States Pay Group - Semi-Monthly</pi:Pay_Group_Name>
<pi:Contain_Corrections_or_Rescinds>false</pi:Contain_Corrections_or_Rescinds>
</pi:Summary>
<pi:Personal>
<pi:First_Name>Vergel</pi:First_Name>
<pi:Last_Name>LIRIO</pi:Last_Name>
</pi:Personal>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">Base Salary</pi:Code_Name>
<pi:Code pi:PriorValue="">E790</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">E</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20151001</pi:Start_Date>
<pi:Amount pi:PriorValue="">25000</pi:Amount>
<pi:Prorated_Amount pi:PriorValue="">25000</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Payment_Election>
<pi:Operation>ADD</pi:Operation>
<pi:Payment_Type>DIRECT DEPOSIT</pi:Payment_Type>
<pi:Country>PH</pi:Country>
<pi:Bank_Account_Name>VERGEL LIRIO</pi:Bank_Account_Name>
<pi:Account_Number>4339169263</pi:Account_Number>
<pi:Account_Type>SA</pi:Account_Type>
<pi:Bank_Name>BANK OF P.I.</pi:Bank_Name>
<pi:Bank_ID_Number>40398</pi:Bank_ID_Number>
</pi:Payment_Election>
<pi:Additional_Information>
<pi:EffDateStockForm>2015-03-01</pi:EffDateStockForm>
<pi:CNUM pi:PriorValue="X91664">123456</pi:CNUM>
</pi:Additional_Information>
</pi:Employee>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>21365</pi:Employee_ID>
<pi:Name>Ava Waterbury</pi:Name>
<pi:Payroll_Company_Name>United States External Pay Entity</pi:Payroll_Company_Name>
<pi:Pay_Group_Name>United States Pay Group - Semi-Monthly</pi:Pay_Group_Name>
<pi:Contain_Corrections_or_Rescinds>false</pi:Contain_Corrections_or_Rescinds>
</pi:Summary>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">Overtime</pi:Code_Name>
<pi:Code pi:PriorValue="">E002</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">E</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20150731</pi:Start_Date>
<pi:Amount pi:PriorValue="">12000</pi:Amount>
<pi:Prorated_Amount pi:PriorValue="">12000</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Earnings_Deductions>
<pi:Operation>NONE</pi:Operation>
<pi:Code_Name>Base Salary</pi:Code_Name>
<pi:Code>E790</pi:Code>
<pi:Earning_or_Deduction>E</pi:Earning_or_Deduction>
<pi:Start_Date>20150731</pi:Start_Date>
<pi:Amount>12000</pi:Amount>
<pi:Prorated_Amount>12000</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">ESPP Base Salary</pi:Code_Name>
<pi:Code pi:PriorValue="">ESPP_BaseSalary</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">D</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20150901</pi:Start_Date>
<pi:Percentage pi:PriorValue="">0.02</pi:Percentage>
</pi:Earnings_Deductions>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">ESPP Non Sales</pi:Code_Name>
<pi:Code pi:PriorValue="">ESPP_NonSales</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">D</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20150901</pi:Start_Date>
<pi:Percentage pi:PriorValue="">0.03</pi:Percentage>
</pi:Earnings_Deductions>
<pi:Additional_Information>
<pi:CNUM>042227</pi:CNUM>
</pi:Additional_Information>
</pi:Employee>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>21951</pi:Employee_ID>
<pi:Name>Hollie Hoffler</pi:Name>
<pi:Payroll_Company_Name>United States External Pay Entity</pi:Payroll_Company_Name>
<pi:Pay_Group_Name>United States Pay Group - Semi-Monthly</pi:Pay_Group_Name>
<pi:Contain_Corrections_or_Rescinds>false</pi:Contain_Corrections_or_Rescinds>
</pi:Summary>
<pi:Earnings_Deductions>
<pi:Operation>ADD</pi:Operation>
<pi:Code_Name pi:PriorValue="">Overtime</pi:Code_Name>
<pi:Code pi:PriorValue="">E002</pi:Code>
<pi:Earning_or_Deduction pi:PriorValue="">E</pi:Earning_or_Deduction>
<pi:Start_Date pi:PriorValue="">20150521</pi:Start_Date>
<pi:Amount pi:PriorValue="">4153.2</pi:Amount>
<pi:Prorated_Amount pi:PriorValue="">4153.2</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Earnings_Deductions>
<pi:Operation>NONE</pi:Operation>
<pi:Code_Name>Base Salary</pi:Code_Name>
<pi:Code>E790</pi:Code>
<pi:Earning_or_Deduction>E</pi:Earning_or_Deduction>
<pi:Start_Date>20150521</pi:Start_Date>
<pi:Amount>4153.2</pi:Amount>
<pi:Prorated_Amount>4153.2</pi:Prorated_Amount>
</pi:Earnings_Deductions>
<pi:Payment_Election>
<pi:Operation>ADD</pi:Operation>
<pi:Payment_Type pi:PriorValue="">DIRECT DEPOSIT</pi:Payment_Type>
<pi:Country pi:PriorValue="">US</pi:Country>
<pi:Account_Number pi:PriorValue="">890test</pi:Account_Number>
<pi:Account_Type pi:PriorValue="">DDA</pi:Account_Type>
<pi:Bank_Name pi:PriorValue="">1st Merit</pi:Bank_Name>
<pi:Bank_ID_Number pi:PriorValue="">041200555</pi:Bank_ID_Number>
</pi:Payment_Election>
<pi:Additional_Information>
<pi:EffDateStockForm pi:PriorValue="">2015-09-09</pi:EffDateStockForm>
<pi:CNUM>0A8737</pi:CNUM>
</pi:Additional_Information>
</pi:Employee>
</pi:PayGroup>
</pi:Payroll_Extract_Employees>
答案 0 :(得分:0)
使用XPath:
Earnings_Deductions
- 同时包含操作的元素!=&#39;无效&#39;和Code_Name =&#39; ESPP基本工资&#39;:
//pi:Earnings_Deductions[pi:Operation != 'NONE' and
pi:Code_Name = 'ESPP Base Salary']
Employee
- 与Earnings_Deductions
匹配的元素:
//pi:Employee[pi:Earnings_Deductions[pi:Operation != 'NONE' and
pi:Code_Name = 'ESPP Base Salary']])
计算这些员工:
count(//pi:Employee[
pi:Earnings_Deductions[pi:Operation != 'NONE' and
pi:Code_Name = 'ESPP Base Salary']
]
)