Reputation: 87
<Random attri="abc" ,attri2="xyz"/>
<something>
This is random text
<nothing attri="mnop" />
.
</something>
Now how to write DTD for elements like "something" which have some text and another element. Also how to declare to attribute "attri" in "nothing" as we have already declared another attribute of the same name in "Random"?
Upvotes: 2
Views: 390
Reputation: 52888
Elements that contain both text and other elements are said to have mixed content.
There's only one way to declare an element to have mixed content; they (#PCDATA and any elements) must all occur zero or more times (*
) and be in any order (|
).
So your declaration for something
would need to look like this:
<!ELEMENT something (#PCDATA|nothing)*>
As far as declaring an attribute with the same name (attri
), since ATTLIST declarations are specific to a single element, you have to declare it separately for each element. So in your example you'd need to declare it for both Random
and nothing
. See here for more details.
Upvotes: 1