为什么引入xsd文件的时候,eclipse会报错?

为什么引入xsd文件的时候,eclipse会报错?

<?xml version="1.0" encoding="UTF-8"?>
<!-- 教学计划 -->
<teaching-plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="planSchema.xsd">
    <!-- 课程 -->
    <course no="001">
        <!-- 课程名 -->
        <course-name>大学英语</course-name><course-name>大学英语</course-name>
        <!-- 课时 -->
        <class-hour>36</class-hour>
        <!-- 考核方式 -->
        <exam-form>考试</exam-form>
    </course>
        <!-- 课程 -->
    <course no="002">
        <!-- 课程名 -->
        <course-name>高等数学</course-name>
        <!-- 课时 -->
        <class-hour>70</class-hour>
        <!-- 考核方式 -->
        <exam-form>考试</exam-form>
    </course>
        <!-- 课程 -->
    <course no="003">
        <!-- 课程名 -->
        <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">
    <complexType name="name1">
        <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>    
</schema>

http://img1.sycdn.imooc.com//climg/5d39858d0001db8114130845.jpg

正在回答

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

1回答

同学你好!

  1. 同学可以点击红叉看一下报错信息

    http://img1.sycdn.imooc.com//climg/5d399128000135d704380097.jpg

  2. 根据报错信息说明teaching-plan没有找到,因此同学的xsd文件有误,老师对同学的xsd文件做了一些修改,同学可以对比一下

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<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>

3.修改后xml以下位置报红,属于正常约束,因为同学的xsd文件中给出的约束是id不是no

http://img1.sycdn.imooc.com//climg/5d39929400018e8a03390166.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

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

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

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

在线咨询

领取优惠

免费试听

领取大纲

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