0
源XML檢查超過2個值量:總和在記錄
<?xml version="1.0" encoding="UTF-8"?>
<Emp>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ1</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM1</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>1</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>100.00</Value>
</Amount>
</AmountDetails>
</EmpDetail>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ1</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM1</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>1</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>5000</Value>
</Amount>
</AmountDetails>
</EmpDetail>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>2</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>200.00</Value>
</Amount>
</AmountDetails>
</EmpDetail>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>3</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>500</Value>
</Amount>
</AmountDetails>
</EmpDetail>
</Emp>
目標XML:
<?xml version="1.0" encoding="UTF-8"?>
<Emp>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ1</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM1</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>1</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>5100.00</Value>
</Amount>
</AmountDetails>
</EmpDetail>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>2</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>200.00</Value>
</Amount>
</AmountDetails>
</EmpDetail>
<EmpDetail>
<ProjectDetails>
<Code>Project</Code>
<ProjectReference>
<Reference>
<RefCode>PROJ2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<ProjectDetails>
<Code>Element</Code>
<ProjectReference>
<Reference>
<RefCode>ELEM2</RefCode>
</Reference>
</ProjectReference>
</ProjectDetails>
<Period>
<PeriodNo>3</PeriodNo>
</Period>
<AmountDetails>
<Currency>EUR</Currency>
<Amount>
<Value>500</Value>
</Amount>
</AmountDetails>
</EmpDetail>
</Emp>
查詢:如果PeriodNo,項目的RefCode和元素的RefCode是相同的話,我必須總和金額值並且應該只產生一條記錄。在我的源文件中,前兩行項目的periodno,項目的refcode和元素的refcode是相同的,所以想要在輸出中只得到一個記錄,並且金額值應該是(100 + 5000)= 5100。
I有想法,如果我必須檢查一個值,並做的lineitem的總和,但在這種情況下,我必須檢查每個記錄中的3個值,我總結它。你能告訴我,如何使用xslt繼續使用它。我有XSLT 1.0版本。