HOME | COMPANY | SOFTWARE | DOCUMENTATION | EDUCATION & TRAINING | SALES & SERVICE

    "The Official Guide to Programming with OmniMark"

Site Map | Search:   
OmniMark Magazine Developer's Forum   

  International Edition   

OmniMark® Programmer's Guide Version 3

15. Processing SGML Errors

Detailed Table of Contents

Previous chapter is Chapter 14, "SGML Objects".

Next chapter is Chapter 16, "Processing External Entities".

OmniMark reports three kinds of errors:

OmniMark provides additional features to allow the OmniMark programmer to provide customized SGML error reporting. This chapter describes the features that are available to aid the programmer in this task.

15.1 Catching SGML Errors

Syntax

   SGML-ERROR condition?
      LOG?
      local-declaration*
      action*

The SGML-ERROR rule is triggered when an SGML parsing error is found by the SGML parser. The OmniMark program can do a number of things in an SGML-ERROR rule.

If the LOG keyword is specified at the beginning of the rule body, then the conventional error reporting is done in addition to the actions that follow.

If there is more than one SGML-ERROR rule in an OmniMark program, the first SGML-ERROR rule which has no condition, or which has a condition that is TRUE is performed.

If there are no SGML-ERROR rules which can be performed, the conventional error reporting is done.

When the document instance has SGML errors, the programmer can still obtain control in the EPILOG-START rule to determine how to complete the processing. This allows the program to clean up properly while still reporting as many errors as possible before terminating the parsing of the current document.

15.1.1 Retrieving The Parts of the SGML Error Message

The parts of the error message produced by the SGML parser are available in the SGML-ERROR rule in the following built-in local variables:

For example, the following SGML-ERROR rule instructs OmniMark to report an error in the usual fashion and also outputs the fixed and variable parts of the error message, together with the number of the line on which it occurred in a form that can be accessed by other software. If the variable part of the message is not available, it is not written out.

   SGML-ERROR
     LOG
     OUTPUT "\message{%g(#MESSAGE) on line %d(#LINE-NUMBER)"
     OUTPUT "%n%g(#ADDITIONAL-INFO)"
            WHEN #ADDITIONAL-INFO IS ATTACHED
     OUTPUT "}"

Warning (#CLASS = 0) reports are always passed to SGML-ERROR rules, even if the -warnings command-line option has not been used. The OmniMark program can ignore warnings if it wishes by, for example, using the following condition:

   SGML-ERROR UNLESS #CLASS = 0

Specifying LOG in an SGML-ERROR rule has no effect on warning reports unless the command-line option -warning is given. However, the actions in the selected SGML-ERROR rule will still be performed.

15.1.1.1 Predefined Pattern Variables in the SGML-ERROR Rule

Many of the built-in local variables in the SGML-ERROR rule are also provided as pattern variables, for compatibility with past releases. Use of these pattern variables is seriously deprecated.

Unlike programmer-defined pattern variables, these pattern variables must always be heralded with the PATTERN keyword in contexts where heralding would normally be optional.

The pattern variables are CLASS, MESSAGE, ADDITIONAL-INFO, RECOVERY-INFO, FILE-NAME, and LINE-NUMBER.

The "IS SPECIFIED" test will always be true for these built-in pattern variables except for ADDITIONAL-INFO and RECOVERY-INFO, which are not present in all messages.


15.2 Error Counting

OmniMark also provides built-in counters to report the number of SGML errors and warnings encountered. Although it is simple for a programmer to provide an SGML-ERROR rule that does exactly this, it is likely going to be commonly-required information, and it makes sense for OmniMark to provide it in a consistent way.

The counters which perform error-counting are:

The counters #SGML-ERROR-COUNT and #SGML-WARNING-COUNT are "saved" and reset to zero by a "DO SGML-PARSE" action and the previous values are restored by exiting from the "DO SGML-PARSE" action. Note that these counter values for the (sub-)document are not available immediately following the "DO SGML-PARSE" action: if they are to be communicated to the processing of an enclosing document, they have to be captured by the "DO SGML-PARSE" action.

#SGML-ERROR-COUNT, #SGML-WARNING-COUNT, #SGML-ERROR-TOTAL and #SGML-WARNING-TOTAL are "read-only": the OmniMark programmer cannot set or otherwise change their values.

The values of the built-in counters #SGML-WARNING-COUNT and #SGML-WARNING-TOTAL are always incremented for warnings issued by the SGML parser, whether or not those warnings are reported by OmniMark. This is consistent with the fact that warnings are always "seen" by the SGML-ERROR rule, whether or not -warnings is specified on the command line.


15.3 Handling Prolog Errors

OmniMark automatically performs error recovery after SGML errors in the document instance. However, SGML errors in the document prolog cause OmniMark to abandon the parsing of that document. This means that if the error occurs in the document prolog of:

The PROLOG-IN-ERROR rule is provided to allow the programmer to gain control before parsing of the current document is terminated.

Syntax

   PROLOG-IN-ERROR condition?
      local-declaration*
      action*

The PROLOG-IN-ERROR rule is performed either at the end of the SGML Declaration or at the end of the document prolog, if any SGML errors have been encountered to that point. This is essentially immediately prior to the point at which OmniMark normally gives up the current parse.

Each PROLOG-IN-ERROR rule that is in an active group (or in no group -- in the #IMPLIED group), and either has no condition or has a condition that succeeds is performed. (There can be more than one.)

The PROLOG-IN-ERROR rule gives the programmer the following choices:

Like other output processor rules, the PROLOG-IN-ERROR rule can have a condition that determines whether it is performed, and only a PROLOG-IN-ERROR rule in an active group will be selected for being performed. Subject to any condition and the currently active groups, any selectable PROLOG-IN-ERROR rule is performed, and they are performed in the order in which they appear in the OmniMark program.

15.3.1 The Minimum Literal at the Start of the SGML Declaration

Considerable confusion and difficulty has resulted from the Amendment 1 to the SGML standard change of the minimum literal at the start of the SGML Declaration (i.e. "ISO 8879-1986" changed to "ISO 8879:1986"). Some SGML supporting products require one, some the other, and others allow either.

To alleviate the trouble caused by strict adherence to the standard, OmniMark allows both forms of this minimum literal, but reports a warning (rather than an error) when it encounters the "ISO 8879-1986" form. When warnings are suppressed in an OmniMark run, no indication of this error will be given.

It should be kept in mind that anything other than "ISO 8879:1986" is, strictly speaking, an error, even though, for convenience, the older form is only reported as a warning.

Next chapter is Chapter 16, "Processing External Entities".

Copyright © OmniMark Technologies Corporation, 1988-1997. All rights reserved.
EUM27, release 2, 1997/04/11.

Home Copyright Information Website Feedback Site Map Search