Debian Codegraph @

DOC/HTML/sgmlspl/generic.html

raw symbols SCIP
1 <HTML>
2 <HEAD>
3 <TITLE>What are the generic events?</TITLE>
4 </HEAD>
5 <BODY>
6
7 <P><B>Links</B>: <A HREF=specific.html>Next</A> <A HREF=handlers.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P>
8
9 <H1>What are the generic events?</H1>
10
11 <P><A HREF=sgmlspl.html><TT>sgmlspl</TT></A> recognises the twelve generic events listed in table
12 1. You may provide any one of these
13 as the first argument to <TT>sgml</TT> to declare a handler
14 (string or subroutine) for that event.</P>
15
16
17 <H3>Table 1: <A HREF=sgmlspl.html><TT>sgmlspl</TT></A> generic events</H3>
18
19 <HR>
20 <DL>
21 <DT><B>Event</B></DT>
22 <DD><TT>'start'</TT></DD>
23 <DT><B>Description</B></DT>
24 <DD>Execute <IT>handler</IT> (with no arguments) at
25 the beginning of the parse.</DD>
26
27 </DL>
28 <HR>
29
30
31 <DL>
32 <DT><B>Event</B></DT>
33 <DD><TT>'end'</TT></DD>
34 <DT><B>Description</B></DT>
35 <DD>Execute <IT>handler</IT> (with no arguments) at
36 the end of the parse.</DD>
37
38 </DL>
39 <HR>
40
41
42 <DL>
43 <DT><B>Event</B></DT>
44 <DD><TT>'start_element'</TT></DD>
45 <DT><B>Description</B></DT>
46 <DD>Execute <IT>handler</IT> at the beginning of every
47 element without a specific start handler.</DD>
48
49 </DL>
50 <HR>
51
52
53 <DL>
54 <DT><B>Event</B></DT>
55 <DD><TT>'end_element'</TT></DD>
56 <DT><B>Description</B></DT>
57 <DD>Execute <IT>handler</IT> at the end of every
58 element without a specific end handler.</DD>
59
60 </DL>
61 <HR>
62
63
64 <DL>
65 <DT><B>Event</B></DT>
66 <DD><TT>'cdata'</TT></DD>
67 <DT><B>Description</B></DT>
68 <DD>Execute <IT>handler</IT> for every character-data
69 string.</DD>
70
71 </DL>
72 <HR>
73
74
75 <DL>
76 <DT><B>Event</B></DT>
77 <DD><TT>'sdata'</TT></DD>
78 <DT><B>Description</B></DT>
79 <DD>Execute <IT>handler</IT> for every special-data
80 string without a specific handler.</DD>
81
82 </DL>
83 <HR>
84
85
86 <DL>
87 <DT><B>Event</B></DT>
88 <DD><TT>'re'</TT></DD>
89 <DT><B>Description</B></DT>
90 <DD>Execute <IT>handler</IT> for every
91 record end.</DD>
92
93 </DL>
94 <HR>
95
96
97 <DL>
98 <DT><B>Event</B></DT>
99 <DD><TT>'pi'</TT></DD>
100 <DT><B>Description</B></DT>
101 <DD>Execute <IT>handler</IT> for every processing
102 instruction.</DD>
103
104 </DL>
105 <HR>
106
107
108 <DL>
109 <DT><B>Event</B></DT>
110 <DD><TT>'entity'</TT></DD>
111 <DT><B>Description</B></DT>
112 <DD>Execute <IT>handler</IT> for every external data
113 entity without a specific handler.</DD>
114
115 </DL>
116 <HR>
117
118
119 <DL>
120 <DT><B>Event</B></DT>
121 <DD><TT>'start_subdoc'</TT></DD>
122 <DT><B>Description</B></DT>
123 <DD>Execute <IT>handler</IT> at the beginning of every
124 subdocument entity without a specific handler.</DD>
125
126 </DL>
127 <HR>
128
129
130 <DL>
131 <DT><B>Event</B></DT>
132 <DD><TT>'end_subdoc'</TT></DD>
133 <DT><B>Description</B></DT>
134 <DD>Execute <IT>handler</IT> at the end of every
135 subdocument entity without a specific handler.</DD>
136
137 </DL>
138 <HR>
139
140
141 <DL>
142 <DT><B>Event</B></DT>
143 <DD><TT>'conforming'</TT></DD>
144 <DT><B>Description</B></DT>
145 <DD>Execute <IT>handler</IT> once, at the end of the
146 document parse, if and only if the document was conforming.</DD>
147
148 </DL>
149 <HR>
150
151
152 <P>The handlers for all of these except the document events
153 <TT>'start'</TT> and <TT>'end'</TT> will receive
154 two arguments whenever they are called: the first will be the data
155 associated with the event (if any), and the second will be the
156 <TT>SGMLS_Event</TT> object itself (see the document for
157 <A HREF="../SGMLSpm/sgmlspm.html"><TT>SGMLS.pm</TT></A>). Note the following example, which allows processing
158 instructions for including the date or the hostname in the document at
159 parse time:</P>
160
161 <P>
162 <PRE>sgml('pi', sub {
163 my ($instruction) = @_;
164 if ($instruction eq 'date') {
165 output `date`;
166 } elsif ($instruction eq 'hostname') {
167 output `hostname`;
168 } else {
169 print STDERR "Warning: unknown processing instruction: $instruction\n";
170 }
171 });</PRE>
172 </P>
173 <P>With this <A HREF=handlers.html>handler</A>, any occurance
174 of <TT>&lt;?date&gt;</TT> in the original <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> document
175 would be replaced by the current date and time, and any occurance of
176 <TT>&lt;?hostname&gt;</TT> would be replaced by the name of
177 the host.</P>
178
179
180 <P><B>Links</B>: <A HREF=specific.html>Next</A> <A HREF=handlers.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P>
181
182
183 <ADDRESS>David Megginson <A HREF="mailto:[email protected]">&lt;[email protected]&gt;</A></ADDRESS>
184 </BODY>
185 </HTML>