xmlspy2012的汉化版和破解补丁:点击打开链接
dtd基础知识:
<?xml version="1.0" encoding="UTF-8"?>
<!-- DTD -->
<!--
常用控制符:
?表示0次或者1次
*表示0次或者多次
+表示1次或者多次
默认表示1次
ATTLIST定义属性
CDATA 字符
ID id不能以数字开头
#REQUIRED 必须存在
-->
<!DOCTYPE persons [
<!ELEMENT persons (person+)>
<!ELEMENT person (name,password?,age)>
<!ATTLIST person id ID #REQUIRED>
<!ATTLIST person sex CDATA #REQUIRED>
<!ELEMENT id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT password (#PCDATA)>
<!ELEMENT age (#PCDATA)>
]>
<persons>
<person id="p1" sex="男">
<name>san</name>
<password>san</password>
<age>12</age>
</person>
</persons>
dtd实例:
dtd文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- 定义的节点不能重复(cname和sname)-->
<!ELEMENT classroom (cname,cgrade,sutdents)>
<!ATTLIST classroom cid ID #REQUIRED>
<!ELEMENT cname (#PCDATA)>
<!ELEMENT cgrade (#PCDATA)>
<!ELEMENT sutdents (student+)>
<!ELEMENT student (sid,sname,age)>
<!ELEMENT sid (#PCDATA)>
<!ELEMENT sname (#PCDATA)>
<!ELEMENT age (#PCDATA)>
xml实例引入dtd文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE classroom SYSTEM "classroom.dtd">
<classroom cid="c1">
<cname>职专</cname>
<cgrade>2012</cgrade>
<sutdents>
<student>
<sid></sid>
<sname></sname>
<age>12</age>
</student>
</sutdents>
</classroom>