您的位置:首页 > 其它

40、dom以xml结尾的文件

2016-10-24 23:18 232 查看
1、student.xml文件

<?xml version="1.0" encoding="utf-8" ?>
<!--
1.书写根元素(因为xsd文件的引入是在根元素上进行的)
2.在根元素上书写schemaLocation属性,填入命名空间,和xsd文件位置.(可以引入多个,没对之间用 空格/回车 隔开.)
3.为引入的xsd定义一个前缀.xmlns="http://www.itcast.cn/xml"
4.固定值. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-->
<students  xmlns="http://www.itcast.cn/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.itcast.cn/xml students.xsd" >
<student number="ITCAST_0001">
<name>tom</name>
<age>18</age>
<sex>male</sex>
</student>
</students>


2、student.xsd文件

<?xml version="1.0"?>
<xsd:schema xmlns="http://www.itcast.cn/xml"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.itcast.cn/xml" elementFormDefault="qualified">
<xsd:element name="students" type="studentsType"/>
<xsd:complexType name="studentsType">
<xsd:sequence>
<xsd:element name="student" type="studentType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="studentType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="age" type="ageType" />
<xsd:element name="sex" type="sexType" />
</xsd:sequence>
<xsd:attribute name="number" type="numberType" use="required"/>
</xsd:complexType>
<xsd:simpleType name="sexType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="male"/>
<xsd:enumeration value="female"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ageType">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="120"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="numberType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="ITCAST_\d{4}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>


3、country.css

c1 {
font-size:200px;
color:red;
}
c2 {
font-size:100px;
color:green;
}
c3 {
font-size:10px;
color:yellow;
}
c4 {
font-size:150px;
color:blue;
}


//country.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="country.css"?>
<c>
<c1>中国</c1>
<c2>美国</c2>
<c3>日本</c3>
<c4>英国</c4>
</c>


4、hello.xml文件

<?xml version="1.0" encoding="gbk" ?>
<students>
<!-- 下面是一个问题学生
-->
<student number="itcast_0001" >
<name><tom></name>
<age>18</age>
<sex>male</sex>
<code><![CDATA[<><><><><<><><]]></code>
</student>
</students>


5、student.dtd文件

<!ELEMENT students (student*) >
<!ELEMENT student (name,age,sex)>
<!ELEMENT name (#PCDATA) >
<!ELEMENT age (#PCDATA) >
<!ELEMENT sex (#PCDATA) >
<!ATTLIST student number ID #REQUIRED>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: