我需要将以下xml转换为包含条件的xsl代码,如果此人的部门标签为IT1,则该值应显示为“ bonus +”薪水标签值。请找到我尝试过的xsl代码,但条件不起作用。请帮助
xml code:
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee>
<EmployeeID>1</EmployeeID>
<EmpName>Tarun1 Chatterjee1</EmpName>
<contact>
<PhNo>9111111111</PhNo>
<Email>tarun2.chatterjee2@gmail.com</Email>
</contact>
<Division>
<Department>IT1</Department>
<Salary>10000</Salary>
</Division>
</Employee>
<Employee>
<EmployeeID>2</EmployeeID>
<EmpName>Tarun2 Chatterjee2</EmpName>
<contact>
<PhNo>9111111111</PhNo>
<Email>tarun2.chatterjee2@gmail.com</Email>
</contact>
<Division>
<Department>IT2</Department>
<Salary>20000</Salary>
</Division>
</Employee>
<Employee>
<EmployeeID>3</EmployeeID>
<EmpName>Tarun3 Chatterjee3</EmpName>
<contact>
<PhNo>9111111111</PhNo>
<Email>tarun2.chatterjee2@gmail.com</Email>
</contact>
<Division>
<Department>IT2</Department>
<Salary>20000</Salary>
</Division>
</Employees>
Expected output is
1;Tarun1 Chatterjee1;9111111111;tarun2.chatterjee2@gmail.com;bonus+10000
2;Tarun2 Chatterjee2;9111111111;tarun2.chatterjee2@gmail.com;0+20000
3;Tarun3 Chatterjee3;9111111111;tarun2.chatterjee2@gmail.com;0+20000
xsl代码:
<xsl:template match ="/">
<xsl:for-each select="Employees/Employee">
<xsl:value-of select="EmployeeID" />
<xsl:text>;</xsl:text>
<xsl:value-of select="EmpName"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="contact/PhNo"/>
<xsl:text>;</xsl:text>
<xsl:value-of select="contact/Email"/>
<xsl:text>;</xsl:text>
<xsl:choose>
<xsl:when test="Department='1'">
<xsl:text>bonus+</xsl:text>
<xsl:value-of select="contact/Division/Salary"/>
</xsl:when>
<xsl:when test="Department='2'">
<xsl:text>0+</xsl:text>
<xsl:value-of select="contact/Division/Salary"/>
</xsl:when>
</xsl:choose>
<xsl:text>;</xsl:text>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>