At 02:06 PM 06/18/2001 +0200, Navratil Zdenek wrote:
>But how should I define a structure like this:?
> <e1>element 1</e1>
> <e2>element 2</e2>
>A simple minded DTD:
><!ELEMENT es ((#PCDATA),e1,e2)>
><!ELEMENT e1 (#PCDATA)>
><!ELEMENT e2 (#PCDATA)>
>doesn't work, at least my XML Notepad refused to validate that.
Right. The content model which your document structure (not your DTD)
represents is called "mixed content" -- that is, a mixture of #PCDATA and
other element types.
In XML, the only valid way to represent mixed content in a DTD is:
<!ELEMENT elemname (#PCDATA | [pipe-separated list of element types])*>
That is, the #PCDATA has to come first, and the content model as a whole
must be appended with the "*" operator. In your case (as I think someone
else said) this would be:
<!ELEMENT es (#PCDATA | e1 | e2)*>
Note that the translation of this content model would be something like,
"any combination of any number of #PCDATA blocks, e1 elements, and e2
elements." This isn't very close to your desired structure of "#PCDATA,
followed by one e1, followed by one e2"; unfortunately, it's the only way
of representing these mixed content models with XML DTDs... unless you:
>...solve the problem by adding another element (tag) e.g.:
><!ELEMENT es (e0?,e1,e2)>
><!ELEMENT e0 (#PCDATA)>
I realize you don't *want* to do that. But other than using the mixed
content model, it's your only choice.
John E. Simpson | "I just got out of the hospital. I was in a
http://www.flixml.org | speed reading accident. I hit a bookmark and
XML Q&A: www.xml.com | flew across the room." (Steven Wright)