Question

SGML is the superset of HTML and XML. There are rich HTML and XML parsers available. Could you please explain me the

  1. Usage of SGML (Sample business scneario) in current bussiness domains?

    is it when dealing with legecy systems ?

  2. There are HTML and XML parsers to HTML,xml documents. Why SGML parsers ?

My thinking might be wrong please give me some feedback?

No correct solution

OTHER TIPS

Usage of SGML (Sample business scenario) in current business domains? is it when dealing with legacy systems?

Yes, I think it is mainly for legacy systems, although you can use it for:

1.Weird syntaxes that (ab)use SGML minimization in order to provide less verbose files (when SGML was invented, people used to write SGML files by typing them, hence there are several features in SGML that are oriented to reduce the number of characters that had to be typed)

    {config:
     {attribute name="network":127.0.0.0/8 192.168.123.0/30;}
     {attribute name="action":allow;}
    ;}

Instead of:

<config>
    <attribute name="network">
        127.0.0.0/8 192.168.123.0/30
    </attribute>
    <attribute name="action">
        allow
    </attribute>
</config>

(Of course, this use case has several disadvantages, and I'm not sure if it outweighs its drawbacks, but it is worth mentioning though)

2.Conversion from semi-structured human formats, where part of the text are actually tags. For instance, I had an actual work some years ago that involved converting from this:

From: 
To:

This is the subject 
(there is a blank line before the subject, 
the subject ends with a blank line, 
and everything between parentheses is a comment)

This is the message body

To this

<from>sender</from>
<to>addressee</to>
<subject>This is the subject</subject>
<!-- there is a blank line before the subject, 
the subject ends with a blank line, 
and everything between parentheses is a comment -->
<body>This is the message body</body>

The actual example was far more complex, with many variations and, optional elements, then I found easier to convert it through SGML than writing a parser for it.

There are HTML and XML parsers to HTML,xml documents. Why SGML parsers ?

HTML is a markup language for describing the structure of a webpage (BODY, DIV, TABLE, etC), then it is not suitable for describing more general information such as a configuration file, a list of suppliers, bibliography, etc. (i.e. you can display it in a web page written in HTML, but such information will be hard to extract by automated systems)

XML, on the other hand, is oriented for describing arbitrary data structures, decoupled from layout issues. It is easy to parse an XML document, because XML is based on simple rules (the document must be well-formed). It is because of this rules that you cannot parse an SGML file with an XML parser (unless the SGML file is itself a well formed XML document).

3.Playing with ignore/include marked sections

<!ENTITY % withAnswers "IGNORE">

What is the answer to life the universe and everything?
<![%withAnswers;[ 42 ]]> 

If you want to include the answers in the produced document, just replace the first line with:

<!ENTITY % withAnswers "INCLUDE">

(But you could also use XML and a parameterized XSLT to achieve the same result)

SGML is not just legacy, there are large amount of organisations who continue to use SGML for document publication in the aeronautical industry (think Boeing /Airbus / Embraer), i.e. their most recent revisions of data are published directly in SGML.

Industries that follow data standards, e.g. Air Transportation Association (ATA), are locked in to using the format used by the standards authority, so SGML is still arond in a big way.

At some point in the technical publications chain, this usually gets converted to XML and/or HTML but as an original data source, SGML is around for some tie to come.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top