home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / DOC / HOWTO / OTHER_FO / SGML / MINI / HTML_VAL.GZ / HTML-Validation.sgml
Encoding:
SGML Document  |  1995-11-22  |  7.7 KB  |  273 lines

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