Relationship of XML, SGML, and HTML - HTML

XML is a subset of the Standard Generalized Markup Language (SGML). So is HTML. SGML is a markup standard that asks its document creators to develop a set of rules that a processor should follow as it attempts to parse a structured document. In the case of HTML, that set of rules is called a Document Type Definition (DTD).

The first HTML DTD, published by Tim Berners-Lee and Daniel Connolly, contained the most basic HTML elements—things like paragraph and listing elements.In theory, if a Web author deviated from the rules as established by the HTML 1.0 specification, the result should have been a broken document (although browsers were expected to “fail gracefully,” allowing users to at least view the content even if the content’s display was ruined). This is because SGML requires strict adherence to the rules when a DTD is created. In practice, browsers, the software used to parse HTML documents, did not strictly enforce adherence to these rules.

Berners-Lee and Connolly could have created different elements for HTML rather than the ones they chose, as long as they stuck to the guidelines as established by SGML. Among those guidelines are rules that describe how an element should start (with a < character), what it should contain, what attributes it should possess, and how DTDs themselves are written. For example, in the DTD, to indicate that an element has no content, or is empty, you would include the following:

<!ELEMENT IMG - O EMPTY -- Embedded image -->

SGML allows anyone to create a set of markup rules. The trick is getting software developers to write software that will parse a document according to your custommade DTD. You could, for example, write a DTD that instructs a software program to emit a beep every time a link is clicked. Or, that uses a para element instead of a p element to define paragraphs. Or, as in the earlier example, you could define an element named book that describes a book title or refers to an airline reservation.

Note You can view various versions of HTML DTDs at
SGML is very powerful because it lets users create structured documents that are human readable and very portable across environments. For this reason, it was very popular in government circles and with companies with massive documentation needs, such as aircraft manufacturers and military contractors. Although it is still used extensively by these users, XML is replacing SGML in many cases.

With such a good system in place, why would you need XML? SGML is very complex. It isn’t beyond the capabilities of most people, but it is if you don’t have a lot of time, and most of us don’t. So there was no payoff unless the scope of a project using SGML was large. XML was designed to be an SGML Light. It brought the power of SGML into the hands of everyone without requiring a huge investment in time. If you can remember just a few basic rules, you can start writing your XML within a few minutes. And you don’t even need to write a DTD to define the elements you’re creating. It helps, as you’ll see later, but it isn’t a requirement.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

HTML Topics