0

I'm new to DTD and I'm not sure if I understand this code correctly.

<!ELEMENT P         - - (#PCDATA) +(tag1 | tag2 | tag3) >

Is this code allows P tag to contain tag1, tag2 and tag3?

potame
  • 7,597
  • 4
  • 26
  • 33
Viin
  • 427
  • 1
  • 4
  • 9

1 Answers1

1

This is an SGML syntax, not XML. You can see it because between the name of the declared element (P) and the contents declaration (#PCDATA), you encounter "- -", which means that neither the start tag nor the end tag can be omitted (otherwise you could have something like "- O" which would mean the end tag can be omitted).

The +(tag1 | tag2 | tag3) means that you are allowed to use tag1, tag2, tag3 wherever you want, nested in the P element. It is recursive, meaning that, assuming other elements were allowed within P, you could allow this tags to appear as well, even if they are not declared at the same level of the element.

In the opposite way, to prevent having these elements further in your element and its subelements, you will use -(tag1 | tag2 | tag3).

potame
  • 7,597
  • 4
  • 26
  • 33