xml文件和xsd文件没有连上,xml文件中没有任何报错

来源:2-5 XML Schema

你管的着嘛

2019-06-26 14:50:54

<!-- plan_schema.xml -->

<?xml version="1.0" encoding="UTF-8"?>

<teaching-plan xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
" xsi:noNamespaceSchemaLocation="plan_schema.xsd">

 <course no="1">

  <course-name>大学英语</course-name>

  <class-hour>36</class-hour>

  <exam-form>考试</exam-form>

 </course>

 <course no="2">

  <course-name>高等数学</course-name>

  <class-hour>70</class-hour>

  <exam-form>考试</exam-form>

 </course>

 <course no="3">

  <course-name>计算机应用基础</course-name>

  <class-hour>108</class-hour>

  <exam-form>上机考试</exam-form>

 </course>

</teaching-plan>





<!-- plan_schema.xsd文件 -->

<?xml version="1.0" encoding="UTF-8"?>

<schema xmlns="
http://www.w3.org/2001/XMLSchema
">

 <element name="teaching-plan">

  <complexType>

   <sequense>

       <element name="course" minOccurs="1" maxOccurs="9999">

         <complexType>

          <sequence>

           <element name="course-name" type="string"></element>

           <element name="class-hour">

            <simpleType>

             <restriction>

              <minInclusive value="1"></minInclusive>

              <maxInclusive value="10"></macInclusive>

             </restriction>

            </simpleType>

           </element>

           <element name="exam-form" type="string"></element>

          </sequence>

          <!-- 定义属性 -->

          <attibute name="no" type="string" use="required"></attibute>

         </complexType>

       </element>

   </sequense>

  </complexType>

 </element>

</schema>

写回答

1回答

好帮手慕柯南

2019-06-26

同学你好!

xsd文件中报错呢

  1. max同学误写成了mac

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

  2. sequence同学误写为了sequense

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

  3. attribute同学中间忘记写r了呢

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

  4. 以下位置需要添加类型数据类型

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

    5.修改后的代码如下:

<?xml version="1.0" encoding="UTF-8"?>
 
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<!--  xmlns="http://www.w3.org/2001/XMLSchema" -->
 <element name="teaching-plan">
 
  <complexType>
 
   <sequence>
 
       <element name="course" minOccurs="1" maxOccurs="9999">
 
         <complexType>
 
          <sequence>
 
           <element name="course-name" type="string"></element>
 
           <element name="class-hour">
 
            <simpleType>
 
             <restriction base="integer">
 
              <minInclusive value="1"></minInclusive>
 
              <maxInclusive value="10"></maxInclusive>
 
             </restriction>
 
            </simpleType>
 
           </element>
 
           <element name="exam-form" type="string"></element>
 
          </sequence>
 
          <!-- 定义属性 -->
 
          <attribute name="no" type="string" use="required"></attribute>

         </complexType>
 
       </element>
 
   </sequence>
 
  </complexType>
 
 </element>
 
</schema>

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

0

0 学习 · 9666 问题

查看课程