Links: Next Previous Up Top

# What are the specific events?

In addition to the generic events listed in the previous section, `sgmlspl` allows special, specific handlers for the beginning and end of elements and subdocument entities, for SDATA strings, and for external data entities. Table 2 lists the different specific event types available.

### Table 2: Specific event types

Event
  `'<GI>'`
Description
  Execute handler at the beginning of every element named `'GI'`.

Event
  `'</GI>'`
Description
  Execute handler at the end of every element named `'GI'`.

Event
  `'|SDATA|'`
Description
  Execute handler for every special-data string `'SDATA'`.

Event
  `'&ENTITY;'`
Description
  Execute handler for every external data entity named `'ENTITY'`.

Event
  `'{ENTITY}'`
Description
  Execute handler at the beginning of every subdocument entity named `'ENTITY'`.

Event
  `'{/ENTITY}'`
Description
  Execute handler at the end of every subdocument entity named `'ENTITY'`.

Note that these override the generic-event handlers. For example, if you were to type

    sgml('&FOO;', sub {
        output "Found a \"foo\" entity!\n";
    });

    sgml('entity', sub {
        output "Found an entity!\n";
    });

And the external data entity `&FOO;` appeared in your SGML document, `sgmlspl` would call the first handler rather than the second.

Note also that start and end handlers are entirely separate things: if an element has a specific start handler but no specific end handler, the generic end handler will still be called at the end of the element. To prevent this, declare a handler with an empty string:

    sgml('</HACK>', '');

Links: Next Previous Up Top