科技公司网站php源码,好看的做地图分析图的网站,南部县房产网,seo搜索引擎优化营销案例实验四 XML
目的#xff1a; 1、安装和使用XML的开发环境 2、认识XML的不同类型 3、掌握XML文档的基本语法 4、了解DTD的作用 5、掌握DTD的语法 6、掌握Schema的语法
实验过程#xff1a; 1、安装XML的编辑器#xff0c;可以选择以下之一 a)XMLSpy b)VScode#xff0c;Vs…实验四 XML
目的 1、安装和使用XML的开发环境 2、认识XML的不同类型 3、掌握XML文档的基本语法 4、了解DTD的作用 5、掌握DTD的语法 6、掌握Schema的语法
实验过程 1、安装XML的编辑器可以选择以下之一 a)XMLSpy b)VScodeVscode中安装XML插件
2、给定一个XML文档test.xml
?xml version1.0?
studentsstudent id001nametom/nameage24/agemajorcourse cidc1Python/course/majorphone18611111111/phonephone18622222222/phone/studentstudent id002namesammy/nameage25/agemajorcourse cidc2C/coursecourse cidc3computer principle/course/majorphone18633333333/phone/student
/studentsa)为test.xml定义一个内部的DTD写出完整的xml文档 如下为进行DTD约束后的完整xml代码:
?xml version1.0?
!DOCTYPE students [!ELEMENT students (student*)!ELEMENT student (name,age,major,phone)!ELEMENT major (course)!ELEMENT name (#PCDATA)!ELEMENT age (#PCDATA)!ELEMENT phone (#PCDATA)!ELEMENT course (#PCDATA)!ATTLIST student id ID #REQUIRED!ATTLIST course cid ID #REQUIRED]
studentsstudent ids001nametom/nameage24/agemajorcourse cidc1Python/course/majorphone18611111111/phonephone18622222222/phone/studentstudent ids002namesammy/nameage25/agemajorcourse cidc2C/coursecourse cidc3computer principle/course/majorphone18633333333/phone/student
/studentsb)为test.xml定义一个外部的Schema文档写出schema文档和使用schema文档后的test.xml 如下是Schema文档代码和导入外部Schema约束的xml完整代码 Schema文档代码(test.xsd):
?xml version1.0 encodingUTF-8?
xs:schema attributeFormDefaultunqualified elementFormDefaultqualified targetNamespacehttp://www.zhjTest.cn xmlns:xshttp://www.w3.org/2001/XMLSchemaxs:element namestudents typezhj:studentsType xmlns:zhjhttp://www.zhjTest.cn/xs:complexType namecourseTypexs:simpleContentxs:extension basexs:stringxs:attribute typexs:string namecid useoptional//xs:extension/xs:simpleContent/xs:complexTypexs:complexType namemajorTypexs:sequencexs:element typezhj:courseType namecourse maxOccursunbounded minOccurs0 xmlns:zhjhttp://www.zhjTest.cn//xs:sequence/xs:complexTypexs:complexType namestudentTypexs:sequencexs:element namenamexs:simpleTypexs:restriction basexs:stringxs:enumeration valuetom/xs:enumeration valuesammy//xs:restriction/xs:simpleType/xs:elementxs:element nameagexs:simpleTypexs:restriction basexs:stringxs:enumeration value24/xs:enumeration value25//xs:restriction/xs:simpleType/xs:elementxs:element typezhj:majorType namemajor xmlns:zhjhttp://www.zhjTest.cn/xs:element namephone maxOccursunbounded minOccurs0xs:simpleTypexs:restriction basexs:stringxs:enumeration value18611111111/xs:enumeration value18622222222/xs:enumeration value18633333333//xs:restriction/xs:simpleType/xs:element/xs:sequencexs:attribute typexs:string nameid useoptional//xs:complexTypexs:complexType namestudentsTypexs:sequencexs:element typezhj:studentType namestudent maxOccursunbounded minOccurs0 xmlns:zhjhttp://www.zhjTest.cn//xs:sequence/xs:complexType
/xs:schemaxml完整代码:
?xml version1.0?
!DOCTYPE students [!ELEMENT students (student*)!ELEMENT student (name,age,major,phone)!ELEMENT major (course)!ELEMENT name (#PCDATA)!ELEMENT age (#PCDATA)!ELEMENT phone (#PCDATA)!ELEMENT course (#PCDATA)!ATTLIST student id ID #REQUIRED!ATTLIST course cid ID #REQUIRED]
students xmlns:xshttp://www.w3.org/2001/XMLSchema-instancexmlnshttp://www.zhjTest.cnxs:schemaLocationhttp://www.zhjTest.cn test.xsd
student ids001nametom/nameage24/agemajorcourse cidc1Python/course/majorphone18611111111/phonephone18622222222/phone/studentstudent ids002namesammy/nameage25/agemajorcourse cidc2C/coursecourse cidc3computer principle/course/majorphone18633333333/phone/student
/students3、编写实验报告并提交至超星。