'Is there a way to reference an element from another element in XML DTD?

I'm making a 'students' XML that stores students and its information like name, address, telephone...

In this case I have an element 'helped-by' inside 'additional-information' in which I want to "reference" the students that have helped this student and their basic information.

This is my code:

<!ELEMENT students (student+)>
<!ELEMENT student
    (name, surname, address, telephone-numbers, procedence,
    student-marks*, additional-information, comments)>
<!ATTLIST student ID ID #REQUIRED>
<!ATTLIST student sex (male|female) #IMPLIED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT surname (#PCDATA)>
<!ELEMENT address (street, number, city)>
    <!ELEMENT street (#PCDATA)>
    <!ELEMENT number (#PCDATA)>
    <!ELEMENT city (#PCDATA)>
<!ELEMENT telephone-numbers (telefono+)>
    <!ELEMENT telephone-number (#PCDATA)>
        <!ATTLIST telefono-number headline CDATA #REQUIRED>
<!ELEMENT procedence (province|origin-country)>
    <!ELEMENT province (#PCDATA)>
    <!ELEMENT origin-country (#PCDATA)>
<!ELEMENT student-marks (#PCDATA|evaluation)*>
    <!ELEMENT evaluation (mark)>
    <!ATTLIST evaluation evaluation-number (first | second | final) #REQUIRED>
        <!ELEMENT mark (#PCDATA)>
<!ELEMENT additional-information (sports-team?, height?, hobbies*, helped-by*)>
    <!ELEMENT sports-team (#PCDATA)>
    <!ELEMENT height (#PCDATA)>
    <!ELEMENT hobbies (#PCDATA)>
    <!ELEMENT helped-by ()>
<!ELEMENT comments (comment)>
    <!ELEMENT comment (#PCDATA)>

I've thought of doing the following:

<!ELEMENT helped-by (name, surname)>

But I'm unsure if that's correct or the best alternative. I'd appreciate some advice on the topic, thanks for your time.



Solution 1:[1]

For DTD, I'd recommend IDREF (see here for more info on attribute types).

<!ELEMENT helped-by EMPTY>
<!ATTLIST helped-by
          refid IDREF #REQUIRED>

The element would look like this:

<helped-by refid="some_student_id"/>

If you wanted to allow more than one "helper", you could use IDREFS:

<!ATTLIST helped-by
          refid IDREFS #REQUIRED>

The element could look like this (or it could be the same as above; as long as there is more than one corresponding id):

<helped-by refid="some_student_id another_student_id"/>

Also, the attribute doesn't have to be refid. It can be named something else.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel Haley