File: example.html

package info (click to toggle)
libsgmls-perl 1.03ii-38
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 900 kB
  • sloc: perl: 1,387; lisp: 262; makefile: 130
file content (82 lines) | stat: -rw-r--r-- 2,373 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<HTML>
<HEAD>
<TITLE>How about a simple example?</TITLE>
</HEAD>
<BODY>

<P><B>Links</B>: <A HREF=extend.html>Next</A> <A HREF=xtrainfo.html>Previous</A> <A HREF=sgmlspm.html>Up</A> <A HREF=sgmlspm.html>Top</A></P>

<H1>How about a simple example?</H1>

<P>OK.  The following script simply reports its events:</P>

<P>
<PRE>#!/usr/bin/perl

use SGMLS;

$this_parse = new SGMLS(STDIN); # Read from standard input.

while ($this_event = $this_parse-&gt;next_event) {
    my $type = $this_event-&gt;type;
    my $data = $this_event-&gt;data;
  SWITCH: {
      $type eq 'start_element' &amp;&amp; do {
          print "Beginning element: " . $data-&gt;name . "\n";
          last SWITCH;
      };
      $type eq 'end_element' &amp;&amp; do {
          print "Ending element: " . $data-&gt;name . "\n";
          last SWITCH;
      };
      $type eq 'cdata' &amp;&amp; do {
          print "Character data: " . $data . "\n";
          last SWITCH;
      };
      $type eq 'sdata' &amp;&amp; do {
          print "Special data: " . $data . "\n";
          last SWITCH;
      };
      $type eq 're' &amp;&amp; do {
          print "Record End\n";
          last SWITCH;
      };
      $type eq 'pi' &amp;&amp; do {
          print "Processing Instruction: " . $data . "\n";
          last SWITCH;
      };
      $type eq 'entity' &amp;&amp; do {
          print "External Data Entity: " . $data-&gt;name .
              " with notation " . $data-&gt;notation-&gt;name . "\n";
          last SWITCH;
      };
      $type eq 'start_subdoc' &amp;&amp; do {
          print "Beginning Subdocument Entity: " . $data-&gt;name . "\n";
          last SWITCH;
      };
      $type eq 'end_subdoc' &amp;&amp; do {
          print "Ending Subdocument Entity: " . $data-&gt;name . "\n";
          last SWITCH;
      };
      $type eq 'conforming' &amp;&amp; do {
          print "This is a conforming SGML document\n";
          last SWITCH;
      };
  }
}
</PRE>
</P>
<P>To use it under Unix, try something like</P>

<P>
<PRE>sgmls document.sgml | perl sample.pl</PRE>
</P>
<P>and watch the output scroll down.</P>


<P><B>Links</B>: <A HREF=extend.html>Next</A> <A HREF=xtrainfo.html>Previous</A> <A HREF=sgmlspm.html>Up</A> <A HREF=sgmlspm.html>Top</A></P>


<ADDRESS>David Megginson <A HREF="mailto:dmeggins@aix1.uottawa.ca">&lt;dmeggins@aix1.uottawa.ca&gt;</A></ADDRESS>
</BODY>
</HTML>