Here's somethings off the top of my head; I'm still not sure if
it is 'good' SGML, but SGML seems not to handle dynamic conditions
in a clean way:
1. Marked Sections
-------------------
Clients by default can define the following types of general entities:
HTML.Level0
HTML.Level1
HTML.Level2
HTML.Level3
...
For example, a level 2 comforming client would imply the following
declarations:
<!ENTITY HTML.Level0 'INCLUDE'>
<!ENTITY HTML.Level1 'INCLUDE'>
<!ENTITY HTML.Level2 'INCLUDE'>
Then a document writer can use the following constructs:
<p>Blah blah blah
<![ &HTML.Level2; [
<!-- Whatever level 2 stuff in here -->
]]>
<![ &HTML.Level3; [
<!-- Whatever level 3 stuff in here -->
]]>
To provide alternatives for the same data.
If a client discovers a entity reference as the status-keyword and the
entity is not defined (like HTML.Level3 for level 2 or lower clients)
the replacement value 'IGNORE' is used.
2. Processing instructions
---------------------------
Processing instructions could be used to inform the client on different
levels of HTML being used in a document. For example:
<?level=2>
<!-- Level 2 (and lower) markup here -->
<?level=3>
<!-- Level 3 (and lower) markup here -->
<?level=2>
<!-- Switch back -->
The client can send a warning to the user when higher level
instructions are specified that is not directly supported by the
client. The default level can be implied by the <!doctype declaration,
or if not defined, the highest level supported by the client.
Of course, there are inherent disadvantages to using processing
instructions, and this seems a little ugly to me.
3. New HTML elements
---------------------
Add new elements to HTML like the following:
<!ELEMENT ALTERNATE - - (PART)+ >
<!ELEMENT PART - - ANY -(HTML|HEAD|BODY) >
<!ATTLIST PART
level NUTOKEN #IMPLIED >
As you might guess, it is somthing similiar to a multipart/alternative
MIME message. Example of usage:
<alternate>
<part level=2>
<!-- level 2 markup -->
</part>
<part level=3>
<!-- level 3 markup -->
</part>
</alternate>
Clients will choose the markup that is contained in the highest level
part to render.
4. The CONCUR construct
------------------------
The CONCUR feature of SGML can be used to handle alternate views. I'm
not to knowledgable/experienced on the CONCUR feature of SGML, so I'm
unsure if it can solve the problem. Plus, I think it would be awkward
for authors to use.
My $0.02,
--ewh