M
Mark
In XHTML, several elements, such as <div>, may contain what's called
mixed content. Here's the mixed content model for <div>:
<!ELEMENT div (#PCDATA | %Block.class; | %Inline.class*>
%Block.class; includes several block-level (structural) elements, and
%Inline.class includes several inline-level (text) elements.
It can lead to strange results which are valid. For example, the
following is valid XHTML:
<div>
Some text.<p>Some more text.</p> And <i>more</i> text.
</div>
I'd like to constrain the DTD content model so <div> can have one
and only one of the following:
Either 1) (%Block.class)*
Or 2) (#PCDATA | %Inline.class*
(That is, the mixed content example given above will not validate to
the constrained DTD content model I'd like.)
For the desired constraint, does the following content model work?
<!ELEMENT div (((%Block.class)*) | ((#PCDATA | &Inline.class*))>
It seems correct to me, but I often get surprised when I play around
with complex DTD content models (and the above is not that complex --
some of them are absolutely horrid.)
Thanks!
Mark
mixed content. Here's the mixed content model for <div>:
<!ELEMENT div (#PCDATA | %Block.class; | %Inline.class*>
%Block.class; includes several block-level (structural) elements, and
%Inline.class includes several inline-level (text) elements.
It can lead to strange results which are valid. For example, the
following is valid XHTML:
<div>
Some text.<p>Some more text.</p> And <i>more</i> text.
</div>
I'd like to constrain the DTD content model so <div> can have one
and only one of the following:
Either 1) (%Block.class)*
Or 2) (#PCDATA | %Inline.class*
(That is, the mixed content example given above will not validate to
the constrained DTD content model I'd like.)
For the desired constraint, does the following content model work?
<!ELEMENT div (((%Block.class)*) | ((#PCDATA | &Inline.class*))>
It seems correct to me, but I often get surprised when I play around
with complex DTD content models (and the above is not that complex --
some of them are absolutely horrid.)
Thanks!
Mark