【问题标题】:XML / XSL: Need ending tag, yet ending tag is there. Keep getting errorXML / XSL:需要结束标记,但结束标记在那里。不断报错
【发布时间】: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>

【问题讨论】:

  • 注意:我现在不是在寻找其他错误,我正在尝试测试它。

标签: xml xslt


【解决方案1】:

要消除 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 表示您目前不寻找更多错误。)

【讨论】:

    猜你喜欢
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-05
    相关资源
    最近更新 更多