<HTML> <HEAD> <TITLE>What are the specific events?</TITLE> </HEAD> <BODY> <P><B>Links</B>: <A HREF=output.html>Next</A> <A HREF=generic.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P> <H1>What are the specific events?</H1> <P>In addition to the <A HREF=generic.html>generic events</A> listed in the previous section, <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> 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.</P> <H3>Table 2: Specific event types</H3> <HR> <DL> <DT><B>Event</B></DT> <DD><TT>'<GI>'</TT></DD> <DT><B>Description</B></DT> <DD>Execute <IT>handler</IT> at the beginning of every element named <TT>'GI'</TT>.</DD> </DL> <HR> <DL> <DT><B>Event</B></DT> <DD><TT>'</GI>'</TT></DD> <DT><B>Description</B></DT> <DD>Execute <IT>handler</IT> at the end of every element named <TT>'GI'</TT>.</DD> </DL> <HR> <DL> <DT><B>Event</B></DT> <DD><TT>'|SDATA|'</TT></DD> <DT><B>Description</B></DT> <DD>Execute <IT>handler</IT> for every special-data string <TT>'SDATA'</TT>.</DD> </DL> <HR> <DL> <DT><B>Event</B></DT> <DD><TT>'&ENTITY;'</TT></DD> <DT><B>Description</B></DT> <DD>Execute <IT>handler</IT> for every external data entity named <TT>'ENTITY'</TT>.</DD> </DL> <HR> <DL> <DT><B>Event</B></DT> <DD><TT>'{ENTITY}'</TT></DD> <DT><B>Description</B></DT> <DD>Execute <IT>handler</IT> at the beginning of every subdocument entity named <TT>'ENTITY'</TT>.</DD> </DL> <HR> <DL> <DT><B>Event</B></DT> <DD><TT>'{/ENTITY}'</TT></DD> <DT><B>Description</B></DT> <DD>Execute <IT>handler</IT> at the end of every subdocument entity named <TT>'ENTITY'</TT>.</DD> </DL> <HR> <P>Note that these override the <A HREF=generic.html>generic-event</A> handlers. For example, if you were to type</P> <P> <PRE>sgml('&FOO;', sub { output "Found a \"foo\" entity!\n"; }); sgml('entity', sub { output "Found an entity!\n"; });</PRE> </P> <P>And the external data entity <TT>&FOO;</TT> appeared in your <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> document, <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> would call the first handler rather than the second.</P> <P>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:</P> <P> <PRE>sgml('</HACK>', '');</PRE> </P> <P><B>Links</B>: <A HREF=output.html>Next</A> <A HREF=generic.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P> <ADDRESS>David Megginson <A HREF="mailto:dmeggins@aix1.uottawa.ca"><dmeggins@aix1.uottawa.ca></A></ADDRESS> </BODY> </HTML>