Next Up Previous Contents
Next: 3.6 Try it yourself - running the SGML parser
Up: 3.5 Marked sections
Previous: 3.5.1 CDATA marked sections
[ID index][Keyword index]

3.5.2 Paper-only and web-only variants

Text within INCLUDE and IGNORE marked sections is parsed or skipped by the parser, as appropriate. They are not often used outside of DTDs, but the IGNORE marked section is occasionally useful as a way of `commenting out' large sections of text which might itself include SGML comments <!-- ... -->.

Sometimes, it is necessary to have parts of your document which vary depending on whether the document is to be viewed on paper or online. In general, the best way to manage this is using the span element (see Section 4.11), but this is limited to use within paragraphs. If you need to conditionally include higher-level chunks of material, you will have to resort to the blunter instrument of a marked section. We may add a suitable element to the DTD in future - probably called div - and deprecate this method.

The Starlink general DTD defines two parameter entities %Only.paper and %Only.web, which you can use to include or ignore text in a marked section. By default, both of these are set to the string `IGNORE', but when you use the sgml2docs script (see Section 6.2), one or the other of these will be set to `INCLUDE', as appropriate for the type of file being generated.

You would use this facility as follows:

<p>Here is some text.
<![ %Only.web [ And here is some which would appear
only in webpages. ]]>

It is, I hope, clear that you could get yourself in a terrible mess here, and create a document which is only valid for some settings of the entities. Please use this feature with restraint: take care that your document remains valid for all settings, including the case where both entities are set to `IGNORE'.


Next Up Previous Contents
Next: 3.6 Try it yourself - running the SGML parser
Up: 3.5 Marked sections
Previous: 3.5.1 CDATA marked sections
[ID index][Keyword index]
The Starlink SGML Set
Starlink System Note 70
Norman Gray, Mark Taylor
21 April 1999. Release DR-0.7-13. Last updated 24 August 2001