Johny Doe
Johny Doe

Reputation: 59

XML - DTD - Content error in the external subset

I'm trying to validate following .dtd code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PERSON [

<!ELEMENT lista_plac_dokument (autor, informacje_o_dokumencie, zatrudnieni)>
    <!ELEMENT autor (autor_imię, autor_nazwisko, autor_adres+)>
        <!ELEMENT autor_imię   (#PCDATA)>
        <!ELEMENT autor_nazwisko   (#PCDATA)>
        <!ELEMENT autor_adres (ulica,(kod_pocztowy|zip),miasto,kraj)>
        <!ELEMENT ulica  (#PCDATA)>
        <!ELEMENT kod_pocztowy  (#PCDATA)>
        <!ELEMENT miasto   (#PCDATA)>
        <!ELEMENT kraj   (#PCDATA)>

    <!ELEMENT informacje_o_dokumencie (kategoria_dokumentu)>
        <!ELEMENT kategoria_dokumentu   (#PCDATA)>

    <!ELEMENT zatrudnieni (osoba*)>

    <!ELEMENT osoba (imię, nazwisko, stanowisko, data_zatrudnienia, wynagrodzenie_brutto_12_miesięcy, informacje_osobiste+)>
        <!ATTLIST osoba osoba_id ID #REQUIRED>
        <!ELEMENT imię   (#PCDATA)>
        <!ELEMENT nazwisko  (#PCDATA)>
        <!ELEMENT stanowisko   (#PCDATA)>
        <!ELEMENT data_zatrudnienia   (#PCDATA)>
        <!ELEMENT wynagrodzenie_brutto_12_miesięcy   (#PCDATA)>
        <!ELEMENT informacje_osobiste (wiek?)>
        <!ELEMENT wiek (#PCDATA)>
]>

but each time I'm trying to check the syntax of it with the usage of following command:

xmllint --loaddtd person.dtd person.xml --noout

I do obtain following error:

person.dtd:29: parser error : Start tag expected, '<' not found
]>
  ^
person.dtd:2: parser error : Content error in the external subset
<!DOCTYPE PERSON [
^
person.dtd:2: parser error : Content error in the external subset
<!DOCTYPE PERSON [
^

Upvotes: 1

Views: 1817

Answers (1)

imhotap
imhotap

Reputation: 2500

The .dtd file (the external declaration subset) must only contain actual markup declarations (<!ELEMENT ...> and others). <!DOCTYPE ... [ and ]> is only used in an .xml file (an instance document).

Try removing

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PERSON [

from the begin and

]>

from the end of your .dtd file.

Upvotes: 5

Related Questions