validationdtdsgml

validate SGML DTD


I wrote the following SGML DTD:

<!DOCTYPE tvguide[
    <!ELEMENT tvguide--(date,channel+)>
    <!ELEMENT date--(#PCDATA)>
    <!ELEMENT channel--(channel_name,format?,program*)>
    <!ELEMENT channel--(#PCDATA)>
    <!ATTLIST channel teletext (yes|no) "no">
    <!ELEMENT format--(#PCDATA)>
    <!ELEMENT program--(name,start_time,(end_time|duration))>
    <!ATTLIST program
        min_age CDATA #REQUIRED
        lang CDATA #IMPLIED es>
    <!ELEMENT name--(#PCDATA)>
    <!ELEMENT start_time--(#PCDATA)>
    <!ELEMENT end_time--(#PCDATA)>
    <!ELEMENT duration--(#PCDATA)>]>

Which tool should I use to check if there are any syntax errors and where, and if it's a valid SGML DTD?

Which tool should I use to validate files using this DTD? I would prefer a program for windows but a linux binary or a library written in PHP, C, C++, Java or Javascript also would be fine.


Solution

  • Take a look at SP from James Clark. I use OmniMark to validate SGML, but I don't think you can find copies anymore.

    You should get errors about tag minimization (you need spaces before/after/between the --). You should also get errors about the element channel being declared twice and an error about the "es" in the lang attribute declaration for program.

    Here's a valid version for reference:

     <!DOCTYPE tvguide [
     <!ELEMENT tvguide - - (date,channel+)>
     <!ELEMENT date - - (#PCDATA)>
     <!ELEMENT channel - - (channel_name,format?,program*)>
     <!ATTLIST channel teletext (yes|no) "no">
     <!ELEMENT format - - (#PCDATA)>
     <!ELEMENT program - - (name,start_time,(end_time|duration))>
     <!ATTLIST program
          min_age CDATA #REQUIRED
          lang CDATA "es">
     <!ELEMENT name - - (#PCDATA)>
     <!ELEMENT start_time - - (#PCDATA)>
     <!ELEMENT end_time - - (#PCDATA)>
     <!ELEMENT duration - - (#PCDATA)>
     ]>