Home > Enterprise >  What do '|', '?', ' ', '*', and ',' mean in a DTD
What do '|', '?', ' ', '*', and ',' mean in a DTD

Time:11-01

I found a lot of these kind of codes in DTD files (each line from a separated DTD file) :

<!ELEMENT master (big | small)*>
<!ELEMENT master (big* | small*)>
<!ELEMENT master (big , small*)>
<!ELEMENT master (big, small)*>
<!ELEMENT master (big, small )*>
<!ELEMENT master (big | small )*>
<!ELEMENT master (big | small )>
<!ELEMENT master (big? | small )>`

I understand the basics like <!Element Master and what big and small means, but what I don't get is what | ? * , etc means. Also what does it mean when it's between () ?

NOTE : each line is taken from a separated DTD file. (I copied each line from 9 DTD files.) What does each line mean?

CodePudding user response:

Most of those operators have their usual meaning in computer science as used, for example, in regular expressions, EBNF, etc:

  • a | b means a or b
  • a? means optionally a
  • a* means zero or more a
  • a means one or more a

a, b means a sequence of a followed by b.

CodePudding user response:

To take one example

<!ELEMENT master (big, small )*>

means that a valid master element has a content that consists of a sequence of zero or more groups, where each group contains one element named big followed by one or more elements called small.

Google for "XML DTD tutorial" and you will find plenty of more detailed explanations.

  • Related