Mixed content

Peter Murray-Rust peter at ursus.demon.co.uk
Fri Apr 17 14:40:28 BST 1998


At 11:15 07/04/98 +0200, Leif Jonsson wrote:
>Hello!


Hello Leif - great to hear from you.
>
>My name is Leif Jonsson and I am a computer scientist student from
>Sweden.
>
>I have two basic questions, and I apologize if they are very obvious,

They are not 'obvious' - they get asked frequently and answered frequently :-)

>but I haven't
>found a clear answer to it in any FAQ so I ask in this forum.

Since no-one else has answered, I'll try (I've been away for a few days ...)

>
>1. Why are the restrictions in MIXED CONTENT as they are, that is, no
>order
>    between the elements are allowed and you can not specify the number
>of times
>    they are to appear?

This is a deliberate decision of the XML-WG - in their balance between
simplicity and power. SGML allows much more varied and powerful content models
but they are harder to use. One particular combination of mixed content is
called 'pernicious mixed content' and bites almost all newcomers to SGML.
The designers took care that pernicious mixed content couldn't occur in
XML, and that would prevent millions of new, excited, XML users getting
switched off in the first few days.

Other decisions were that simple-minded hackers (like me) cannot write
validating parsers for some of the really complex content models (that is
why the & connector is disallowed - (A & B) means exactly one A and exactly
one B, but the order doesn't matter).

>
>2. With the question above in mind, I assume there are some theoretical
>motivation
>    to these restrictions, but how are you then supposed to achieve the
>above desired
>    effects without adding "wrapper elements"? Is there a restructuring
>you can do or?

This is part of the trade-off. The only mixed content construct with
#PCDATA is:
(#PCDATA|A|B)*
This means that if you want to restrict the order or the cardinality you
either have to create new elements (wrappers) or require the validation be
outside the DTD - e.g. in the application.  Since some of the validation is
outside the parser anyway (see XLL specification, for example), we think
that we can live with this.
>
>Again I apologize if these are stupid questions, but at least then they
>should have short
>answers. =)

The SGML community welcomes ignorant questions (ignorance is not a crime).
They treated me extremely gently and kindly when I asked these sort of
things 3 years ago.

	P.



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list