【发布时间】:2016-10-06 12:47:26
【问题描述】:
我正在做一个时间表 xml 和 xsl,xsl 显然是错误的,并且说以下错误: 第 15 行第 9 列出错 - SXXP0003:XML 解析器报告的错误:元素类型“ol”必须由匹配的结束标记“”终止。
XML 代码在这里:http://textuploader.com/dabkb
XSL 是这样的:
<xsl:template match="/">
<html>
<head>
<title>Timetable Wage</title>
</head>
<body>
<h2>Print the names of all modules on the timetables</h2>
<ol>
<xsl:for-each select="/timetable/module"/>
<li><xsl:value-of select="name"/></li>
</xsl:for-each>
</ol>
<h2>Print the names of all modules which have an exam</h2>
<table border="1">
<tr>
<th>Modules with exam</th>
</tr>
<xsl:for-each select="/timetable/module/exam/..">
<tr>
<td><xsl: value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
<h2>Print name, day, time, room of all lab classes</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Day</th>
<th>Time</th>
<th>Room</th>
</tr>
<xsl:for-each select="/timetable/module/name|/timetable/module/classes/lab">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="day"/></td>
<td><xsl:value-of select="time"/></td>
<td><xsl:value-of select="room"/></td>
</tr>
</xsl:for-each>
</table>
<h2>Print the details of any module which has more than one lecture in a week</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Day</th>
<th>Time</th>
<th>Room</th>
</tr>
<xsl:for-each select="/timetable/module/classes/lecture[@id>0]|//name">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="day"/></td>
<td><xsl:value-of select="time"/></td>
<td><xsl:value-of select="room"/></td>
</tr>
</xsl:for-each>
</table>
<h2>Print the day, time and room of all classes which take place in computer labs</h2>
<table border="1">
<tr>
<th>Day</th>
<th>Time</th>
<th>Room</th>
</tr>
<xsl:for-each select="//room[@type='computerLab']/..|//name">
<tr>
<td><xsl:value-of select="day"/></td>
<td><xsl:value-of select="time"/></td>
<td><xsl:value-of select="room"/></td>
</tr>
</xsl:for-each>
</table>
<h2>Print the name of all modules which have classes on a Monday</h2>
<table border="1">
<tr>
<th>Name</th>
</tr>
<xsl:for-each select="//day[text()='Mon']/..|//name">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
【问题讨论】:
-
注意:我现在不是在寻找其他错误,我正在尝试测试它。