1 package hotsax.html.sax;
2
3 import org.xml.sax.*;
4 import org.xml.sax.helpers.*;
5 import org.xml.sax.ext.*;
6
7 import java.io.*;
8 import java.util.*;
9
10 /***
11 * ParserDelegate - provides a clean interface between the
12 * Byacc/J generated HtmlParse and the SaxParser.
13 * This cleanly separates what is to be done from actually doing it. A HtmlParser
14 * can be combined with a DOM or SAX backend.
15 */
16
17
18 public interface ParserDelegate {
19
20
21
22
23
24 /***
25 * Parse a startDocument event and pass it to the resigtered content handler.
26 * This method fires in response to a HtmlParser.EOF lexer token beging recognised.
27 * SOF is a virtual token fired as the first event after the file is opened.
28 */
29 public void startDocument();
30
31 /***
32 * Parse a PI and pass it to the contentHandler event
33 * (does not pass xml declaration: <?xml version = 1>)
34 * Separates the target from the data by using whitespace.
35 *
36 */
37 public void processingInstruction(HtmlParserVal target, HtmlParserVal lval);
38
39 /***
40 * Initialize the start of a start element. Prepares the attribute list
41 * to collect any attributes.
42 */
43 public void startElement();
44
45 /***
46 * Adds an attribute to the list. The name of the attribute is normalized
47 * to lowercase
48 */
49 public void addAttribute(String name, String value);
50
51 public HtmlParserVal getAttributes();
52 public void startElement(HtmlParserVal lval, HtmlParserVal attrList);
53
54 /***
55 * Fire startElement event. Note handled the actual beginning of the element by now
56 * and have collected all attributes (if any)
57 */
58 public void startElement(HtmlParserVal lval);
59
60 /***
61 * collect characters from parse stream. Unwrap the HtmlParserVal.sval
62 * String to a character array.
63 */
64 public void characters(HtmlParserVal lval);
65
66
67 /***
68 * Fire endElement event. The name of the element is passed to the event handler.
69 * Note these might be optionally missing in the HTML case.
70 */
71 public void endElement(HtmlParserVal lval);
72
73 /***
74 * Fire endDocument event.
75 */
76 public void endDocument();
77
78
79
80 /***
81 * comment handler
82 * Note, these are delegate to the XMLReader's LexicalHandler if any
83 */
84 public void comment(HtmlParserVal lval);
85
86
87 /***
88 * CDATA handler
89 * Note, these are delegate to the XMLReader's LexicalHandler if any
90 * This only marks the start boundary condition. Text still goes through characters()
91 */
92 public void startCDATA();
93
94 /***
95 * CDATA handler
96 * Note, these are delegate to the XMLReader's LexicalHandler if any
97 * This only marks the end boundary of the CDATA section. Text still goes through characters()
98 */
99 public void endCDATA();
100
101 /***
102 * Start the beginning of the DOCTYPE (DTD) declaration
103 * Note, these are delegate to the XMLReader's LexicalHandler if any
104 * @param lval HtmlParserVal represents the document type handle, system id or public id from the DOCTYPE declaration
105 */
106 public void startDTD(HtmlParserVal lval);
107
108 /***
109 * End the DOCTYPE declaration
110 */
111 public void endDTD();
112
113 /***
114 * Set the the XMLReader this delegate is reading from
115 * @param reader the XMLReader or really the current SAXParser
116 */
117 public void setXMLReader(XMLReader reader);
118
119 }