XML / XSL:需要结束标记,但结尾标记就在那里。不断收到错误

时间:2016-10-06 12:47:26

标签: xml xslt

我正在制作时间表xml和xsl,xsl显然是错误的并且说出以下错误: 第15行第9列出错 - SXXP0003:XML解析器报告的错误:元素类型" ol"必须由匹配的结束标记终止"< / 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>

1 个答案:

答案 0 :(得分:0)

消除XSLT中的XML级语法错误......

更改

                <xsl:for-each select="/timetable/module"/>

                <xsl:for-each select="/timetable/module">

并更改

                        <td><xsl: value-of select="name"/></td>

                        <td><xsl:value-of select="name"/></td>

这些更正只会使您的XSLT格式正确。 (Your comment表示您此时并未寻找其他错误。)