home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / htmlval.txt < prev    next >
Text File  |  1997-07-07  |  8KB  |  240 lines

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