Search code examples
xmldtd

XML, DTD file missing information


I need some help, making sure I understand this and doing it right.

The element rit

1.1. The element rit has an attribute version that must have the value 1.0

1.2. The element rit has a required attribute date that has a text representing the date of feed.

1.3. The element rit can have 0 or more feed elements

1.4. The element rit’s last element is a required doc-copyright element. The copyright statement for your company.

<!ELEMENT rit (version, date, feed*, doc-copyright) >

<!ATTLIST ret version CDATA #FIXED "1.0">

<!ATTLIST ret date CDATA #REQUIRED >

Thank you.


Solution

  • If version and date are attributes, they shouldn't be in the content model of the rit element declaration (remove them from (version, date, feed*, doc-copyright)).

    Don't forget to add element declarations for the date and doc-copyright elements.

    Having multiple ATTLIST declarations for an element is ok, but in my opinion it's easier to read and maintain a single ATTLIST for an element.

    Example of changes...

    <!ELEMENT rit (feed*, doc-copyright)>
    
    <!ATTLIST ret 
              version CDATA #FIXED    "1.0"
              date    CDATA #REQUIRED     >
    
    <!ELEMENT  feed (#PCDATA)>
    <!ELEMENT  doc-copyright (#PCDATA)>