Click to See Complete Forum and Search --> : Need help with Recursive Elements in DTD


kikko
06-04-2008, 06:27 PM
Hi Everyone,
Can anyone help give ideas on how to solve recursive elements please?
eg. questions can have subquestions and subquestions can have sub-subquestions and so on) example below:
<survey>
<questions>
<question>
<questionText></questionText>
<answers>
<answer></answer>
</answers>
<questions>
<question>
<questionText></questionText>
<answers>
<answer></answer>
</answers>
</question>
</questions>
</question>
</questions>
</survey>

i tried this:
<!ELEMENT questions (questions|question)*> but it only works with this(which is what i'm not after):
<questions>
<question>
<questionText></questionText>
<answers>
<answer></answer>
</answers>
</question>
<questions>
<question>
<questionText></questionText>
<answers>
<answer></answer>
</answers>
</question>
</questions>
</questions>

looking forward to your reply

thanks

rpgfan3233
06-04-2008, 08:30 PM
<!ELEMENT survey (questions*)>
<!ELEMENT questions (question+)> <!-- there should be at least one question, right? -->
<!ELEMENT question (questionText+, answers+, questions*)*>

That should get you going. If a question element contains a questionText element, an answers element or a questions element, the remaining elements must be present as well (except a questions element - that is optional, hence the * rather than the +).

I hope this helps!

rpgfan

kikko
06-04-2008, 08:54 PM
Hi rpgfan,
Thank you very much for replying. IT WORKS :)

again, thanks for your time and help

Kikko