Creating valid XML document(exp 14)

 interalDTD.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE personinfo [
    <!ELEMENT personinfo (person+)>
    <!ELEMENT person (name, profession, age, city)>
    <!ELEMENT name (firstname,lastname)>
    <!ELEMENT firstname (#PCDATA)>
    <!ELEMENT lastname (#PCDATA)>
    <!ELEMENT profession (#PCDATA)>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT city (#PCDATA)>
    <!ATTLIST person pid ID #REQUIRED>
]>
<!-- DTD - Document Type Defination -->
<personinfo>
    <person pid="P1">
        <name>
            <firstname>John</firstname>
            <lastname>Doe</lastname>
        </name>
        <profession>Student</profession>
        <age>21</age>
        <city>Ichalkaranji</city>
    </person>
    <person pid="P2">
        <name>
            <firstname>ABC</firstname>
            <lastname>XYZ</lastname>
        </name>
        <profession>Teacher</profession>
        <age>42</age>
        <city>Kolhapur</city>
    </person>
</personinfo>

......................................................................................

ExternalDTD.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE personinfo SYSTEM "personinfo.dtd">
<!-- DTD - Document Type Defination -->
<personinfo>
    <person pid="P1">
        <name>
            <firstname>John</firstname>
            <lastname>Doe</lastname>
        </name>
        <profession>Student</profession>
        <age>21</age>
        <city>Sangli</city>
    </person>
    <person pid="P2">
        <name>
            <firstname>ABC</firstname>
            <lastname>XYZ</lastname>
        </name>
        <profession>Teacher</profession>
        <age>42</age>
        <city>Kolhapur</city>
    </person>
</personinfo>

......................................................................................

personinfo.dtd

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT personinfo (person+)>
<!ELEMENT person (name, profession, age, city)>
<!ELEMENT name (firstname, lastname)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT profession (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ATTLIST person pid ID #REQUIRED>

Post a Comment

0 Comments