I am trying to accomplish the following element declaration:
The XML element may consist of a text or/and an element, BUT it must consist at least one of them.
If I do:
<!ELEMENT myelem (#PCDATA|myanotherelem)*>
it means that myelem may still be empty. I thought of using
(#PCDATA|myanotherelem)+
but the mixed content model should be zero based. How do I deal with it?
The only legal forms for content models in XML DTDs are
(#PCDATA)and(#PCDATA | a | b | ... | z)*for some number elements (zero or more) a, b, … z.Note that an element of the form
<myelem></myelem>is in fact regarded by the XML spec as having #PCDATA content — it’s not at all irrational of you to want to specify non-zero-length #PCDATA content, but that’s not in fact what the keyword#PCDATAmeans. The constraint you want to impose (a minimum length for #PCDATA content — probably also you want to require that it not consist solely of whitespace characters, either) cannot be expressed in DTD notation. That’s one of the things that other schema languages (e.g. XSD and Relax NG) add by means of datatypes.