## 5 Running an external SGML parser ¶

PSGML can not validate an SGML document (see below what it can and can’t do). If you have a validating SGML parser, like `sgmls`, you can run the parser on your file with the command `C-c C-v` (`sgml-validate`).

Some variables control this function:

User Option: sgml-validate-command ¶

  The shell command to validate an SGML document.

  This is a `format` control string that by default should contain two `%s` conversion specifications: the first will be replaced by the value of `sgml-declaration` (or the empty string, if nil); the second will be replaced by the current buffer’s file name (or the empty string, if nil).

  If `sgml-validate-files` is non-nil, the format string should contain one `%s` conversion specification for each element of its result.

  If sgml-validate-command is a list, then every element should be a string. The strings will be tried in order and ‘`%`’-sequences in the string will be replaced according to the list below, if the string contains ‘`%`’-sequences with no replacement value the next string will be tried.

  `%b`

    means the visited file of the current buffer

  `%s`

    means the SGML declaration specified in the sgml-declaration variable

  `%d`

    means the file containing the DOCTYPE declaration, if not in the buffer

  The default value is `nsgmls -s %s %s`.

User Option: sgml-validate-files ¶

  If non-nil, a function of no arguments that returns a list of file names. These file names will serve as the arguments to the `sgml-validate-command` format control string instead of the defaults.

User Option: sgml-declaration ¶

  The name of the SGML declaration file.

User Option: sgml-offer-save ¶

  If non-nil, `C-c C-v` (`sgml-validate`) will ask about saving modified buffers before running the validate command. The default value is `t`.

The built-in parser can find some markup errors. The command `C-c C-o` (`sgml-next-trouble-spot`) is the best way to use the built-in parser for this. To check the whole file go to the beginning of the buffer and use `C-c C-o`.

Some of the markup errors not found are:

- Errors in the SGML declaration.
- Errors in attribute specifications.
- Omitted start-tags for empty elements.