XML文件为
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="text.xsl"?>
<roster>
<student ID="101">
<name>李华</name>
<sex>男</sex>
<birthday>1978.9.12</birthday>
<score>92</score>
<skill>Java</skill>
<skill>Oracle</skill>
<skill>SQL</skill>
</student>
<studnet ID="102">
<name>倪冰</name>
<sex>女</sex>
<birthday>1979.1.12</birthday>
<score>89</score>
<skill>Visual Basic</skill>
<skill>SQL</skill>
<skill>ASP</skill>
</studnet>
...................
</roster>
text.xsl文件内容为:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<title>培训中心成绩单</title>
<h2 align="center">学生成绩单 </h2>
<table border="1" cellpadding="0" align="center">
<tr align="center" bgcolor="#dadada">
<td>编号</td>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>成绩</td>
<td>评价</td>
</tr>
<xsl:for-each select="/roster/student">
<tr>
<td>
<xsl:value-of select="@ID"/>
</td>
<td> <xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="sex"/>
</td>
<td>
<xsl:value-of select="birthday"/>
</td>
<td>
<xsl:value-of select="score"/>
</td>
<td>
<xsl:choose>
<xsl:when test="score < 60 ">不及格</xsl:when>
<xsl:when test="score < 80 ">一般</xsl:when>
<xsl:when test="score > 90 ">优秀</xsl:when>
<xsl:otherwise>良好</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
结果只显示了ID为101,名字叫李华的第1个student,错误应该是第2处红色地方,如果改成]<xsl:for-each select="/roster/*">才会显示所有student,但roster下如果有除了student以外的节点也会混淆,另外改成//student,/roster//student都只会显示第1个student