XML vs SGML
XML stands for EXtensible Markup Language. It is defined in the XML 1.0 specification, which is developed by the W3C (World Wide Web Consortium). XML provides a standard way, which is also simple, to encode data and text such that the content could be exchanged across driver hardware, operating systems and applications with little human intervention. SGML (Standard Generalized Markup Language) is an ISO (International Organization for Standardization) standard for specifying a document markup language or a set of tags. SGML is not a document language but a Document Type Definition (DTD).
XML is a markup language that is used to transfer data and text between driver hardware, operating systems and applications with little human intervention. XML provides tags, attributes and element structures that can be used to provide context information. This context information can be used to decode the meaning of the content. This makes it possible to develop efficient search engines and perform data mining on the data. Furthermore, traditional relational databases are suitable as XML data because they could be organized in rows and columns but XML provides less support for data with rich content such as audio, video, complex documents, etc. XML databases store data in a structured, hierarchical form which allows queries to be processed more efficiently. XML tags are not predefined and the users can define new tags and document structures. Also, new internet languages such as RSS, Atom, SOAP, and XHTM were created using XML.
SGML is based on the idea that even though a document can be displayed with different appearances depending on the output medium used, it contains some structural and semantic elements that do not change with reference to how it is displayed. SGML based documents can be created without concerning about the document’s appearance which can change overtime, but concerning about the document structure. Further, SGML compiler can interpret any document using its DTD, therefore these documents provide more portability. Also, documents based on SGML could be easily re-adapted to different media (for example, document intended for print medium could be readapted for a display screen).
What is the difference between XML and SGML?
While XML is a markup language that is used to transfer data and text between driver hardware, operating systems and applications, SGML is an ISO standard for specifying a document markup language or a set of tags. XML is actually a markup language that is based on SGML. But XML imposes some restrictions that are not in SGML. For example, XML imposes following restrictions: entity references must be closed with a REFC delimiter, references to external data entities in content are not allowed, character references must be closed with a REFC delimiter, named character references are not allowed, etc. Furthermore, some constructs such as unclosed start-tags, unclosed end-tags, empty start-tags, empty end-tags that are permitted in SGML when SHORTTAG is YES, are not allowed in XML. Additionally, some SGML declarations such as DATATAG, OMITTAG, RANK, LINK (SIMPLE, IMPLICIT and EXPLICIT), etc. are not allowed in XML.