如何寫一個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