如何写一个dtd文件


class.dtd

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT classrooms (classroom+)>
<!ELEMENT classroom (grade,classname,students)>
<!ATTLIST classroom id  ID #REQUIRED>
<!ELEMENT classname (#PCDATA)>
<!ELEMENT grade (#PCDATA)>
<!ELEMENT students (student+)>
<!ELEMENT student (id,studentname,age)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT studentname (#PCDATA)>
<!ELEMENT age (#PCDATA)>

class.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE classrooms SYSTEM "class.dtd">
<classrooms>
    <classroom id="c1">
        <grade>2010</grade>
        <classname>10级计算机应用技术一班</classname>
        <students>
            <student>
                <id>1</id>
                <studentname>宋发准</studentname>
                <age>12</age>
            </student>
            <student>
                <id>1</id>
                <studentname>宋发准</studentname>
                <age>12</age>
            </student>
        </students>
    </classroom>
    <classroom id="c2">
        <grade>2010</grade>
        <classname>10级计算机应用技术二班</classname>
        <students>
            <student>
                <id>2</id>
                <studentname>李四</studentname>
                <age>22</age>
            </student>
            <student>
                <id>2</id>
                <studentname>李四</studentname>
                <age>22</age>
            </student>
        </students>
    </classroom>
</classrooms>

?=0次或者1次,+=一次或者多次,*=0次或者多次


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM