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