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
meansa
orb
a?
means optionallya
a*
means zero or morea
a
means one or morea
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.