引入xsd时候报错
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!DOCTYPE teaching-plan SYSTEM "plan-data.dtd" > -->
<teaching-plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="XMLSchema.xsd" >//报错位置,没提示,啥都没,就一个x
<coure no="2321">
<coure-name>大学英语</coure-name>
<class-hour>36</class-hour>
<exam-form>考试</exam-form>
</coure>
<coure no="2">
<course-name>高等数学</course-name>
<class-hour>70</class-hour>
<exam-form>考试</exam-form>
</coure>
<coure no="3">
<course-name>计算机应用基础</course-name>
<class-hour>108</class-hour>
<exam-form>上机考试</exam-form>
</coure>
</teaching-plan>
<?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema"> <element name="techhing-plan"> <complexType> <sequence> <element name="coure"> <complexType> <sequence> <element name="coure-name" type="string"></element> <element name="class-hour" type="float"></element> <element name="exam" type="string"></element> </sequence> </complexType> </element> </sequence> </complexType> </element> </schema>
正在回答
同学你好!
你的xml和xsd中的teaching-plan 并不匹配呢
xml中你写的teaching-plan
xsd中你写的teachhing-plan
建议同学将上面两者统一一下
你的course-name标签,xml和xsd中写的也不统一:
xml中写的course-name:
xsd中写的coure-name:
建议同学将上面的两者也统一一下
你的no报错,因为在xsd中你定义的是id,并且你的位置放错了,并且在xml中应该为id
老师对同学的代码,做了修改,你可以参考一下:
<?xml version="1.0" encoding="UTF-8"?> <teaching-plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XMLSCHEma.xsd" > <coure id="2321"> <coure-name>大学英语</coure-name> <class-hour>36</class-hour> <exam-form>考试</exam-form> </coure> <coure id="2"> <coure-name>高等数学</coure-name> <class-hour>70</class-hour> <exam-form>考试</exam-form> </coure> <coure id="3"> <coure-name>计算机应用基础</coure-name> <class-hour>108</class-hour> <exam-form>上机考试</exam-form> </coure> </teaching-plan>
xsd:
<?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema"> <element name="teaching-plan"> <complexType> <sequence> <element name="coure" maxOccurs="1000"> <complexType> <sequence> <element name="coure-name" type="string"></element> <element name="class-hour" > <simpleType> <restriction base="integer"> <maxInclusive value="110"></maxInclusive> <minInclusive value="20"></minInclusive> </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>
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
<teaching-plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="XMLSCHEma.xsd" >//报错
<coure no="2321">
<coure-name>大学英语</coure-name>
<class-hour>36</class-hour>
<exam-form>考试</exam-form>
</coure>
<coure no="2">
<course-name>高等数学</course-name>
<class-hour>70</class-hour>
<exam-form>考试</exam-form>
</coure>
<coure no="3">
<course-name>计算机应用基础</course-name>
<class-hour>108</class-hour>
<exam-form>上机考试</exam-form>
</coure>
</teaching-plan>
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<element name="teachhing-plan">
<complexType>
<sequence>
<element name="coure" maxOccurs="1000">
<complexType>
<sequence>
<element name="coure-name" type="string"></element>
<element name="class-hour" >
<simpleType >
<restriction base="integer">
<maxInclusive value="110"></maxInclusive>
<minInclusive value="20"></minInclusive>
</restriction>
</simpleType>
</element>
<element name="exam-form" type="string"></element>
</sequence>
</complexType>
</element>
</sequence>
<attribute name="id" type="string" use="required"></attribute>
</complexType>
</element>
</schema>
- 参与学习 人
- 提交作业 676 份
- 解答问题 9666 个
本阶段将从前端网页搭建入手,到Java Web基础,前后端结合助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星