为什么编译器会报错呢

为什么编译器会报错呢

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

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

    <course>

       <hour>36</hour>

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

    </course>

     <course>

       <name>高等数学</name>

       <hour>70</hour>

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

    </course>

     <course>

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

       <hour>108</hour>

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

    </course>

</plan>

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

<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/hr" xmlns:tns="http://www.example.org/hr" elementFormDefault="qualified">

   <element name="plane">

                 <complexType>

                          <sequence>

                              <element name="name"> </element>

                              <element name="hour"></element>

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

                          </sequence>

                 </complexType>

       

   </element>


</schema>

在xml中的plane标签那一行会报错

正在回答

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

3回答

你好同学,你的代码存在问题,

1、plane子母写错了,应该为plan。

2、约束文件的标签头应改为<schema xmlns="http://www.w3.org/2001/XMLSchema">

3、你没有约束course元素,针对你的代码进行了修改,可以参考如下代码进行修改,祝学习愉快~

约束文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
   <element name="plan">
           <complexType>
               <sequence>
               <element name="course"  minOccurs="0" maxOccurs="unbounded"
                 <complexType>
                    <sequence>
                        <element name="name"> </element>
                        <element name="hour"></element>
                        <element name="exam-form"></element>
                    </sequence>
                 </complexType>
             </element>
               </sequence>
           </complexType>
   </element>
</schema>

xml文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?>
<plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="hrs.xsd">
    <course>
         <name>高等数学</name>
        <hour>36</hour>
        <exam-form>考试</exam-form>
    </course>
     <course>
       <name>高等数学</name>
       <hour>70</hour>
       <exam-form>考试</exam-form>
    </course>
     <course>
       <name>计算机应用基础</name>
       <hour>108</hour>
       <exam-form>上机考试</exam-form>
    </course>
</plan>


慕布斯645313 2018-10-11 12:45:18

你的plane写错了,应该是plan吧

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

  • 提问者 我叫飞天德 #1
    改过来了 但是我是xml上plan标签报的错= =,改过来也不行
    2018-10-11 19:01:20
chrismorgen 2018-10-10 10:59:48

建议你将hr.xsd文件中的代码也粘贴一下,方便老师具有针对性的为你解答,祝学习愉快~

  • 提问者 我叫飞天德 #1
    <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/hr" xmlns:tns="http://www.example.org/hr" elementFormDefault="qualified"> <element name="plane"> <complexType> <sequence> <element name="name"> </element> <element name="hour"></element> <element name="exam-form"></element> </sequence> </complexType> </element> </schema>
    2018-10-10 22:24:34
问题已解决,确定采纳
还有疑问,暂不采纳

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

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

0 星
从网页搭建入门Java Web2018版
  • 参与学习           人
  • 提交作业       1088    份
  • 解答问题       10204    个

如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

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