Previous Table of Contents Next


SGMLS

SGMLS is the most commonly used public domain SGML validator available. It exists for almost every platform and was the first free parser to run on the Mac. The best place to get copies of SGMLS is the SGML FTP archives. The best place to learn more about updates and upgrades is the SGML newsgroups. There are other public domain parsers—some of which are newer and better than SGMLS—but none has been ported to the Mac.

SGMLS is a stand-alone program. It reads a text file, a DTD, and (if necessary) an SGML declaration, and then it parses the document. To report the SGML errors that it finds, it uses error messages based directly on the ISO 8879 standard. Several versions of SGMLS for the Mac are available at the FTP sites. The earlier version, compiled using Think C, was slower and had a more difficult interface. The new version, described here, is compiled with Metrowerks and is available for PowerPC and 68K Macintoshes. It has added interface features that make it easier to use.


Note:  
SGMLS is a program written for a command line interface, and it does not shake that paradigm, even though on the Mac it has dialog boxes and buttons. You actually have to type in information that on a Mac you would usually select with menus and dialog boxes.

Running SGMLS. The interface to SGMLS is an unadorned dialog box divided into three parts (see fig. 27.6). The top section contains a box where you type the name of the file that you want to validate and any switches that you want SGMLS to use. The lower-left section of the dialog box indicates input options, and the lower-right section indicates output options.


Fig. 27.6  SGMLS has a simple interface that mimics a command line.

To validate a file using SGML:

1.  Double-click the application.
2.  Enter the name of your file in the dialog box. If you need to use a modified SGML declaration, enter the name of the SGML declaration before the file name. For example:
mysgml.decl alice.sgml


• See “DTDs and Declarations for Elements, Attributes, and Entities,” p. 62
3.  Don’t change the radio buttons at the lower left, which indicate input. You want input to occur from the console.
4.  Select the File radio button at the lower right if you want your error output to go to a file. This is generally easier if you expect to have many errors or if you are validating a long file. If you select the Console radio button, error messages appear on the scrollable Console window.
5.  Choose OK to validate the file.
6.  Correct the errors in your SGML file, and repeat steps 1 through 5.

Common Problems with SGMLS. SGMLS has little documentation beyond a lengthy UNIX man page. It contains a large amount of technical information, most of which you do not need. However, you can obtain the names of the basic switches and parameters from it, if you need them. All implementations of SGMLS work the same, so the documentation applies to all platforms.

Command Line Switches. SGMLS assumes that you are using SGML’s standard defaults unless you specify otherwise. These defaults impose constraints that you might not like. Element names are restricted to eight characters, and literal values are restricted to 240 characters. If you want to change these values, you must edit the SGML declaration and then tell your SGML software which file contains the declaration. You can use a custom declaration by providing the name of the declaration file before the name of the SGML document.


• See “Attributes: Their Use and the ATTRIBUTE Declaration,” p. 182

You can use other switches with SGMLS. For example, you can specify how you want error messages to be printed, which kinds of errors you want to know about, and how SGMLS should resolve Generic Public Identifiers.

Finding the Document’s DTD and Other Referenced Files. Your document might give you an error message that sounds as though it does not recognize any elements or attributes. For example:

     Error at file.sgm, line 11 accessing "file.dtd":
     SGML error at file.sgm, line 12 at record start:
     No definition for HELLO document type; "HELLO O O ANY" assumed


Previous Table of Contents Next