<HTML> <HEAD> <TITLE>How does the specification file tell sgmlspl what to do?</TITLE> </HEAD> <BODY> <P><B>Links</B>: <A HREF=handlers.html>Next</A> <A HREF=dsssl.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P> <H1>How does the specification file tell <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> what to do?</H1> <P><A HREF=sgmlspl.html><TT>sgmlspl</TT></A> uses an <I>event model</I> rather than a <I>procedural model</I> -- instead of saying "do A then B then C" you say "whenever X happens, do A; whenever Y happens, do B; whenever Z happens, do C". In other words, while you design the code, <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> decides when and how often to run it.</P> <P>The specification file, which contains your instructions, is regular <A HREF="http://www.metronet.com/0/perlinfo/perl5/manual/perl.html"><TT>perl5</TT></A> code, and you can define packages and subroutines, display information, read files, create variables, etc. For processing the <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> document, however, <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> exports a single subroutine, <TT>sgml(<IT>event</IT>, <IT>handler</IT>)</TT>, into the 'main' package -- each time you call <TT>sgml</TT>, you declare a handler for a specific type of <TT>sgmls</TT> <A HREF="../SGMLSpm/events.html">event</A>, and <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> will then execute that handler every time the event occurs. You may use <TT>sgml</TT> to declare a <A HREF=handlers.html>handler</A> for a <A HREF=generic.html><I>generic event</I></A>, like <TT>'start_element'</TT>, or a <A HREF=specific.html><I>specific event</I></A>, like <TT>'<DOC>'</TT> -- a specific event will always take precedence over a generic event, so when the <TT>DOC</TT> element begins, <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> will execute the <TT>'<DOC>'</TT> handler rather than the <TT>'start_element'</TT> handler.</P> <P><B>Links</B>: <A HREF=handlers.html>Next</A> <A HREF=dsssl.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>