2 define('XML_HTMLSAX3_STATE_STOP', 0);
3 define('XML_HTMLSAX3_STATE_START', 1);
4 define('XML_HTMLSAX3_STATE_TAG', 2);
5 define('XML_HTMLSAX3_STATE_OPENING_TAG', 3);
6 define('XML_HTMLSAX3_STATE_CLOSING_TAG', 4);
7 define('XML_HTMLSAX3_STATE_ESCAPE', 6);
8 define('XML_HTMLSAX3_STATE_JASP', 7);
9 define('XML_HTMLSAX3_STATE_PI', 8);
10 class XML_HTMLSax3_StartingState
{
11 function parse(&$context) {
12 $data = $context->scanUntilString('<');
14 $context->handler_object_data
->
15 {$context->handler_method_data
}($context->htmlsax
, $data);
17 $context->IgnoreCharacter();
18 return XML_HTMLSAX3_STATE_TAG
;
21 class XML_HTMLSax3_TagState
{
22 function parse(&$context) {
23 switch($context->ScanCharacter()) {
25 return XML_HTMLSAX3_STATE_CLOSING_TAG
;
28 return XML_HTMLSAX3_STATE_PI
;
31 return XML_HTMLSAX3_STATE_JASP
;
34 return XML_HTMLSAX3_STATE_ESCAPE
;
37 $context->unscanCharacter();
38 return XML_HTMLSAX3_STATE_OPENING_TAG
;
42 class XML_HTMLSax3_ClosingTagState
{
43 function parse(&$context) {
44 $tag = $context->scanUntilCharacters('/>');
46 $char = $context->scanCharacter();
48 $char = $context->scanCharacter();
50 $context->unscanCharacter();
53 $context->handler_object_element
->
54 {$context->handler_method_closing
}($context->htmlsax
, $tag, FALSE);
56 return XML_HTMLSAX3_STATE_START
;
59 class XML_HTMLSax3_OpeningTagState
{
60 function parseAttributes(&$context) {
61 $Attributes = array();
63 $context->ignoreWhitespace();
64 $attributename = $context->scanUntilCharacters("=/> \n\r\t");
65 while ($attributename != '') {
66 $attributevalue = NULL;
67 $context->ignoreWhitespace();
68 $char = $context->scanCharacter();
70 $context->ignoreWhitespace();
71 $char = $context->ScanCharacter();
73 $attributevalue= $context->scanUntilString('"');
74 $context->IgnoreCharacter();
75 } else if ($char == "'") {
76 $attributevalue = $context->scanUntilString("'");
77 $context->IgnoreCharacter();
79 $context->unscanCharacter();
81 $context->scanUntilCharacters("> \n\r\t");
83 } else if ($char !== NULL) {
84 $attributevalue = NULL;
85 $context->unscanCharacter();
87 $Attributes[$attributename] = $attributevalue;
89 $context->ignoreWhitespace();
90 $attributename = $context->scanUntilCharacters("=/> \n\r\t");
95 function parse(&$context) {
96 $tag = $context->scanUntilCharacters("/> \n\r\t");
98 $this->attrs
= array();
99 $Attributes = $this->parseAttributes($context);
100 $char = $context->scanCharacter();
102 $char = $context->scanCharacter();
104 $context->unscanCharacter();
106 $context->handler_object_element
->
107 {$context->handler_method_opening
}($context->htmlsax
, $tag,
109 $context->handler_object_element
->
110 {$context->handler_method_closing
}($context->htmlsax
, $tag,
113 $context->handler_object_element
->
114 {$context->handler_method_opening
}($context->htmlsax
, $tag,
118 return XML_HTMLSAX3_STATE_START
;
122 class XML_HTMLSax3_EscapeState
{
123 function parse(&$context) {
124 $char = $context->ScanCharacter();
126 $char = $context->ScanCharacter();
128 $context->unscanCharacter();
129 $context->unscanCharacter();
130 $text = $context->scanUntilString('-->');
131 $text .= $context->scanCharacter();
132 $text .= $context->scanCharacter();
134 $context->unscanCharacter();
135 $text = $context->scanUntilString('>');
137 } else if ( $char == '[') {
138 $context->unscanCharacter();
139 $text = $context->scanUntilString(']>');
140 $text.= $context->scanCharacter();
142 $context->unscanCharacter();
143 $text = $context->scanUntilString('>');
146 $context->IgnoreCharacter();
148 $context->handler_object_escape
->
149 {$context->handler_method_escape
}($context->htmlsax
, $text);
151 return XML_HTMLSAX3_STATE_START
;
154 class XML_HTMLSax3_JaspState
{
155 function parse(&$context) {
156 $text = $context->scanUntilString('%>');
158 $context->handler_object_jasp
->
159 {$context->handler_method_jasp
}($context->htmlsax
, $text);
161 $context->IgnoreCharacter();
162 $context->IgnoreCharacter();
163 return XML_HTMLSAX3_STATE_START
;
166 class XML_HTMLSax3_PiState
{
167 function parse(&$context) {
168 $target = $context->scanUntilCharacters(" \n\r\t");
169 $data = $context->scanUntilString('?>');
171 $context->handler_object_pi
->
172 {$context->handler_method_pi
}($context->htmlsax
, $target, $data);
174 $context->IgnoreCharacter();
175 $context->IgnoreCharacter();
176 return XML_HTMLSAX3_STATE_START
;