schema报错

schema报错

相关代码:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE teaching-plan SYSTEM "plan.dtd">
<!--教学计划-->
<teaching-plan xmlns="http://www.imooc.com/plan-schema"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.imooc.com/plan-schema  plan.xsd">
    <course id="3309">
        <course-name>大学英语</course-name>
        <class-hour>36</class-hour>
        <exam-form>考试</exam-form>
     </course>
    <course id="3310">
        <course-name>高等数学</course-name>
        <class-hour>70</class-hour>
        <exam-form>考试</exam-form>
    </course>
    <course id="3311">
        <course-name>计算机应用基础</course-name>
        <class-hour>108</class-hour>
        <exam-form>上机考试</exam-form>
    </course>
</teaching-plan>

相关代码:

<?xml version="1.0" encoding="UTF-8" ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.imooc.com/plan-schema" elementFormDefault="qualified">
    <element name="teaching-plan">
        <complexType>
            <sequence>
                <element name="course" minOccurs="1" maxOccurs="100">
                    <complexType>
                        <sequence>
                            <element name="course-name" type="string"></element>
                            <element name="class-hour" >
                                <simpleType>
                                    <restriction base="integer">
                                        <minInclusive value="20"></minInclusive>
                                        <maxInclusive value="110"></maxInclusive>
                                    </restriction>
                                </simpleType>
                            </element>
                            <element name="exam-form" type="string"></element>
                        </sequence>
                        <attribute name="id" type="string" use="required"></attribute>
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>
</schema>

问题描述:

id,exam-form字段下面红线报错

相关截图:

https://img1.sycdn.imooc.com//climg/61bf06e509e09bf919201080.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小尤 2021-12-19 18:30:43

同学你好,同学引入了两个约束文件,从而可能出现异常。则建议同学删除dtd文件试一下。如下所示:

https://img1.sycdn.imooc.com//climg/61bf07f909a45d3d06610165.jpg

祝学习愉快!

  • 提问者 该筱该 #1

    这个试过没有用,

    Invalid content was found starting with element 'exam-form'. '"http://www.imooc.com/plan-schema":class-hour' is expected to occur a minimum of '20' times in the current sequence. '19' more instances are required to satisfy this constraint.这是exam-form的报错,Attribute 'id' is not allowed to appear in element 'course'.这是id字段的报错

    2021-12-19 18:33:18
  • 好帮手慕小尤 回复 提问者 该筱该 #2

    同学你好,老师测试代码是没有问题的,可能是缓存的原因。建议同学重新创建两个文件,然后将xml与xsd文件中代码复制粘贴进新文件中试一下。

    祝学习愉快!

    2021-12-20 10:12:17
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师