Peter --

In your response (below) to a mixed content question, I suspect that you
gave an SGML answer to an XML question.

>> <!ELEMENT elem1 (#PCDATA, elem2)>
is perfectly good SGML (if the document instance doesn't contain illegal
newlines etc.), but is illegal XML. Mixed content in XML is limited to
models in which character data is allowed at any location.

So, in XML, EITHER the rule must be relaxed:
      elem1 contains a mixture of #PCDATA and elem2
      <!ELEMENT elem1 (#PCDATA, elem2)*>

OR that #PCDATA must be wrapped in an element:
      elem1 contains introelem followed by elem2
      <!ELEMENT elem1 (introelem, elem2)*>

Incidentally, I have encountered quite a few situations in which the real
model I wanted to express was "perhaps some characters, e.g. a phrase,
followed by this named element".  Unfortunately translating that directly
into DTD syntax creates an SGML model that can bite you later (the mixed
content problem) and illegal XML.

-- Tommie

>> (2)  Suppose that you want to define in a DTD an element that contains
>> string data (i.e., #PCDATA) followed by a single element.  It is my
>> understanding that the following is INCORRECT:
>> <!ELEMENT elem1 (#PCDATA, elem2)>
>> Is my understanding correct, i.e., that it is incorrect?
>Yes, there's nothing wrong with that, syntactically, except you need
>to be very careful of pernicious mixed content, eg
>   <elem1>foo bar <elem2>blort</elem2>
>   </elem1>
>is invalid because the newline after the end of elem2 is regarded as
>more character data and your content model forbids it.
>> It is my understanding that this is the way to do it:
>> <!ELEMENT elem1 (#PCDATA | elem2)*>
>That allows arbitrary intermixing of character data and ELEM2s,
>as many as you want.
>> Is there a way to specify that you want PCDATA followed by an element?
>You did it, but I'd be interested to know what it's needed for :-)

B. Tommie Usdin                        mailto:[log in to unmask]
Mulberry Technologies, Inc.      
17 West Jefferson Street                           Phone: 301/315-9631
Suite 207                                    Direct Line: 301/315-9634
Rockville, MD  20850                                 Fax: 301/315-8285
  Mulberry Technologies: A Consultancy Specializing in SGML and XML