Tag omission

Tag omission is an optional feature to minimize an SGML document. Whenever a tag can be implicitly anticipated by the parser from the structure of the document, the tag can be omitted.[1] The tag omission feature can be generally enabled or disabled in the SGML Declaration. The Document Type Definition is used to enable or disable the tag for a specific tag.

Tag omission is one of the main features of SGML which was removed from XML to simplify parsing.

Example

In this example the <document> tag has a distinct order of the tags. The information that <title> needs to come first and is followed by <p> can be used to omit the title start and end tag. Furthermore, the end tag of <p> can also be omitted, because it will be delimited by the next <p> tag or the document end.

<!ELEMENT document - O  (title, p+) >
   <!ELEMENT title O O  (#PCDATA)>
   <!ELEMENT p     - O  (#PCDATA)>

In this DTD specification, the behavior of the tag omission feature is specified for each element by the two characters following the element name. The values can be - or O for disabling and enabling the features. The first character specifies the behavior of the start tag and the second the behavior of the end tag.

A valid document not using tag omission:

<document>
   <title>Tag Omission</title>
   <p>first paragraph</p>
   <p>second paragraph</p>
   <p>third paragraph</p>
</document>

A valid document simplified by using tag omission:

<document>
   Tag Omission
   <p>first paragraph
   <p>second paragraph
   <p>third paragraph
gollark: That seems like not determinism as much as some bizarre philosophical thing about truth.
gollark: What?
gollark: <@!221827050892296192> The Wireless Telegraphy Act 2006 is from 2006.
gollark: I probably already have by using my RTL-SDR to look at pager messages. It turns out there are a lot of them here.
gollark: Weirdly, in the UK it's illegal to "[use] wireless telegraphy apparatus with intent to obtain information as to the contents, sender or addressee of a message (whether sent by means of wireless telegraphy or not) of which neither he nor a person on whose behalf he is acting is an intended recipient" because of the "Wireless Telegraphy Act", presumably even if someone is broadcasting stuff completely unencrypted.

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.