The Standard Generalized Markup Language (SGML;
ISO
ISO is the most common abbreviation for the International Organization for Standardization.
ISO or Iso may also refer to: Business and finance
* Iso (supermarket), a chain of Danish supermarkets incorporated into the SuperBest chain in 2007
* Iso ...
8879:1986) is a standard for defining generalized
markup language
Markup language refers to a text-encoding system consisting of a set of symbols inserted in a text document to control its structure, formatting, or the relationship between its parts. Markup is often used to control the display of the document ...
s for documents. ISO 8879 Annex A.1 states that generalized markup is "based on two
postulate
An axiom, postulate, or assumption is a statement that is taken to be true, to serve as a premise or starting point for further reasoning and arguments. The word comes from the Ancient Greek word (), meaning 'that which is thought worthy or f ...
s":
* Declarative: Markup should describe a document's structure and other attributes rather than specify the processing that needs to be performed, because it is less likely to conflict with future developments.
* Rigorous: In order to allow markup to take advantage of the techniques available for processing, markup should rigorously define objects like programs and
database
In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases sp ...
s.
DocBook
DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hardware and software, but it can be used for any other sort of documentation.
As a semantic languag ...
SGML and
LinuxDoc are examples which used SGML tools.
Standard versions
SGML is an
ISO
ISO is the most common abbreviation for the International Organization for Standardization.
ISO or Iso may also refer to: Business and finance
* Iso (supermarket), a chain of Danish supermarkets incorporated into the SuperBest chain in 2007
* Iso ...
standard: "ISO 8879:1986 Information processing – Text and office systems – Standard Generalized Markup Language (SGML)", of which there are three versions:
* Original ''SGML'', which was accepted in October 1986, followed by a minor Technical Corrigendum.
* ''SGML (ENR)'', in 1996, resulted from a Technical Corrigendum to add ''extended naming rules'' allowing arbitrary-language and -script markup.
* ''SGML (ENR+WWW or WebSGML)'', in 1998, resulted from
Technical Corrigendumto better support XML and WWW requirements.
SGML is part of a trio of enabling ISO standards for
electronic document
An electronic document is any electronic media content (other than computer programs or system files) that is intended to be used in either an electronic form or as printed output. Originally, any computer data were considered as something inter ...
s developed by
ISO/IEC JTC 1/SC 34
ISO/IEC JTC 1/SC 34, Document description and processing languages is a subcommittee of the ISO/IEC JTC 1 joint technical committee, which is a collaborative effort of both the International Organization for Standardization and the International ...
(ISO/IEC Joint Technical Committee 1, Subcommittee 34 – Document description and processing languages) :
* SGML (ISO 8879) – Generalized markup language
** SGML was reworked in 1998 into
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
, a successful
profile
Profile or profiles may refer to:
Art, entertainment and media Music
* ''Profile'' (Jan Akkerman album), 1973
* ''Profile'' (Githead album), 2005
* ''Profile'' (Pat Donohue album), 2005
* ''Profile'' (Duke Pearson album), 1959
* '' ''Profi ...
of SGML. Full SGML is rarely found or used in new projects.
*
DSSSL
The Document Style Semantics and Specification Language (DSSSL) is an international standard developed to provide stylesheets for SGML documents.
DSSSL consists of two parts: a tree transformation process that can be used to manipulate the tree ...
(ISO/IEC 10179) – Document processing and styling language based on
Scheme A scheme is a systematic plan for the implementation of a certain idea.
Scheme or schemer may refer to:
Arts and entertainment
* ''The Scheme'' (TV series), a BBC Scotland documentary series
* The Scheme (band), an English pop band
* ''The Schem ...
.
** DSSSL was reworked into
W3C
The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working to ...
XSLT
XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subseque ...
and
XSL-FO
XSL-FO (XSL Formatting Objects) is a markup language for XML document formatting that is most often used to generate PDF files. XSL-FO is part of XSL (Extensible Stylesheet Language), a set of W3C technologies designed for the transformation and ...
which use an XML syntax. Nowadays, DSSSL is rarely used in new projects apart from
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
documentation.
*
HyTime
HyTime (''Hypermedia/Time-based Structuring Language'') is a markup language that is an application of SGML. HyTime defines a set of hypertext-oriented element types that, in effect, supplement SGML and allow SGML document authors to build hyperte ...
– Generalized
hypertext
Hypertext is E-text, text displayed on a computer display or other electronic devices with references (hyperlinks) to other text that the reader can immediately access. Hypertext documents are interconnected by hyperlinks, which are typi ...
and scheduling.
** HyTime was partially reworked into
W3C
The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working to ...
XLink
XML Linking Language, or XLink, is an XML markup language and W3C specification that provides methods for creating internal and external links within XML documents, and associating metadata with those links.
The XLink specification
XLink 1.1 is ...
. HyTime is rarely used in new projects.
SGML is supported by various technical reports, in particular
* ISO/IEC TR 9573 – Information processing – SGML support facilities – Techniques for using SGML
** Part 13: Public entity sets for mathematics and science
*** In 2007, the W3C MathML working group agreed to assume the maintenance of these entity sets.
History
SGML descended from
IBM's
Generalized Markup Language
Generalized Markup Language (GML) is a set of macros that implement intent-based (procedural) markup tags for the IBM text formatter, SCRIPT. SCRIPT/VS is the main component of IBM's Document Composition Facility (DCF). A ''starter set'' of ...
(GML), which
Charles Goldfarb
Charles F. Goldfarb is known as the father of Standard Generalized Markup Language (SGML) and grandfather of HTML and the World Wide Web. He co-invented the concept of markup languages.
In 1969 Charles Goldfarb, leading a small team at IBM, de ...
, Edward Mosher, and Raymond Lorie developed in the 1960s. Goldfarb, editor of the international standard, coined the "GML" term using their surname initials.
Goldfarb also wrote the definitive work on SGML syntax in "The SGML Handbook".
The syntax of SGML is closer to the
COCOA
Cocoa may refer to:
Chocolate
* Chocolate
* ''Theobroma cacao'', the cocoa tree
* Cocoa bean, seed of ''Theobroma cacao''
* Chocolate liquor, or cocoa liquor, pure, liquid chocolate extracted from the cocoa bean, including both cocoa butter and ...
format. As a document markup language, SGML was originally designed to enable the sharing of
machine-readable large-project documents in government, law, and industry. Many such documents must remain readable for several decades—a long time in the
information technology
Information technology (IT) is the use of computers to create, process, store, retrieve, and exchange all kinds of data . and information. IT forms part of information and communications technology (ICT). An information technology system (I ...
field. SGML also was extensively applied by the military, and the aerospace, technical reference, and industrial publishing industries. The advent of the
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
profile has made SGML suitable for widespread application for small-scale, general-purpose use.
Document validity
SGML (ENR+WWW) defines two kinds of validity. According to the revised Terms and Definitions of ISO 8879 (from the public draft
):
A conforming SGML document must be either a type-valid SGML document, a tag-valid SGML document, or both. Note: A user may wish to enforce additional constraints on a document, such as whether a document instance is integrally-stored or free of entity references.
A type-valid SGML document is defined by the standard as
An SGML document in which, for each document instance, there is an associated document type declaration #REDIRECT Document type declaration
{{redirect category shell, {{R move{{R from other capitalisation{{R up ...
(DTD) to whose DTD that instance conforms.
A tag-valid SGML document is defined by the standard as
An SGML document, all of whose document instances are fully tagged. There need not be a document type declaration #REDIRECT Document type declaration
{{redirect category shell, {{R move{{R from other capitalisation{{R up ...
associated with any of the instances. Note: If there is a document type declaration #REDIRECT Document type declaration
{{redirect category shell, {{R move{{R from other capitalisation{{R up ...
, the instance can be parsed with or without reference to it.
Terminology
''Tag-validity'' was introduced in SGML (ENR+WWW) to support
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
which allows documents with no DOCTYPE declaration but which can be parsed without a grammar, or documents which have a DOCTYPE declaration that makes no
XML Infoset
XML Information Set (XML Infoset) is a W3C specification describing an abstract data model of an XML document in terms of a set of ''information items''. The definitions in the XML Information Set specification are meant to be used in ''other'' sp ...
contributions to the document. The standard calls this ''fully tagged''. ''Integrally stored'' reflects the
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
requirement that elements end in the same entity in which they started. ''Reference-free'' reflects the
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
requirement that entity references are for special characters and do not contain markup. SGML validity commentary, especially commentary that was made before 1997 or that is unaware of SGML (ENR+WWW), covers ''type-validity'' only.
The SGML emphasis on validity supports the requirement for generalized markup that ''markup should be rigorous.'' (ISO 8879 A.1)
Syntax
An SGML document may have three parts:
# the SGML Declaration,
# the Prologue, containing a DOCTYPE declaration with the various ''markup declarations'' that together make a
Document Type Definition
A document type definition (DTD) is a set of ''markup declarations'' that define a ''document type'' for an SGML-family markup language ( GML, SGML, XML, HTML).
A DTD defines the valid building blocks of an XML document. It defines the document ...
(DTD), and
# the instance itself, containing one top-most element and its contents.
An SGML document may be composed from many
entities
An entity is something that exists as itself, as a subject or as an object, actually or potentially, concretely or abstractly, physically or not. It need not be of material existence. In particular, abstractions and legal fictions are usually ...
(discrete pieces of text). In SGML, the entities and element types used in the document may be specified with a DTD, the different character sets, features, delimiter sets, and keywords are specified in the SGML Declaration to create the ''concrete syntax'' of the document.
Although full SGML allows implicit markup and some other kinds of tags, the
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
specification (s4.3.1) states:
For introductory information on a basic, modern SGML syntax, see
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
. The following material concentrates on features not in XML and is not a comprehensive summary of SGML syntax.
Optional features
SGML generalizes and supports a wide range of markup languages as found in the mid 1980s. These ranged from terse
Wiki
A wiki ( ) is an online hypertext publication collaboratively edited and managed by its own audience, using a web browser. A typical wiki contains multiple pages for the subjects or scope of the project, and could be either open to the pu ...
-like syntaxes to
RTF-like bracketed languages to
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
-like matching-tag languages. SGML did this by a relatively simple default ''reference concrete syntax'' augmented with a large number of optional features that could be enabled in the SGML Declaration. Not every SGML parser can necessarily process every SGML document. Because each processor's ''System Declaration'' can be compared to the document's ''SGML Declaration'' it is always possible to know whether a document is supported by a particular processor.
Many SGML features relate to markup minimization. Other features relate to
concurrent (parallel) markup (CONCUR), to linking processing attributes (LINK), and to embedding SGML documents within SGML documents (SUBDOC).
The notion of customizable features was not appropriate for Web use, so one goal of
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
was to minimize optional features. However, XML's well-formedness rules cannot support Wiki-like languages, leaving them unstandardized and difficult to integrate with non-text information systems.
Concrete and abstract syntaxes
The usual (default) SGML ''concrete syntax'' resembles this example, which is the default
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
concrete syntax:
typically something like this
SGML provides an ''abstract syntax'' that can be
implemented in many different types of ''concrete syntax''. Although the markup norm is using
angle brackets
A bracket is either of two tall fore- or back-facing punctuation marks commonly used to isolate a segment of text or data from its surroundings. Typically deployed in symmetric pairs, an individual bracket may be identified as a 'left' or 'r ...
as start- and end- tag
delimiters in an SGML document (per the standard-defined ''reference concrete syntax''), it is possible to use other characters—provided a suitable ''concrete syntax'' is defined in the document's
SGML declaration.
For example, an SGML interpreter might be programmed to parse GML, wherein the tags are delimited with a left
colon and a right
full stop
The full stop (Commonwealth English), period (North American English), or full point , is a punctuation mark. It is used for several purposes, most often to mark the end of a declarative sentence (as distinguished from a question or exclamation ...
, thus, an '':e'' prefix denotes an end tag:
:xmp.Hello, world:exmp.
. According to the reference syntax, letter-case (upper- or lower-) is not distinguished in tag names, thus the three tags: (i)
<quote>
, (ii)
<QUOTE>
, and (iii)
<quOtE>
are equivalent. (''NOTE:'' A concrete syntax might ''change'' this rule via the NAMECASE NAMING declarations).
Markup minimization
SGML has features for reducing the number of characters required to mark up a document, which must be enabled in the SGML Declaration. SGML processors need not support every available feature, thus allowing applications to tolerate many types of inadvertent markup omissions; however, SGML systems usually are intolerant of invalid structures. XML is intolerant of syntax omissions, and does not require a DTD for checking well-formedness.
OMITTAG
Both start tags and end tags may be omitted from a document instance, provided:
# the OMITTAG feature is enabled in the SGML Declaration,
# the DTD indicates that the tags are permitted to be omitted,
# (for start tags) the element has no associated required (
#REQUIRED
) attributes, and
# the tag can be unambiguously inferred by context.
For example, if OMITTAG YES is specified in the SGML Declaration (enabling the OMITTAG feature), and the DTD includes the following declarations:
then this excerpt:
Introduction to SGML
which omits two tags and two tags, would represent valid markup.
Omitting tags is optional – the same excerpt could be tagged like this:
Introduction to SGML
and would still represent valid markup.
Note: The OMITTAG feature is unrelated to the tagging of elements whose declared content is
EMPTY
as defined in the DTD:
Elements defined like this have no end tag, and specifying one in the document instance would result in invalid markup. This is syntactically different from
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
empty elements in this regard.
SHORTREF
Tags can be replaced with delimiter strings, for a terser markup, via the SHORTREF feature. This markup style is now associated with
wiki markup
A wiki ( ) is an online hypertext publication collaboratively edited and managed by its own audience, using a web browser. A typical wiki contains multiple pages for the subjects or scope of the project, and could be either open to the pu ...
, e.g. wherein two equals-signs (), at the start of a line, are the "heading start-tag", and two equals signs () after that are the "heading end-tag".
SHORTTAG
SGML markup languages whose concrete syntax enables the SHORTTAG VALUE feature, do not require attribute values containing only alphanumeric characters to be enclosed within quotation marks—either double
" "
(LIT) or single
' '
(LITA)—so that the previous markup example could be written:
typically something like this>
One feature of SGML markup languages is the "presumptuous empty tagging", such that the empty end tag
</>
in
<ITALICS>this</>
"inherits" its value from the nearest previous full start tag, which, in this example, is
<ITALICS>
(in other words, it closes the most recently opened item). The expression is thus equivalent to
<ITALICS>this</ITALICS>
.
NET
Another feature is the ''NET'' (Null End Tag) construction:
<ITALICS/this/
, which is structurally equivalent to
<ITALICS>this</ITALICS>
.
Other features
Additionally, the SHORTTAG NETENABL IMMEDNET feature allows shortening tags surrounding an empty text value, but forbids shortening full tags:
can be written as
slash
Slash may refer to:
* Slash (punctuation), the "/" character
Arts and entertainment Fictional characters
* Slash (Marvel Comics)
* Slash (''Teenage Mutant Ninja Turtles'')
Music
* Harry Slash & The Slashtones, an American rock band
* Nash ...
( / ) stands for the NET-enabling "start-tag close" (NESTC), and the second slash stands for the NET. NOTE: XML defines NESTC with a /, and NET with an > (angled bracket)—hence the corresponding construct in XML appears as
.
The third feature is 'text on the same line', allowing a markup item to be ended with a line-end; especially useful for headings and such, requiring using either SHORTREF or DATATAG minimization. For example, if the DTD includes the following declarations:
(and "&#RE;&#RS;" is a short-reference delimiter in the concrete syntax), then:
SGML has many features that defied convenient description with the popular formal
technology of the 1980s and the 1990s. The standard warns in Annex H:
A report on an early implementation of a parser for basic SGML, the Amsterdam SGML Parser,
notes and specifies various differences.
There appears to be no definitive classification of full SGML against a known class of
. Plausible classes may include
, validator) for valid XML.
The SGML productions in the ISO standard are reported to be LL(3) or LL(4).
.
level rather than a character or delimiter level:
The SGML standard does not define SGML with formal data structures, such as
", which is parsed into a RDAG of structural units known as "elements". The physical graph is loosely characterized as an ''entity tree'', but entities might appear multiple times. Moreover, the structure graph is also loosely characterized as an ''element tree'', but the ID/IDREF markup allows arbitrary arcs.
The results of parsing can also be understood as a data tree in different notations; where the document is the root node, and entities in other notations (text, graphics) are child nodes. SGML provides apparatus for linking to and annotating external non-SGML entities.
The SGML standard describes it in terms of ''maps'' and ''recognition modes'' (s9.6.1). Each entity, and each element, can have an associated ''notation'' or ''declared content type'', which determines the kinds of references and tags which will be recognized in that entity and element. Also, each element can have an associated ''delimiter map'' (and ''short reference map''), which determines which characters are treated as delimiters in context. The SGML standard characterizes parsing as a
switching between recognition modes. During parsing, there is a stack of maps that configure the
relates to the recognition modes.
Parsing involves traversing the dynamically-retrieved entity graph, finding/implying tags and the element structure, and validating those tags against the grammar. An unusual aspect of SGML is that the grammar (DTD) is used both passively — to ''recognize'' lexical structures, and actively — to ''generate'' missing structures and tags that the DTD has declared optional. End- and start- tags can be omitted, because they can be inferred. Loosely, a series of tags can be omitted only if there is a single, possible path in the grammar to imply them. It was this active use of grammars that made concrete SGML parsing difficult to formally characterize.
SGML uses the term ''validation'' for both recognition and generation. XML does not use the grammar (DTD) to change delimiter maps or to inform the parse modes, and does not allow
; consequently, XML validation of elements is not active in the sense that SGML validation is active. SGML ''without'' a DTD (e.g. simple XML), is a grammar or a language; SGML ''with'' a DTD is a
. SGML with an SGML declaration is, perhaps, a meta-metalanguage, since it is a metalanguage whose declaration mechanism ''is'' a metalanguage.
SGML has an abstract syntax implemented by many possible concrete syntaxes; however, this is not the same usage as in an
. In the SGML usage, a concrete syntax is a set of specific delimiters, while the abstract syntax is the set of names for the delimiters. The
corresponds more to the programming language notion of abstract syntax introduced by
.
XML (Extensible Markup Language) is a profile (subset) of SGML designed to ease the implementation of the parser compared to a full SGML parser, primarily for use on the World Wide Web. In addition to disabling many SGML options present in the reference syntax (such as omitting tags and nested subdocuments) XML adds a number of additional restrictions on the kinds of SGML syntax. For example, despite enabling SGML shortened tag forms, XML does not allow unclosed start or end tags. It also relied on many of the additions made by the WebSGML Annex. XML currently is more widely used than full SGML. XML has lightweight
. Applications of XML include