home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 August / PCWorld_1999-08_cd.bin / doc / HOWTO / unmaintained / mini / HTML-Validation < prev    next >
Text File  |  1997-10-13  |  8KB  |  245 lines

  1. [ 14 October 1997
  2.   The Linux HTML Validation mini-HOWTO is not being maintained by 
  3.   the author any more.  If you are interested in maintaining the 
  4.   HTML Validation mini-HOWTO, please get in touch with me at 
  5.   <gregh@sunsite.unc.edu>. ]
  6.  
  7.   The HTML Validation HOWTO
  8.   Keith M. Corbett, kmc@specialform.com
  9.   v0.2, 29 October 1995
  10.  
  11.   This document explains how to use the nsgmls parser to validate HTML
  12.   documents for conformance with the HTML 2.0 document type definition,
  13.   or "DTD".  This DTD is the most commonly accepted SGML based defini-
  14.   tion of HTML, and thus defines a subset of current practice in HTML
  15.   markup that is likely to be portable to a wide number of HTML users
  16.   agents (browsers).
  17.   ______________________________________________________________________
  18.  
  19.   Table of Contents:
  20.  
  21.   1.      Introduction
  22.  
  23.   1.1.    Costs and benefits
  24.  
  25.   1.2.    Getting started
  26.  
  27.   2.      Tools
  28.  
  29.   2.1.    The
  30.  
  31.   2.2.    The
  32.  
  33.   2.3.    Download the HTML specification materials
  34.  
  35.   3.      Parsing an HTML document
  36.  
  37.   3.1.    Parser input
  38.  
  39.   3.2.    Parser output
  40.  
  41.   3.3.    Parser messages
  42.  
  43.   3.4.    Return status
  44.  
  45.   4.      Resources
  46.   ______________________________________________________________________
  47.  
  48.   1.  Introduction
  49.  
  50.   This is a guide to using the nsgmls parser to validate and process
  51.   HTML documents.
  52.  
  53.   1.1.  Costs and benefits
  54.  
  55.   Using the full features of SGML markup will enrich your HTML
  56.   documents.  However, validating your documents to the HTML DTD has
  57.   certain cost / benefit tradeoffs, basically because you are dealing
  58.   with a more circumscribed dialect of HTML than is currently in vogue.
  59.   The "official" HTML rules for enforcing document structure, and the
  60.   SGML rules for data content markup, are more restrictive than current
  61.   practice on the Web.
  62.  
  63.   The main issue you must consider is that valid HTML is restricted to a
  64.   standard set of element tags.
  65.  
  66.   There isn't an accepted DTD that accurately reflects "browser HTML" as
  67.   understood by many client browser programs.  For the most part, the
  68.   HTML 2.0 DTD reflects tags and attributes that were commonly in use on
  69.   the Web around June 1994.  Various efforts to define a more advanced
  70.   HTML+ or HTML 3.0 DTD have gotten somewhat bogged down.  And none of
  71.   the DTDs in circulation will recognize all of the tags that have been
  72.   popularized recently by browser vendors such as Netscape and
  73.   Microsoft.
  74.  
  75.   1.2.  Getting started
  76.  
  77.   Contrary to popular opinion, working with SGML does not have to cost a
  78.   lot of time and money.  It is possible to build a robust development
  79.   environment consisting entirely of software that is freely available
  80.   on a wide range of platforms, including Linux, DOS, and most Unix
  81.   workstations.  Thanks to a few very dedicated folks, all the tools you
  82.   need to work with SGML have been made publicly available on the
  83.   Internet.
  84.  
  85.   Setting up your environment (the parser and supporting program
  86.   libraries) takes a bit of work but not nearly as much as one might
  87.   think.
  88.  
  89.   You may also want to peruse an introductory SGML text such as "SGML:
  90.   An Author's Guide to the Standard Generalized Markup Language" by
  91.   Martin bryan, or "Practical SGML" by Eric van Herwijnen.
  92.  
  93.   2.  Tools
  94.  
  95.   2.1.  The HTML Check toolkit package
  96.  
  97.   If you want a completely self-installing / canned package, check out
  98.   the HalSoft HTML Check Toolkit at URL: http://www.halsoft.com/html-
  99.   tk/index.html
  100.  
  101.   The only disadvantage of using the HalSoft kit is that it uses the
  102.   older sgmls parser, which produces error messages that are sometimes
  103.   (even) more cryptic than those from nsgmls.
  104.  
  105.   I've used nsgmls on Linux and Windows (3.x and NT); it is supposed to
  106.   work on many other platforms as well.
  107.  
  108.   2.2.  The nsgmls parser
  109.  
  110.   James Clark has built a software kit called sp which includes the
  111.   validating SGML parser, nsgmls.  (This is the successor to the sgmls
  112.   parser which has long been considered the reference parser.)
  113.  
  114.   For information on the sp kit, see URL: http://www.jclark.com/sp.html
  115.  
  116.   You can download the kit directly from: ftp://ftp.jclark.com/pub/sp/
  117.  
  118.   You may be able to pick up nsgmls executable files for your platform.
  119.   Or, download the source kit and follow the directions in the README
  120.   file for running make.
  121.  
  122.   Consider creating a high level public directory that will contain
  123.   SGML-related files.  For example, on my Linux PC I have various SGML
  124.   related directories including:
  125.  
  126.   /usr/sgml/bin
  127.  
  128.   /usr/sgml/html
  129.  
  130.   /usr/sgml/sgmls
  131.  
  132.   /usr/sgml/sp
  133.  
  134.   2.3.  Download the HTML specification materials
  135.  
  136.   The draft standard for HTML 2.0 includes SGML definition files you
  137.   need to run the parser, namely the DTD (Document Type Definition),
  138.   SGML Declaration, and entity catalog.  To obtain the HTML 2.0 public
  139.   text, see URL:
  140.  
  141.   http://www.w3.org/hypertext/WWW/MarkUp/html-spec/
  142.  
  143.   Download and install the following files:
  144.  
  145.   DTD html*.dtd
  146.  
  147.   SGML declaration html.decl
  148.  
  149.   Entity catalog catalog
  150.  
  151.   You can add two entries to the HTML entity catalog for ease of use
  152.   with nsgmls:
  153.  
  154.        ______________________________________________________________________
  155.                -- catalog: SGML Open style entity catalog for HTML --
  156.                -- $Id: catalog,v 1.2 1994/11/30 23:45:18 connolly Exp $ --
  157.         :
  158.         :
  159.                -- Additions for ease of use with nsgmls --
  160.        SGMLDECL        "html.decl"
  161.        DOCTYPE HTML    "html.dtd"
  162.        ______________________________________________________________________
  163.  
  164.   Alternatively, you can create a second catalog containing these
  165.   entries; you will have to pass this catalog to nsgmls as an argument
  166.   with the -m switch.
  167.  
  168.   3.  Parsing an HTML document
  169.  
  170.   Following is a "cookbook" for validating a single document.  Simply
  171.   invoke the nsgmls parser and pass it the pathnames of the HTML catalog
  172.   file(s) and the document:
  173.  
  174.        % nsgmls -s -m /usr/sgml/html/catalog <test.html
  175.  
  176.   The -s switch suppresses the parser's output; see below.
  177.  
  178.   3.1.  Parser input
  179.  
  180.   Your document must conform to SGML, which means, among other things,
  181.   that the document type must be declared at the beginning of the input.
  182.   (You can fudge this by prepending the information to the document
  183.   instance on the nsgmls command line.)
  184.  
  185.   Here's a simple HTML document that can be parsed correctly using the
  186.   scheme I've outlined:
  187.  
  188.        ______________________________________________________________________
  189.        <!doctype html public "-//IETF//DTD HTML 2.0//EN">
  190.        <html>
  191.        <head>
  192.        <title>Simple HTML document.</title>
  193.        </head>
  194.        <body>
  195.        <h1>Test document</h1>
  196.        <p>This is a test document.</p>
  197.        </body>
  198.        </html>
  199.        ______________________________________________________________________
  200.  
  201.   3.2.  Parser output
  202.  
  203.   The standard output of nsgmls is a digested form of the SGML input
  204.   that processing systems can use as a lexer for navigating the
  205.   structure of the document.  For the purpose of validation, you can
  206.   throw the standard output away and rely on the error output.
  207.  
  208.   If you do want the full output, omit the -s switch and pipe standard
  209.   output to a file:
  210.  
  211.        % nsgmls -m /usr/sgml/html/catalog <test.html >test.out
  212.  
  213.   3.3.  Parser messages
  214.  
  215.   Error and warning messages from nsgmls can be very cryptic.  And you
  216.   may see very many errors from illegal markup.
  217.  
  218.   To pipe messages to a file, use the -f switch:
  219.  
  220.        % nsgmls -s -m /usr/sgml/html/catalog -f test.err <test.html
  221.  
  222.   3.4.  Return status
  223.  
  224.   The parser indicates whether the input document conforms to the HTML
  225.   DTD in two ways:
  226.  
  227.   Return code - the parser returns a 0 exit status on success, non-zero
  228.   otherwise.
  229.  
  230.   Output - if the document conforms to the DTD, the last line of
  231.   standard output will consist of a single C character.
  232.  
  233.   4.  Resources
  234.  
  235.   The HalSoft HTML Check Toolkit is at URL: http://www.halsoft.com/html-
  236.   tk/index.html
  237.  
  238.   James Clark's page on sp is at URL: http://www.jclark.com/sp.html
  239.  
  240.   The W3C page on the HTML specification is at URL:
  241.   http://www.w3.org/hypertext/WWW/MarkUp/html-spec/
  242.  
  243.   Feel free to contact me via email: kmc@specialform.com.
  244.  
  245.