老师,我这里两个位置报错是什么原因

来源:2-6 自由编程

不懂装懂xu

2020-08-29 16:17:42

http://img.mukewang.com/climg/5f4a0e270962020907350470.jpg

http://img.mukewang.com/climg/5f4a0e050997945c08910499.jpg

<?xml version="1.0" encoding="UTF-8"?>
<!-- !DOCTYPE teaching SYSTEM "plan.dtd" -->
<teaching xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="plan.xsd">
 <course id="001">
  <course-name>大学英语</course-name>
  <class-hour>36</class-hour>
  <exam-form>考试</exam-form>
 </course>
 <course id="002">
  <course-name>高等数学</course-name>
  <class-hour>70</class-hour>
  <exam-form>考试</exam-form>
 </course>
 <course id="003">
  <course-name>计算机应用基础</course-name>
  <class-hour>108</class-hour>
  <exam-form>上机考试</exam-form>
 </course>
</teaching>


<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
 <element name="teacing">
  <complexType>
   <sequence>
    <element name="course" minOccurs="1" maxOccurs="9999">
     <complexType>
      <sequence>
       <element name="course-name" type="string"></element>
       <element name="class-hour">
        <restriction base="integer">
          <minInclusive value="0"></minInclusive>
          <maxInclusive value="100"></maxInclusive>
        </restriction>
       </element>
       <element name="exam-from" type="string"></element>
      </sequence>
     </complexType>
    </element>
   </sequence>
  </complexType>
 </element>
</schema>

错误1:cvc-elt.1: Cannot find the declaration of element
 'teaching'.

错误2:s4s-elt-must-match.1: The content of 'class-hour' must match (annotation?, (simpleType |
 complexType)?, (unique | key | keyref)*)). A problem was found starting at: restriction.

写回答

1回答

好帮手慕小脸

2020-08-29

同学你好,

1、xml文件报错是因为同学在xsd文件中单词书写错误,如下:

http://img.mukewang.com/climg/5f4a15ee09c015f704540120.jpg

2、xsd文件报错是,因为文件中缺少标签 <simpleType>,将其添加上即可

http://img.mukewang.com/climg/5f4a14c00982055f06180338.jpg

3、上述内容更改完成后,在xml文件中依旧会出现其他错误,如下:

http://img.mukewang.com/climg/5f4a166d0916686405430385.jpg

修改:

    1)在xsd文件中需要定义<attribute>标签,如下:

http://img.mukewang.com/climg/5f4a168e09b5bc6f06880062.jpg

    2)exam-form的单词书写错误

http://img.mukewang.com/climg/5f4a16f809b0bea306450060.jpg  

  3)限制最大值到100,这里108会出现报错

http://img.mukewang.com/climg/5f4a1793091b5fe405240162.jpg

同学可选择将最大值调整,或更改数据

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

0

0 学习 · 9666 问题

查看课程