No regular expressions were active.
1 |
|
<?php
|
|
1 |
|
<?php
|
2 |
|
/* vim: se
t expandta
b tabstop=
4 shiftwid
th=4: */
|
|
2 |
|
/* vim: se
t expandta
b tabstop=
4 shiftwid
th=4: */
|
3 |
|
//
|
|
3 |
|
//
|
4 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
|
4 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
5 |
|
// | PHP V
ersion 4
|
|
|
5 |
|
// | PHP V
ersion 4
|
|
6 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
|
6 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
7 |
|
// | Copyr
ight (c) 1
997-2002 T
he PHP Gro
up
|
|
|
7 |
|
// | Copyr
ight (c) 1
997-2002 T
he PHP Gro
up
|
|
8 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
|
8 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
9 |
|
// | This
source fil
e is subje
ct to vers
ion 2.02 o
f the PHP
license,
|
|
|
9 |
|
// | This
source fil
e is subje
ct to vers
ion 2.02 o
f the PHP
license,
|
|
10 |
|
// | that
is bundled
with this
package i
n the file
LICENSE,
and is
|
|
|
10 |
|
// | that
is bundled
with this
package i
n the file
LICENSE,
and is
|
|
11 |
|
// | avail
able at th
rough the
world-wide
-web at
|
|
|
11 |
|
// | avail
able at th
rough the
world-wide
-web at
|
|
12 |
|
// | http:
//www.php.
net/licens
e/3_0.txt.
|
|
|
12 |
|
// | http:
//www.php.
net/licens
e/3_0.txt.
|
|
13 |
|
// | If yo
u did not
receive a
copy of th
e PHP lice
nse and ar
e unable t
o |
|
|
13 |
|
// | If yo
u did not
receive a
copy of th
e PHP lice
nse and ar
e unable t
o |
|
14 |
|
// | obtai
n it throu
gh the wor
ld-wide-we
b, please
send a not
e to
|
|
|
14 |
|
// | obtai
n it throu
gh the wor
ld-wide-we
b, please
send a not
e to
|
|
15 |
|
// | licen
se@php.net
so we can
mail you
a copy imm
ediately.
|
|
|
15 |
|
// | licen
se@php.net
so we can
mail you
a copy imm
ediately.
|
|
16 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
|
16 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
17 |
|
// | Autho
rs: Alexan
der Zhukov
<alex@ver
esk.ru> Or
iginal por
t from Pyt
hon |
|
|
17 |
|
// | Autho
rs: Alexan
der Zhukov
<alex@ver
esk.ru> Or
iginal por
t from Pyt
hon |
|
18 |
|
// | Autho
rs: Harry
Fuecks <hf
uecks@phpp
atterns.co
m> Port to
PEAR + mo
re |
|
|
18 |
|
// | Autho
rs: Harry
Fuecks <hf
uecks@phpp
atterns.co
m> Port to
PEAR + mo
re |
|
19 |
|
// | Autho
rs: Many @
Sitepoint
forums Adv
anced PHP
Forums
|
|
|
19 |
|
// | Autho
rs: Many @
Sitepoint
forums Adv
anced PHP
Forums
|
|
20 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
|
20 |
|
// +------
----------
----------
----------
----------
----------
----------
----+
|
21 |
|
//
|
|
21 |
|
//
|
22 |
|
// $Id: HT
MLSax3.php
,v 1.1 200
4/06/02 14
:09:19 hfu
ecks Exp $
|
|
22 |
|
// $Id: HT
MLSax3.php
,v 1.1 200
4/06/02 14
:09:19 hfu
ecks Exp $
|
23 |
|
//
|
|
23 |
|
//
|
24 |
|
/**
|
|
24 |
|
/**
|
25 |
|
* Main par
ser compon
ents
|
|
25 |
|
* Main par
ser compon
ents
|
26 |
|
* @package
XML_HTMLS
ax3
|
|
26 |
|
* @package
XML_HTMLS
ax3
|
27 |
|
* @version
$Id: HTML
Sax3.php,v
1.1 2004/
06/02 14:0
9:19 hfuec
ks Exp $
|
|
27 |
|
* @version
$Id: HTML
Sax3.php,v
1.1 2004/
06/02 14:0
9:19 hfuec
ks Exp $
|
28 |
|
*/
|
|
28 |
|
*/
|
29 |
|
/**
|
|
29 |
|
/**
|
30 |
|
* Required
classes
|
|
30 |
|
* Required
classes
|
31 |
|
*/
|
|
31 |
|
*/
|
32 |
|
require_on
ce(
"{$dir['pl
ugins
'
]}
safehtml/H
TMLSax3/St
ates.php
"
);
|
|
32 |
|
require_on
ce(
BX_DIRECTO
RY_PATH_PL
UGINS
.
'
safehtml/H
TMLSax3/St
ates.php
'
);
|
33 |
|
require_on
ce(
"{$dir['pl
ugins
'
]}
safehtml/H
TMLSax3/De
corators.p
hp
"
);
|
|
33 |
|
require_on
ce(
BX_DIRECTO
RY_PATH_PL
UGINS
.
'
safehtml/H
TMLSax3/De
corators.p
hp
'
);
|
34 |
|
|
|
34 |
|
|
35 |
|
/**
|
|
35 |
|
/**
|
36 |
|
* Base Sta
te Parser
|
|
36 |
|
* Base Sta
te Parser
|
37 |
|
* @package
XML_HTMLS
ax3
|
|
37 |
|
* @package
XML_HTMLS
ax3
|
38 |
|
* @access
protected
|
|
38 |
|
* @access
protected
|
39 |
|
* @abstrac
t
|
|
39 |
|
* @abstrac
t
|
40 |
|
*/
|
|
40 |
|
*/
|
41 |
|
class XML_
HTMLSax3_S
tateParser
{
|
|
41 |
|
class XML_
HTMLSax3_S
tateParser
{
|
42 |
|
/**
|
|
42 |
|
/**
|
43 |
|
* Inst
ance of us
er front e
nd class t
o be passe
d to callb
acks
|
|
43 |
|
* Inst
ance of us
er front e
nd class t
o be passe
d to callb
acks
|
44 |
|
* @var
XML_HTMLS
ax3
|
|
44 |
|
* @var
XML_HTMLS
ax3
|
45 |
|
* @acc
ess privat
e
|
|
45 |
|
* @acc
ess privat
e
|
46 |
|
*/
|
|
46 |
|
*/
|
47 |
|
var $h
tmlsax;
|
|
47 |
|
var $h
tmlsax;
|
48 |
|
/**
|
|
48 |
|
/**
|
49 |
|
* User
defined o
bject for
handling e
lements
|
|
49 |
|
* User
defined o
bject for
handling e
lements
|
50 |
|
* @var
object
|
|
50 |
|
* @var
object
|
51 |
|
* @acc
ess privat
e
|
|
51 |
|
* @acc
ess privat
e
|
52 |
|
*/
|
|
52 |
|
*/
|
53 |
|
var $h
andler_obj
ect_elemen
t;
|
|
53 |
|
var $h
andler_obj
ect_elemen
t;
|
54 |
|
/**
|
|
54 |
|
/**
|
55 |
|
* User
defined o
pen tag ha
ndler meth
od
|
|
55 |
|
* User
defined o
pen tag ha
ndler meth
od
|
56 |
|
* @var
string
|
|
56 |
|
* @var
string
|
57 |
|
* @acc
ess privat
e
|
|
57 |
|
* @acc
ess privat
e
|
58 |
|
*/
|
|
58 |
|
*/
|
59 |
|
var $h
andler_met
hod_openin
g;
|
|
59 |
|
var $h
andler_met
hod_openin
g;
|
60 |
|
/**
|
|
60 |
|
/**
|
61 |
|
* User
defined c
lose tag h
andler met
hod
|
|
61 |
|
* User
defined c
lose tag h
andler met
hod
|
62 |
|
* @var
string
|
|
62 |
|
* @var
string
|
63 |
|
* @acc
ess privat
e
|
|
63 |
|
* @acc
ess privat
e
|
64 |
|
*/
|
|
64 |
|
*/
|
65 |
|
var $h
andler_met
hod_closin
g;
|
|
65 |
|
var $h
andler_met
hod_closin
g;
|
66 |
|
/**
|
|
66 |
|
/**
|
67 |
|
* User
defined o
bject for
handling d
ata in ele
ments
|
|
67 |
|
* User
defined o
bject for
handling d
ata in ele
ments
|
68 |
|
* @var
object
|
|
68 |
|
* @var
object
|
69 |
|
* @acc
ess privat
e
|
|
69 |
|
* @acc
ess privat
e
|
70 |
|
*/
|
|
70 |
|
*/
|
71 |
|
var $h
andler_obj
ect_data;
|
|
71 |
|
var $h
andler_obj
ect_data;
|
72 |
|
/**
|
|
72 |
|
/**
|
73 |
|
* User
defined d
ata handle
r method
|
|
73 |
|
* User
defined d
ata handle
r method
|
74 |
|
* @var
string
|
|
74 |
|
* @var
string
|
75 |
|
* @acc
ess privat
e
|
|
75 |
|
* @acc
ess privat
e
|
76 |
|
*/
|
|
76 |
|
*/
|
77 |
|
var $h
andler_met
hod_data;
|
|
77 |
|
var $h
andler_met
hod_data;
|
78 |
|
/**
|
|
78 |
|
/**
|
79 |
|
* User
defined o
bject for
handling p
rocessing
instructio
ns
|
|
79 |
|
* User
defined o
bject for
handling p
rocessing
instructio
ns
|
80 |
|
* @var
object
|
|
80 |
|
* @var
object
|
81 |
|
* @acc
ess privat
e
|
|
81 |
|
* @acc
ess privat
e
|
82 |
|
*/
|
|
82 |
|
*/
|
83 |
|
var $h
andler_obj
ect_pi;
|
|
83 |
|
var $h
andler_obj
ect_pi;
|
84 |
|
/**
|
|
84 |
|
/**
|
85 |
|
* User
defined p
rocessing
instructio
n handler
method
|
|
85 |
|
* User
defined p
rocessing
instructio
n handler
method
|
86 |
|
* @var
string
|
|
86 |
|
* @var
string
|
87 |
|
* @acc
ess privat
e
|
|
87 |
|
* @acc
ess privat
e
|
88 |
|
*/
|
|
88 |
|
*/
|
89 |
|
var $h
andler_met
hod_pi;
|
|
89 |
|
var $h
andler_met
hod_pi;
|
90 |
|
/**
|
|
90 |
|
/**
|
91 |
|
* User
defined o
bject for
handling J
SP/ASP tag
s
|
|
91 |
|
* User
defined o
bject for
handling J
SP/ASP tag
s
|
92 |
|
* @var
object
|
|
92 |
|
* @var
object
|
93 |
|
* @acc
ess privat
e
|
|
93 |
|
* @acc
ess privat
e
|
94 |
|
*/
|
|
94 |
|
*/
|
95 |
|
var $h
andler_obj
ect_jasp;
|
|
95 |
|
var $h
andler_obj
ect_jasp;
|
96 |
|
/**
|
|
96 |
|
/**
|
97 |
|
* User
defined J
SP/ASP han
dler metho
d
|
|
97 |
|
* User
defined J
SP/ASP han
dler metho
d
|
98 |
|
* @var
string
|
|
98 |
|
* @var
string
|
99 |
|
* @acc
ess privat
e
|
|
99 |
|
* @acc
ess privat
e
|
100 |
|
*/
|
|
100 |
|
*/
|
101 |
|
var $h
andler_met
hod_jasp;
|
|
101 |
|
var $h
andler_met
hod_jasp;
|
102 |
|
/**
|
|
102 |
|
/**
|
103 |
|
* User
defined o
bject for
handling X
ML escapes
|
|
103 |
|
* User
defined o
bject for
handling X
ML escapes
|
104 |
|
* @var
object
|
|
104 |
|
* @var
object
|
105 |
|
* @acc
ess privat
e
|
|
105 |
|
* @acc
ess privat
e
|
106 |
|
*/
|
|
106 |
|
*/
|
107 |
|
var $h
andler_obj
ect_escape
;
|
|
107 |
|
var $h
andler_obj
ect_escape
;
|
108 |
|
/**
|
|
108 |
|
/**
|
109 |
|
* User
defined X
ML escape
handler me
thod
|
|
109 |
|
* User
defined X
ML escape
handler me
thod
|
110 |
|
* @var
string
|
|
110 |
|
* @var
string
|
111 |
|
* @acc
ess privat
e
|
|
111 |
|
* @acc
ess privat
e
|
112 |
|
*/
|
|
112 |
|
*/
|
113 |
|
var $h
andler_met
hod_escape
;
|
|
113 |
|
var $h
andler_met
hod_escape
;
|
114 |
|
/**
|
|
114 |
|
/**
|
115 |
|
* User
defined h
andler obj
ect or Nul
lHandler
|
|
115 |
|
* User
defined h
andler obj
ect or Nul
lHandler
|
116 |
|
* @var
object
|
|
116 |
|
* @var
object
|
117 |
|
* @acc
ess privat
e
|
|
117 |
|
* @acc
ess privat
e
|
118 |
|
*/
|
|
118 |
|
*/
|
119 |
|
var $h
andler_def
ault;
|
|
119 |
|
var $h
andler_def
ault;
|
120 |
|
/**
|
|
120 |
|
/**
|
121 |
|
* Pars
er options
determini
ng parsing
behavior
|
|
121 |
|
* Pars
er options
determini
ng parsing
behavior
|
122 |
|
* @var
array
|
|
122 |
|
* @var
array
|
123 |
|
* @acc
ess privat
e
|
|
123 |
|
* @acc
ess privat
e
|
124 |
|
*/
|
|
124 |
|
*/
|
125 |
|
var $p
arser_opti
ons = arra
y();
|
|
125 |
|
var $p
arser_opti
ons = arra
y();
|
126 |
|
/**
|
|
126 |
|
/**
|
127 |
|
* XML
document b
eing parse
d
|
|
127 |
|
* XML
document b
eing parse
d
|
128 |
|
* @var
string
|
|
128 |
|
* @var
string
|
129 |
|
* @acc
ess privat
e
|
|
129 |
|
* @acc
ess privat
e
|
130 |
|
*/
|
|
130 |
|
*/
|
131 |
|
var $r
awtext;
|
|
131 |
|
var $r
awtext;
|
132 |
|
/**
|
|
132 |
|
/**
|
133 |
|
* Posi
tion in XM
L document
relative
to start (
0)
|
|
133 |
|
* Posi
tion in XM
L document
relative
to start (
0)
|
134 |
|
* @var
int
|
|
134 |
|
* @var
int
|
135 |
|
* @acc
ess privat
e
|
|
135 |
|
* @acc
ess privat
e
|
136 |
|
*/
|
|
136 |
|
*/
|
137 |
|
var $p
osition;
|
|
137 |
|
var $p
osition;
|
138 |
|
/**
|
|
138 |
|
/**
|
139 |
|
* Leng
th of the
XML docume
nt in char
acters
|
|
139 |
|
* Leng
th of the
XML docume
nt in char
acters
|
140 |
|
* @var
int
|
|
140 |
|
* @var
int
|
141 |
|
* @acc
ess privat
e
|
|
141 |
|
* @acc
ess privat
e
|
142 |
|
*/
|
|
142 |
|
*/
|
143 |
|
var $l
ength;
|
|
143 |
|
var $l
ength;
|
144 |
|
/**
|
|
144 |
|
/**
|
145 |
|
* Arra
y of state
objects
|
|
145 |
|
* Arra
y of state
objects
|
146 |
|
* @var
array
|
|
146 |
|
* @var
array
|
147 |
|
* @acc
ess privat
e
|
|
147 |
|
* @acc
ess privat
e
|
148 |
|
*/
|
|
148 |
|
*/
|
149 |
|
var $S
tate = arr
ay();
|
|
149 |
|
var $S
tate = arr
ay();
|
150 |
|
|
|
150 |
|
|
151 |
|
/**
|
|
151 |
|
/**
|
152 |
|
* Cons
tructs XML
_HTMLSax3_
StateParse
r setting
up states
|
|
152 |
|
* Cons
tructs XML
_HTMLSax3_
StateParse
r setting
up states
|
153 |
|
* @var
XML_HTMLS
ax3 instan
ce of user
front end
class
|
|
153 |
|
* @var
XML_HTMLS
ax3 instan
ce of user
front end
class
|
154 |
|
* @acc
ess protec
ted
|
|
154 |
|
* @acc
ess protec
ted
|
155 |
|
*/
|
|
155 |
|
*/
|
156 |
|
functi
on XML_HTM
LSax3_Stat
eParser (&
$htmlsax)
{
|
|
156 |
|
functi
on XML_HTM
LSax3_Stat
eParser (&
$htmlsax)
{
|
157 |
|
$t
his->htmls
ax = & $ht
mlsax;
|
|
157 |
|
$t
his->htmls
ax = & $ht
mlsax;
|
158 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
START] =&
new XML_HT
MLSax3_Sta
rtingState
();
|
|
158 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
START] =&
new XML_HT
MLSax3_Sta
rtingState
();
|
159 |
|
|
|
159 |
|
|
160 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
CLOSING_TA
G] =& new
XML_HTMLSa
x3_Closing
TagState()
;
|
|
160 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
CLOSING_TA
G] =& new
XML_HTMLSa
x3_Closing
TagState()
;
|
161 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
TAG] =& ne
w XML_HTML
Sax3_TagSt
ate();
|
|
161 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
TAG] =& ne
w XML_HTML
Sax3_TagSt
ate();
|
162 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
OPENING_TA
G] =& new
XML_HTMLSa
x3_Opening
TagState()
;
|
|
162 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
OPENING_TA
G] =& new
XML_HTMLSa
x3_Opening
TagState()
;
|
163 |
|
|
|
163 |
|
|
164 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
PI] =& new
XML_HTMLS
ax3_PiStat
e();
|
|
164 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
PI] =& new
XML_HTMLS
ax3_PiStat
e();
|
165 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
JASP] =& n
ew XML_HTM
LSax3_Jasp
State();
|
|
165 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
JASP] =& n
ew XML_HTM
LSax3_Jasp
State();
|
166 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
ESCAPE] =&
new XML_H
TMLSax3_Es
capeState(
);
|
|
166 |
|
$t
his->State
[XML_HTMLS
AX3_STATE_
ESCAPE] =&
new XML_H
TMLSax3_Es
capeState(
);
|
167 |
|
}
|
|
167 |
|
}
|
168 |
|
|
|
168 |
|
|
169 |
|
/**
|
|
169 |
|
/**
|
170 |
|
* Move
s the posi
tion back
one charac
ter
|
|
170 |
|
* Move
s the posi
tion back
one charac
ter
|
171 |
|
* @acc
ess protec
ted
|
|
171 |
|
* @acc
ess protec
ted
|
172 |
|
* @ret
urn void
|
|
172 |
|
* @ret
urn void
|
173 |
|
*/
|
|
173 |
|
*/
|
174 |
|
functi
on unscanC
haracter()
{
|
|
174 |
|
functi
on unscanC
haracter()
{
|
175 |
|
$t
his->posit
ion -= 1;
|
|
175 |
|
$t
his->posit
ion -= 1;
|
176 |
|
}
|
|
176 |
|
}
|
177 |
|
|
|
177 |
|
|
178 |
|
/**
|
|
178 |
|
/**
|
179 |
|
* Move
s the posi
tion forwa
rd one cha
racter
|
|
179 |
|
* Move
s the posi
tion forwa
rd one cha
racter
|
180 |
|
* @acc
ess protec
ted
|
|
180 |
|
* @acc
ess protec
ted
|
181 |
|
* @ret
urn void
|
|
181 |
|
* @ret
urn void
|
182 |
|
*/
|
|
182 |
|
*/
|
183 |
|
functi
on ignoreC
haracter()
{
|
|
183 |
|
functi
on ignoreC
haracter()
{
|
184 |
|
$t
his->posit
ion += 1;
|
|
184 |
|
$t
his->posit
ion += 1;
|
185 |
|
}
|
|
185 |
|
}
|
186 |
|
|
|
186 |
|
|
187 |
|
/**
|
|
187 |
|
/**
|
188 |
|
* Retu
rns the ne
xt charact
er from th
e XML docu
ment or vo
id if at e
nd
|
|
188 |
|
* Retu
rns the ne
xt charact
er from th
e XML docu
ment or vo
id if at e
nd
|
189 |
|
* @acc
ess protec
ted
|
|
189 |
|
* @acc
ess protec
ted
|
190 |
|
* @ret
urn mixed
|
|
190 |
|
* @ret
urn mixed
|
191 |
|
*/
|
|
191 |
|
*/
|
192 |
|
functi
on scanCha
racter() {
|
|
192 |
|
functi
on scanCha
racter() {
|
193 |
|
if
($this->p
osition <
$this->len
gth) {
|
|
193 |
|
if
($this->p
osition <
$this->len
gth) {
|
194 |
|
return $
this->rawt
ext{$this-
>position+
+};
|
|
194 |
|
return $
this->rawt
ext{$this-
>position+
+};
|
195 |
|
}
|
|
195 |
|
}
|
196 |
|
}
|
|
196 |
|
}
|
197 |
|
|
|
197 |
|
|
198 |
|
/**
|
|
198 |
|
/**
|
199 |
|
* Retu
rns a stri
ng from th
e current
position t
o the next
occurance
|
|
199 |
|
* Retu
rns a stri
ng from th
e current
position t
o the next
occurance
|
200 |
|
* of t
he supplie
d string
|
|
200 |
|
* of t
he supplie
d string
|
201 |
|
* @par
am string
string to
search unt
il
|
|
201 |
|
* @par
am string
string to
search unt
il
|
202 |
|
* @acc
ess protec
ted
|
|
202 |
|
* @acc
ess protec
ted
|
203 |
|
* @ret
urn string
|
|
203 |
|
* @ret
urn string
|
204 |
|
*/
|
|
204 |
|
*/
|
205 |
|
functi
on scanUnt
ilString($
string) {
|
|
205 |
|
functi
on scanUnt
ilString($
string) {
|
206 |
|
$s
tart = $th
is->positi
on;
|
|
206 |
|
$s
tart = $th
is->positi
on;
|
207 |
|
$t
his->posit
ion = strp
os($this->
rawtext, $
string, $s
tart);
|
|
207 |
|
$t
his->posit
ion = strp
os($this->
rawtext, $
string, $s
tart);
|
208 |
|
if
($this->p
osition ==
= FALSE) {
|
|
208 |
|
if
($this->p
osition ==
= FALSE) {
|
209 |
|
$this->p
osition =
$this->len
gth;
|
|
209 |
|
$this->p
osition =
$this->len
gth;
|
210 |
|
}
|
|
210 |
|
}
|
211 |
|
re
turn subst
r($this->r
awtext, $s
tart, $thi
s->positio
n - $start
);
|
|
211 |
|
re
turn subst
r($this->r
awtext, $s
tart, $thi
s->positio
n - $start
);
|
212 |
|
}
|
|
212 |
|
}
|
213 |
|
|
|
213 |
|
|
214 |
|
/**
|
|
214 |
|
/**
|
215 |
|
* Retu
rns a stri
ng from th
e current
position u
ntil the f
irst insta
nce of
|
|
215 |
|
* Retu
rns a stri
ng from th
e current
position u
ntil the f
irst insta
nce of
|
216 |
|
* one
of the cha
racters in
the suppl
ied string
argument
|
|
216 |
|
* one
of the cha
racters in
the suppl
ied string
argument
|
217 |
|
* @par
am string
string to
search unt
il
|
|
217 |
|
* @par
am string
string to
search unt
il
|
218 |
|
* @acc
ess protec
ted
|
|
218 |
|
* @acc
ess protec
ted
|
219 |
|
* @ret
urn string
|
|
219 |
|
* @ret
urn string
|
220 |
|
* @abs
tract
|
|
220 |
|
* @abs
tract
|
221 |
|
*/
|
|
221 |
|
*/
|
222 |
|
functi
on scanUnt
ilCharacte
rs($string
) {}
|
|
222 |
|
functi
on scanUnt
ilCharacte
rs($string
) {}
|
223 |
|
|
|
223 |
|
|
224 |
|
/**
|
|
224 |
|
/**
|
225 |
|
* Move
s the posi
tion forwa
rd past an
y whitespa
ce charact
ers
|
|
225 |
|
* Move
s the posi
tion forwa
rd past an
y whitespa
ce charact
ers
|
226 |
|
* @acc
ess protec
ted
|
|
226 |
|
* @acc
ess protec
ted
|
227 |
|
* @ret
urn void
|
|
227 |
|
* @ret
urn void
|
228 |
|
* @abs
tract
|
|
228 |
|
* @abs
tract
|
229 |
|
*/
|
|
229 |
|
*/
|
230 |
|
functi
on ignoreW
hitespace(
) {}
|
|
230 |
|
functi
on ignoreW
hitespace(
) {}
|
231 |
|
|
|
231 |
|
|
232 |
|
/**
|
|
232 |
|
/**
|
233 |
|
* Begi
ns the par
sing opera
tion, sett
ing up any
decorator
s, dependi
ng on
|
|
233 |
|
* Begi
ns the par
sing opera
tion, sett
ing up any
decorator
s, dependi
ng on
|
234 |
|
* pars
e options
invoking _
parse() to
execute p
arsing
|
|
234 |
|
* pars
e options
invoking _
parse() to
execute p
arsing
|
235 |
|
* @par
am string
XML docume
nt to pars
e
|
|
235 |
|
* @par
am string
XML docume
nt to pars
e
|
236 |
|
* @acc
ess protec
ted
|
|
236 |
|
* @acc
ess protec
ted
|
237 |
|
* @ret
urn void
|
|
237 |
|
* @ret
urn void
|
238 |
|
*/
|
|
238 |
|
*/
|
239 |
|
functi
on parse($
data) {
|
|
239 |
|
functi
on parse($
data) {
|
240 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_TRIM
_DATA_NODE
S']==1) {
|
|
240 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_TRIM
_DATA_NODE
S']==1) {
|
241 |
|
$decorat
or =& new
XML_HTMLSa
x3_Trim(
|
|
241 |
|
$decorat
or =& new
XML_HTMLSa
x3_Trim(
|
242 |
|
$thi
s->handler
_object_da
ta,
|
|
242 |
|
$thi
s->handler
_object_da
ta,
|
243 |
|
$thi
s->handler
_method_da
ta);
|
|
243 |
|
$thi
s->handler
_method_da
ta);
|
244 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
|
244 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
245 |
|
$this->h
andler_met
hod_data =
'trimData
';
|
|
245 |
|
$this->h
andler_met
hod_data =
'trimData
';
|
246 |
|
}
|
|
246 |
|
}
|
247 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_CASE
_FOLDING']
==1) {
|
|
247 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_CASE
_FOLDING']
==1) {
|
248 |
|
$open_de
cor =& new
XML_HTMLS
ax3_CaseFo
lding(
|
|
248 |
|
$open_de
cor =& new
XML_HTMLS
ax3_CaseFo
lding(
|
249 |
|
$thi
s->handler
_object_el
ement,
|
|
249 |
|
$thi
s->handler
_object_el
ement,
|
250 |
|
$thi
s->handler
_method_op
ening,
|
|
250 |
|
$thi
s->handler
_method_op
ening,
|
251 |
|
$thi
s->handler
_method_cl
osing);
|
|
251 |
|
$thi
s->handler
_method_cl
osing);
|
252 |
|
$this->h
andler_obj
ect_elemen
t =& $open
_decor;
|
|
252 |
|
$this->h
andler_obj
ect_elemen
t =& $open
_decor;
|
253 |
|
$this->h
andler_met
hod_openin
g ='foldOp
en';
|
|
253 |
|
$this->h
andler_met
hod_openin
g ='foldOp
en';
|
254 |
|
$this->h
andler_met
hod_closin
g ='foldCl
ose';
|
|
254 |
|
$this->h
andler_met
hod_closin
g ='foldCl
ose';
|
255 |
|
}
|
|
255 |
|
}
|
256 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_LINE
FEED_BREAK
']==1) {
|
|
256 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_LINE
FEED_BREAK
']==1) {
|
257 |
|
$decorat
or =& new
XML_HTMLSa
x3_Linefee
d(
|
|
257 |
|
$decorat
or =& new
XML_HTMLSa
x3_Linefee
d(
|
258 |
|
$thi
s->handler
_object_da
ta,
|
|
258 |
|
$thi
s->handler
_object_da
ta,
|
259 |
|
$thi
s->handler
_method_da
ta);
|
|
259 |
|
$thi
s->handler
_method_da
ta);
|
260 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
|
260 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
261 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
|
261 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
262 |
|
}
|
|
262 |
|
}
|
263 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_TAB_
BREAK']==1
) {
|
|
263 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_TAB_
BREAK']==1
) {
|
264 |
|
$decorat
or =& new
XML_HTMLSa
x3_Tab(
|
|
264 |
|
$decorat
or =& new
XML_HTMLSa
x3_Tab(
|
265 |
|
$thi
s->handler
_object_da
ta,
|
|
265 |
|
$thi
s->handler
_object_da
ta,
|
266 |
|
$thi
s->handler
_method_da
ta);
|
|
266 |
|
$thi
s->handler
_method_da
ta);
|
267 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
|
267 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
268 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
|
268 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
269 |
|
}
|
|
269 |
|
}
|
270 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_ENTI
TIES_UNPAR
SED']==1)
{
|
|
270 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_ENTI
TIES_UNPAR
SED']==1)
{
|
271 |
|
$decorat
or =& new
XML_HTMLSa
x3_Entitie
s_Unparsed
(
|
|
271 |
|
$decorat
or =& new
XML_HTMLSa
x3_Entitie
s_Unparsed
(
|
272 |
|
$thi
s->handler
_object_da
ta,
|
|
272 |
|
$thi
s->handler
_object_da
ta,
|
273 |
|
$thi
s->handler
_method_da
ta);
|
|
273 |
|
$thi
s->handler
_method_da
ta);
|
274 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
|
274 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
275 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
|
275 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
276 |
|
}
|
|
276 |
|
}
|
277 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_ENTI
TIES_PARSE
D']==1) {
|
|
277 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_ENTI
TIES_PARSE
D']==1) {
|
278 |
|
$decorat
or =& new
XML_HTMLSa
x3_Entitie
s_Parsed(
|
|
278 |
|
$decorat
or =& new
XML_HTMLSa
x3_Entitie
s_Parsed(
|
279 |
|
$thi
s->handler
_object_da
ta,
|
|
279 |
|
$thi
s->handler
_object_da
ta,
|
280 |
|
$thi
s->handler
_method_da
ta);
|
|
280 |
|
$thi
s->handler
_method_da
ta);
|
281 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
|
281 |
|
$this->h
andler_obj
ect_data =
& $decorat
or;
|
282 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
|
282 |
|
$this->h
andler_met
hod_data =
'breakDat
a';
|
283 |
|
}
|
|
283 |
|
}
|
284 |
|
//
Note swit
ched on by
default
|
|
284 |
|
//
Note swit
ched on by
default
|
285 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_STRI
P_ESCAPES'
]==1) {
|
|
285 |
|
if
($this->p
arser_opti
ons['XML_O
PTION_STRI
P_ESCAPES'
]==1) {
|
286 |
|
$decorat
or =& new
XML_HTMLSa
x3_Escape_
Stripper(
|
|
286 |
|
$decorat
or =& new
XML_HTMLSa
x3_Escape_
Stripper(
|
287 |
|
$thi
s->handler
_object_es
cape,
|
|
287 |
|
$thi
s->handler
_object_es
cape,
|
288 |
|
$thi
s->handler
_method_es
cape);
|
|
288 |
|
$thi
s->handler
_method_es
cape);
|
289 |
|
$this->h
andler_obj
ect_escape
=& $decor
ator;
|
|
289 |
|
$this->h
andler_obj
ect_escape
=& $decor
ator;
|
290 |
|
$this->h
andler_met
hod_escape
= 'strip'
;
|
|
290 |
|
$this->h
andler_met
hod_escape
= 'strip'
;
|
291 |
|
}
|
|
291 |
|
}
|
292 |
|
$t
his->rawte
xt = $data
;
|
|
292 |
|
$t
his->rawte
xt = $data
;
|
293 |
|
$t
his->lengt
h = strlen
($data);
|
|
293 |
|
$t
his->lengt
h = strlen
($data);
|
294 |
|
$t
his->posit
ion = 0;
|
|
294 |
|
$t
his->posit
ion = 0;
|
295 |
|
$t
his->_pars
e();
|
|
295 |
|
$t
his->_pars
e();
|
296 |
|
}
|
|
296 |
|
}
|
297 |
|
|
|
297 |
|
|
298 |
|
/**
|
|
298 |
|
/**
|
299 |
|
* Perf
orms the p
arsing its
elf, deleg
ating call
s to a spe
cific pars
er
|
|
299 |
|
* Perf
orms the p
arsing its
elf, deleg
ating call
s to a spe
cific pars
er
|
300 |
|
* stat
e
|
|
300 |
|
* stat
e
|
301 |
|
* @par
am constan
t state ob
ject to pa
rse with
|
|
301 |
|
* @par
am constan
t state ob
ject to pa
rse with
|
302 |
|
* @acc
ess protec
ted
|
|
302 |
|
* @acc
ess protec
ted
|
303 |
|
* @ret
urn void
|
|
303 |
|
* @ret
urn void
|
304 |
|
*/
|
|
304 |
|
*/
|
305 |
|
functi
on _parse(
$state = X
ML_HTMLSAX
3_STATE_ST
ART) {
|
|
305 |
|
functi
on _parse(
$state = X
ML_HTMLSAX
3_STATE_ST
ART) {
|
306 |
|
do
{
|
|
306 |
|
do
{
|
307 |
|
$state =
$this->St
ate[$state
]->parse($
this);
|
|
307 |
|
$state =
$this->St
ate[$state
]->parse($
this);
|
308 |
|
}
while ($st
ate != XML
_HTMLSAX3_
STATE_STOP
&&
|
|
308 |
|
}
while ($st
ate != XML
_HTMLSAX3_
STATE_STOP
&&
|
309 |
|
$this->pos
ition < $t
his->lengt
h);
|
|
309 |
|
$this->pos
ition < $t
his->lengt
h);
|
310 |
|
}
|
|
310 |
|
}
|
311 |
|
}
|
|
311 |
|
}
|
312 |
|
|
|
312 |
|
|
313 |
|
/**
|
|
313 |
|
/**
|
314 |
|
* Parser f
or PHP Ver
sions belo
w 4.3.0. U
ses a slow
er parsing
mechanism
than
|
|
314 |
|
* Parser f
or PHP Ver
sions belo
w 4.3.0. U
ses a slow
er parsing
mechanism
than
|
315 |
|
* the equi
valent PHP
4.3.0+ s
ubclass of
StatePars
er
|
|
315 |
|
* the equi
valent PHP
4.3.0+ s
ubclass of
StatePars
er
|
316 |
|
* @package
XML_HTMLS
ax3
|
|
316 |
|
* @package
XML_HTMLS
ax3
|
317 |
|
* @access
protected
|
|
317 |
|
* @access
protected
|
318 |
|
* @see XML
_HTMLSax3_
StateParse
r_Gtet430
|
|
318 |
|
* @see XML
_HTMLSax3_
StateParse
r_Gtet430
|
319 |
|
*/
|
|
319 |
|
*/
|
320 |
|
class XML_
HTMLSax3_S
tateParser
_Lt430 ext
ends XML_H
TMLSax3_St
ateParser
{
|
|
320 |
|
class XML_
HTMLSax3_S
tateParser
_Lt430 ext
ends XML_H
TMLSax3_St
ateParser
{
|
321 |
|
/**
|
|
321 |
|
/**
|
322 |
|
* Cons
tructs XML
_HTMLSax3_
StateParse
r_Lt430 de
fining ava
ilable
|
|
322 |
|
* Cons
tructs XML
_HTMLSax3_
StateParse
r_Lt430 de
fining ava
ilable
|
323 |
|
* pars
er options
|
|
323 |
|
* pars
er options
|
324 |
|
* @var
XML_HTMLS
ax3 instan
ce of user
front end
class
|
|
324 |
|
* @var
XML_HTMLS
ax3 instan
ce of user
front end
class
|
325 |
|
* @acc
ess protec
ted
|
|
325 |
|
* @acc
ess protec
ted
|
326 |
|
*/
|
|
326 |
|
*/
|
327 |
|
functi
on XML_HTM
LSax3_Stat
eParser_Lt
430(& $htm
lsax) {
|
|
327 |
|
functi
on XML_HTM
LSax3_Stat
eParser_Lt
430(& $htm
lsax) {
|
328 |
|
pa
rent::XML_
HTMLSax3_S
tateParser
($htmlsax)
;
|
|
328 |
|
pa
rent::XML_
HTMLSax3_S
tateParser
($htmlsax)
;
|
329 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TRIM_DAT
A_NODES']
= 0;
|
|
329 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TRIM_DAT
A_NODES']
= 0;
|
330 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_CASE_FOL
DING'] = 0
;
|
|
330 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_CASE_FOL
DING'] = 0
;
|
331 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_LINEFEED
_BREAK'] =
0;
|
|
331 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_LINEFEED
_BREAK'] =
0;
|
332 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TAB_BREA
K'] = 0;
|
|
332 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TAB_BREA
K'] = 0;
|
333 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_PARSED']
= 0;
|
|
333 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_PARSED']
= 0;
|
334 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_UNPARSED'
] = 0;
|
|
334 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_UNPARSED'
] = 0;
|
335 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_STRIP_ES
CAPES'] =
0;
|
|
335 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_STRIP_ES
CAPES'] =
0;
|
336 |
|
}
|
|
336 |
|
}
|
337 |
|
|
|
337 |
|
|
338 |
|
/**
|
|
338 |
|
/**
|
339 |
|
* Retu
rns a stri
ng from th
e current
position u
ntil the f
irst insta
nce of
|
|
339 |
|
* Retu
rns a stri
ng from th
e current
position u
ntil the f
irst insta
nce of
|
340 |
|
* one
of the cha
racters in
the suppl
ied string
argument
|
|
340 |
|
* one
of the cha
racters in
the suppl
ied string
argument
|
341 |
|
* @par
am string
string to
search unt
il
|
|
341 |
|
* @par
am string
string to
search unt
il
|
342 |
|
* @acc
ess protec
ted
|
|
342 |
|
* @acc
ess protec
ted
|
343 |
|
* @ret
urn string
|
|
343 |
|
* @ret
urn string
|
344 |
|
*/
|
|
344 |
|
*/
|
345 |
|
functi
on scanUnt
ilCharacte
rs($string
) {
|
|
345 |
|
functi
on scanUnt
ilCharacte
rs($string
) {
|
346 |
|
$s
tartpos =
$this->pos
ition;
|
|
346 |
|
$s
tartpos =
$this->pos
ition;
|
347 |
|
wh
ile ($this
->position
< $this->
length &&
strpos($st
ring, $thi
s->rawtext
{$this->po
sition}) =
== FALSE)
{
|
|
347 |
|
wh
ile ($this
->position
< $this->
length &&
strpos($st
ring, $thi
s->rawtext
{$this->po
sition}) =
== FALSE)
{
|
348 |
|
$this->p
osition++;
|
|
348 |
|
$this->p
osition++;
|
349 |
|
}
|
|
349 |
|
}
|
350 |
|
re
turn subst
r($this->r
awtext, $s
tartpos, $
this->posi
tion - $st
artpos);
|
|
350 |
|
re
turn subst
r($this->r
awtext, $s
tartpos, $
this->posi
tion - $st
artpos);
|
351 |
|
}
|
|
351 |
|
}
|
352 |
|
|
|
352 |
|
|
353 |
|
/**
|
|
353 |
|
/**
|
354 |
|
* Move
s the posi
tion forwa
rd past an
y whitespa
ce charact
ers
|
|
354 |
|
* Move
s the posi
tion forwa
rd past an
y whitespa
ce charact
ers
|
355 |
|
* @acc
ess protec
ted
|
|
355 |
|
* @acc
ess protec
ted
|
356 |
|
* @ret
urn void
|
|
356 |
|
* @ret
urn void
|
357 |
|
*/
|
|
357 |
|
*/
|
358 |
|
functi
on ignoreW
hitespace(
) {
|
|
358 |
|
functi
on ignoreW
hitespace(
) {
|
359 |
|
wh
ile ($this
->position
< $this->
length &&
|
|
359 |
|
wh
ile ($this
->position
< $this->
length &&
|
360 |
|
strpos("
\n\r\t",
$this->raw
text{$this
->position
}) !== FAL
SE) {
|
|
360 |
|
strpos("
\n\r\t",
$this->raw
text{$this
->position
}) !== FAL
SE) {
|
361 |
|
$this->p
osition++;
|
|
361 |
|
$this->p
osition++;
|
362 |
|
}
|
|
362 |
|
}
|
363 |
|
}
|
|
363 |
|
}
|
364 |
|
|
|
364 |
|
|
365 |
|
/**
|
|
365 |
|
/**
|
366 |
|
* Begi
ns the par
sing opera
tion, sett
ing up the
unparsed
XML entiti
es
|
|
366 |
|
* Begi
ns the par
sing opera
tion, sett
ing up the
unparsed
XML entiti
es
|
367 |
|
* deco
rator if n
ecessary t
hen delega
ting furth
er work to
parent
|
|
367 |
|
* deco
rator if n
ecessary t
hen delega
ting furth
er work to
parent
|
368 |
|
* @par
am string
XML docume
nt to pars
e
|
|
368 |
|
* @par
am string
XML docume
nt to pars
e
|
369 |
|
* @acc
ess protec
ted
|
|
369 |
|
* @acc
ess protec
ted
|
370 |
|
* @ret
urn void
|
|
370 |
|
* @ret
urn void
|
371 |
|
*/
|
|
371 |
|
*/
|
372 |
|
functi
on parse($
data) {
|
|
372 |
|
functi
on parse($
data) {
|
373 |
|
pa
rent::pars
e($data);
|
|
373 |
|
pa
rent::pars
e($data);
|
374 |
|
}
|
|
374 |
|
}
|
375 |
|
}
|
|
375 |
|
}
|
376 |
|
|
|
376 |
|
|
377 |
|
/**
|
|
377 |
|
/**
|
378 |
|
* Parser f
or PHP Ver
sions equa
l to or gr
eater than
4.3.0. Us
es a faste
r
|
|
378 |
|
* Parser f
or PHP Ver
sions equa
l to or gr
eater than
4.3.0. Us
es a faste
r
|
379 |
|
* parsing
mechanism
than the e
quivalent
PHP < 4.3.
0 subclass
of StateP
arser
|
|
379 |
|
* parsing
mechanism
than the e
quivalent
PHP < 4.3.
0 subclass
of StateP
arser
|
380 |
|
* @package
XML_HTMLS
ax3
|
|
380 |
|
* @package
XML_HTMLS
ax3
|
381 |
|
* @access
protected
|
|
381 |
|
* @access
protected
|
382 |
|
* @see XML
_HTMLSax3_
StateParse
r_Lt430
|
|
382 |
|
* @see XML
_HTMLSax3_
StateParse
r_Lt430
|
383 |
|
*/
|
|
383 |
|
*/
|
384 |
|
class XML_
HTMLSax3_S
tateParser
_Gtet430 e
xtends XML
_HTMLSax3_
StateParse
r {
|
|
384 |
|
class XML_
HTMLSax3_S
tateParser
_Gtet430 e
xtends XML
_HTMLSax3_
StateParse
r {
|
385 |
|
/**
|
|
385 |
|
/**
|
386 |
|
* Cons
tructs XML
_HTMLSax3_
StateParse
r_Gtet430
defining a
vailable
|
|
386 |
|
* Cons
tructs XML
_HTMLSax3_
StateParse
r_Gtet430
defining a
vailable
|
387 |
|
* pars
er options
|
|
387 |
|
* pars
er options
|
388 |
|
* @var
XML_HTMLS
ax3 instan
ce of user
front end
class
|
|
388 |
|
* @var
XML_HTMLS
ax3 instan
ce of user
front end
class
|
389 |
|
* @acc
ess protec
ted
|
|
389 |
|
* @acc
ess protec
ted
|
390 |
|
*/
|
|
390 |
|
*/
|
391 |
|
functi
on XML_HTM
LSax3_Stat
eParser_Gt
et430(& $h
tmlsax) {
|
|
391 |
|
functi
on XML_HTM
LSax3_Stat
eParser_Gt
et430(& $h
tmlsax) {
|
392 |
|
pa
rent::XML_
HTMLSax3_S
tateParser
($htmlsax)
;
|
|
392 |
|
pa
rent::XML_
HTMLSax3_S
tateParser
($htmlsax)
;
|
393 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TRIM_DAT
A_NODES']
= 0;
|
|
393 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TRIM_DAT
A_NODES']
= 0;
|
394 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_CASE_FOL
DING'] = 0
;
|
|
394 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_CASE_FOL
DING'] = 0
;
|
395 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_LINEFEED
_BREAK'] =
0;
|
|
395 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_LINEFEED
_BREAK'] =
0;
|
396 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TAB_BREA
K'] = 0;
|
|
396 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_TAB_BREA
K'] = 0;
|
397 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_PARSED']
= 0;
|
|
397 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_PARSED']
= 0;
|
398 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_UNPARSED'
] = 0;
|
|
398 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_ENTITIES
_UNPARSED'
] = 0;
|
399 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_STRIP_ES
CAPES'] =
0;
|
|
399 |
|
$t
his->parse
r_options[
'XML_OPTIO
N_STRIP_ES
CAPES'] =
0;
|
400 |
|
}
|
|
400 |
|
}
|
401 |
|
/**
|
|
401 |
|
/**
|
402 |
|
* Retu
rns a stri
ng from th
e current
position u
ntil the f
irst insta
nce of
|
|
402 |
|
* Retu
rns a stri
ng from th
e current
position u
ntil the f
irst insta
nce of
|
403 |
|
* one
of the cha
racters in
the suppl
ied string
argument.
|
|
403 |
|
* one
of the cha
racters in
the suppl
ied string
argument.
|
404 |
|
* @par
am string
string to
search unt
il
|
|
404 |
|
* @par
am string
string to
search unt
il
|
405 |
|
* @acc
ess protec
ted
|
|
405 |
|
* @acc
ess protec
ted
|
406 |
|
* @ret
urn string
|
|
406 |
|
* @ret
urn string
|
407 |
|
*/
|
|
407 |
|
*/
|
408 |
|
functi
on scanUnt
ilCharacte
rs($string
) {
|
|
408 |
|
functi
on scanUnt
ilCharacte
rs($string
) {
|
409 |
|
$s
tartpos =
$this->pos
ition;
|
|
409 |
|
$s
tartpos =
$this->pos
ition;
|
410 |
|
$l
ength = st
rcspn($thi
s->rawtext
, $string,
$startpos
);
|
|
410 |
|
$l
ength = st
rcspn($thi
s->rawtext
, $string,
$startpos
);
|
411 |
|
$t
his->posit
ion += $le
ngth;
|
|
411 |
|
$t
his->posit
ion += $le
ngth;
|
412 |
|
re
turn subst
r($this->r
awtext, $s
tartpos, $
length);
|
|
412 |
|
re
turn subst
r($this->r
awtext, $s
tartpos, $
length);
|
413 |
|
}
|
|
413 |
|
}
|
414 |
|
|
|
414 |
|
|
415 |
|
/**
|
|
415 |
|
/**
|
416 |
|
* Move
s the posi
tion forwa
rd past an
y whitespa
ce charact
ers
|
|
416 |
|
* Move
s the posi
tion forwa
rd past an
y whitespa
ce charact
ers
|
417 |
|
* @acc
ess protec
ted
|
|
417 |
|
* @acc
ess protec
ted
|
418 |
|
* @ret
urn void
|
|
418 |
|
* @ret
urn void
|
419 |
|
*/
|
|
419 |
|
*/
|
420 |
|
functi
on ignoreW
hitespace(
) {
|
|
420 |
|
functi
on ignoreW
hitespace(
) {
|
421 |
|
$t
his->posit
ion += str
spn($this-
>rawtext,
" \n\r\t",
$this->po
sition);
|
|
421 |
|
$t
his->posit
ion += str
spn($this-
>rawtext,
" \n\r\t",
$this->po
sition);
|
422 |
|
}
|
|
422 |
|
}
|
423 |
|
|
|
423 |
|
|
424 |
|
/**
|
|
424 |
|
/**
|
425 |
|
* Begi
ns the par
sing opera
tion, sett
ing up the
parsed an
d unparsed
|
|
425 |
|
* Begi
ns the par
sing opera
tion, sett
ing up the
parsed an
d unparsed
|
426 |
|
* XML
entity dec
orators if
necessary
then dele
gating fur
ther work
|
|
426 |
|
* XML
entity dec
orators if
necessary
then dele
gating fur
ther work
|
427 |
|
* to p
arent
|
|
427 |
|
* to p
arent
|
428 |
|
* @par
am string
XML docume
nt to pars
e
|
|
428 |
|
* @par
am string
XML docume
nt to pars
e
|
429 |
|
* @acc
ess protec
ted
|
|
429 |
|
* @acc
ess protec
ted
|
430 |
|
* @ret
urn void
|
|
430 |
|
* @ret
urn void
|
431 |
|
*/
|
|
431 |
|
*/
|
432 |
|
functi
on parse($
data) {
|
|
432 |
|
functi
on parse($
data) {
|
433 |
|
pa
rent::pars
e($data);
|
|
433 |
|
pa
rent::pars
e($data);
|
434 |
|
}
|
|
434 |
|
}
|
435 |
|
}
|
|
435 |
|
}
|
436 |
|
|
|
436 |
|
|
437 |
|
/**
|
|
437 |
|
/**
|
438 |
|
* Default
NullHandle
r for meth
ods which
were not s
et by user
|
|
438 |
|
* Default
NullHandle
r for meth
ods which
were not s
et by user
|
439 |
|
* @package
XML_HTMLS
ax3
|
|
439 |
|
* @package
XML_HTMLS
ax3
|
440 |
|
* @access
protected
|
|
440 |
|
* @access
protected
|
441 |
|
*/
|
|
441 |
|
*/
|
442 |
|
class XML_
HTMLSax3_N
ullHandler
{
|
|
442 |
|
class XML_
HTMLSax3_N
ullHandler
{
|
443 |
|
/**
|
|
443 |
|
/**
|
444 |
|
* Gene
ric handle
r method w
hich does
nothing
|
|
444 |
|
* Gene
ric handle
r method w
hich does
nothing
|
445 |
|
* @acc
ess protec
ted
|
|
445 |
|
* @acc
ess protec
ted
|
446 |
|
* @ret
urn void
|
|
446 |
|
* @ret
urn void
|
447 |
|
*/
|
|
447 |
|
*/
|
448 |
|
functi
on DoNothi
ng() {
|
|
448 |
|
functi
on DoNothi
ng() {
|
449 |
|
}
|
|
449 |
|
}
|
450 |
|
}
|
|
450 |
|
}
|
451 |
|
|
|
451 |
|
|
452 |
|
/**
|
|
452 |
|
/**
|
453 |
|
* User int
erface cla
ss. All us
er calls s
hould only
be made t
o this cla
ss
|
|
453 |
|
* User int
erface cla
ss. All us
er calls s
hould only
be made t
o this cla
ss
|
454 |
|
* @package
XML_HTMLS
ax3
|
|
454 |
|
* @package
XML_HTMLS
ax3
|
455 |
|
* @access
public
|
|
455 |
|
* @access
public
|
456 |
|
*/
|
|
456 |
|
*/
|
457 |
|
class XML_
HTMLSax3 {
|
|
457 |
|
class XML_
HTMLSax3 {
|
458 |
|
/**
|
|
458 |
|
/**
|
459 |
|
* Inst
ance of co
ncrete sub
class of X
ML_HTMLSax
3_StatePar
ser
|
|
459 |
|
* Inst
ance of co
ncrete sub
class of X
ML_HTMLSax
3_StatePar
ser
|
460 |
|
* @var
XML_HTMLS
ax3_StateP
arser
|
|
460 |
|
* @var
XML_HTMLS
ax3_StateP
arser
|
461 |
|
* @acc
ess privat
e
|
|
461 |
|
* @acc
ess privat
e
|
462 |
|
*/
|
|
462 |
|
*/
|
463 |
|
var $s
tate_parse
r;
|
|
463 |
|
var $s
tate_parse
r;
|
464 |
|
|
|
464 |
|
|
465 |
|
/**
|
|
465 |
|
/**
|
466 |
|
* Cons
tructs XML
_HTMLSax3
selecting
concrete S
tateParser
subclass
|
|
466 |
|
* Cons
tructs XML
_HTMLSax3
selecting
concrete S
tateParser
subclass
|
467 |
|
* depe
nding on P
HP version
being use
d as well
as setting
the defau
lt
|
|
467 |
|
* depe
nding on P
HP version
being use
d as well
as setting
the defau
lt
|
468 |
|
* Null
Handler fo
r all call
backs<br /
>
|
|
468 |
|
* Null
Handler fo
r all call
backs<br /
>
|
469 |
|
* <b>E
xample:</b
>
|
|
469 |
|
* <b>E
xample:</b
>
|
470 |
|
* <pre
>
|
|
470 |
|
* <pre
>
|
471 |
|
* $myH
andler = &
new MyHan
dler();
|
|
471 |
|
* $myH
andler = &
new MyHan
dler();
|
472 |
|
* $par
ser = new
XML_HTMLSa
x3();
|
|
472 |
|
* $par
ser = new
XML_HTMLSa
x3();
|
473 |
|
* $par
ser->set_o
bject($myH
andler);
|
|
473 |
|
* $par
ser->set_o
bject($myH
andler);
|
474 |
|
* $par
ser->set_o
ption('XML
_OPTION_CA
SE_FOLDING
');
|
|
474 |
|
* $par
ser->set_o
ption('XML
_OPTION_CA
SE_FOLDING
');
|
475 |
|
* $par
ser->set_e
lement_han
dler('myOp
enHandler'
,'myCloseH
andler');
|
|
475 |
|
* $par
ser->set_e
lement_han
dler('myOp
enHandler'
,'myCloseH
andler');
|
476 |
|
* $par
ser->set_d
ata_handle
r('myDataH
andler');
|
|
476 |
|
* $par
ser->set_d
ata_handle
r('myDataH
andler');
|
477 |
|
* $par
ser->parse
r($xml);
|
|
477 |
|
* $par
ser->parse
r($xml);
|
478 |
|
* </pr
e>
|
|
478 |
|
* </pr
e>
|
479 |
|
* @acc
ess public
|
|
479 |
|
* @acc
ess public
|
480 |
|
*/
|
|
480 |
|
*/
|
481 |
|
functi
on XML_HTM
LSax3() {
|
|
481 |
|
functi
on XML_HTM
LSax3() {
|
482 |
|
if
(version_
compare(ph
pversion()
, '4.3', '
ge')) {
|
|
482 |
|
if
(version_
compare(ph
pversion()
, '4.3', '
ge')) {
|
483 |
|
$this->s
tate_parse
r =& new X
ML_HTMLSax
3_StatePar
ser_Gtet43
0($this);
|
|
483 |
|
$this->s
tate_parse
r =& new X
ML_HTMLSax
3_StatePar
ser_Gtet43
0($this);
|
484 |
|
}
else {
|
|
484 |
|
}
else {
|
485 |
|
$this->s
tate_parse
r =& new X
ML_HTMLSax
3_StatePar
ser_Lt430(
$this);
|
|
485 |
|
$this->s
tate_parse
r =& new X
ML_HTMLSax
3_StatePar
ser_Lt430(
$this);
|
486 |
|
}
|
|
486 |
|
}
|
487 |
|
$n
ullhandler
=& new XM
L_HTMLSax3
_NullHandl
er();
|
|
487 |
|
$n
ullhandler
=& new XM
L_HTMLSax3
_NullHandl
er();
|
488 |
|
$t
his->set_o
bject($nul
lhandler);
|
|
488 |
|
$t
his->set_o
bject($nul
lhandler);
|
489 |
|
$t
his->set_e
lement_han
dler('DoNo
thing', 'D
oNothing')
;
|
|
489 |
|
$t
his->set_e
lement_han
dler('DoNo
thing', 'D
oNothing')
;
|
490 |
|
$t
his->set_d
ata_handle
r('DoNothi
ng');
|
|
490 |
|
$t
his->set_d
ata_handle
r('DoNothi
ng');
|
491 |
|
$t
his->set_p
i_handler(
'DoNothing
');
|
|
491 |
|
$t
his->set_p
i_handler(
'DoNothing
');
|
492 |
|
$t
his->set_j
asp_handle
r('DoNothi
ng');
|
|
492 |
|
$t
his->set_j
asp_handle
r('DoNothi
ng');
|
493 |
|
$t
his->set_e
scape_hand
ler('DoNot
hing');
|
|
493 |
|
$t
his->set_e
scape_hand
ler('DoNot
hing');
|
494 |
|
}
|
|
494 |
|
}
|
495 |
|
|
|
495 |
|
|
496 |
|
/**
|
|
496 |
|
/**
|
497 |
|
* Sets
the user
defined ha
ndler obje
ct. Return
s a PEAR E
rror
|
|
497 |
|
* Sets
the user
defined ha
ndler obje
ct. Return
s a PEAR E
rror
|
498 |
|
* if s
upplied ar
gument is
not an obj
ect.
|
|
498 |
|
* if s
upplied ar
gument is
not an obj
ect.
|
499 |
|
* @par
am object
handler ob
ject conta
ining SAX
callback m
ethods
|
|
499 |
|
* @par
am object
handler ob
ject conta
ining SAX
callback m
ethods
|
500 |
|
* @acc
ess public
|
|
500 |
|
* @acc
ess public
|
501 |
|
* @ret
urn mixed
|
|
501 |
|
* @ret
urn mixed
|
502 |
|
*/
|
|
502 |
|
*/
|
503 |
|
functi
on set_obj
ect(&$obje
ct) {
|
|
503 |
|
functi
on set_obj
ect(&$obje
ct) {
|
504 |
|
if
( is_obje
ct($object
) ) {
|
|
504 |
|
if
( is_obje
ct($object
) ) {
|
505 |
|
$this->s
tate_parse
r->handler
_default =
& $object;
|
|
505 |
|
$this->s
tate_parse
r->handler
_default =
& $object;
|
506 |
|
return t
rue;
|
|
506 |
|
return t
rue;
|
507 |
|
}
else {
|
|
507 |
|
}
else {
|
508 |
|
require_
once('PEAR
.php');
|
|
508 |
|
require_
once('PEAR
.php');
|
509 |
|
PEAR::ra
iseError('
XML_HTMLSa
x3::set_ob
ject requi
res '.
|
|
509 |
|
PEAR::ra
iseError('
XML_HTMLSa
x3::set_ob
ject requi
res '.
|
510 |
|
'an
object ins
tance');
|
|
510 |
|
'an
object ins
tance');
|
511 |
|
}
|
|
511 |
|
}
|
512 |
|
}
|
|
512 |
|
}
|
513 |
|
|
|
513 |
|
|
514 |
|
/**
|
|
514 |
|
/**
|
515 |
|
* Sets
a parser
option. By
default a
ll options
are switc
hed off.
|
|
515 |
|
* Sets
a parser
option. By
default a
ll options
are switc
hed off.
|
516 |
|
* Retu
rns a PEAR
Error if
option is
invalid<br
/>
|
|
516 |
|
* Retu
rns a PEAR
Error if
option is
invalid<br
/>
|
517 |
|
* <b>A
vailable o
ptions:</b
>
|
|
517 |
|
* <b>A
vailable o
ptions:</b
>
|
518 |
|
* <ul>
|
|
518 |
|
* <ul>
|
519 |
|
* <li>
XML_OPTION
_TRIM_DATA
_NODES: tr
im whitesp
ace off th
e beginnin
g
|
|
519 |
|
* <li>
XML_OPTION
_TRIM_DATA
_NODES: tr
im whitesp
ace off th
e beginnin
g
|
520 |
|
* and
end of dat
a passed t
o the data
handler</
li>
|
|
520 |
|
* and
end of dat
a passed t
o the data
handler</
li>
|
521 |
|
* <li>
XML_OPTION
_LINEFEED_
BREAK: lin
efeeds res
ult in add
itional da
ta
|
|
521 |
|
* <li>
XML_OPTION
_LINEFEED_
BREAK: lin
efeeds res
ult in add
itional da
ta
|
522 |
|
* hand
ler calls<
/li>
|
|
522 |
|
* hand
ler calls<
/li>
|
523 |
|
* <li>
XML_OPTION
_TAB_BREAK
: tabs res
ult in add
itional da
ta handler
|
|
523 |
|
* <li>
XML_OPTION
_TAB_BREAK
: tabs res
ult in add
itional da
ta handler
|
524 |
|
* call
s</li>
|
|
524 |
|
* call
s</li>
|
525 |
|
* <li>
XML_OPTION
_ENTITIES_
UNPARSED:
XML entiti
es are ret
urned as
|
|
525 |
|
* <li>
XML_OPTION
_ENTITIES_
UNPARSED:
XML entiti
es are ret
urned as
|
526 |
|
* sepe
rate data
handler ca
lls in unp
arsed form
</li>
|
|
526 |
|
* sepe
rate data
handler ca
lls in unp
arsed form
</li>
|
527 |
|
* <li>
XML_OPTION
_ENTITIES_
PARSED: (P
HP 4.3.0+
only) XML
entities a
re
|
|
527 |
|
* <li>
XML_OPTION
_ENTITIES_
PARSED: (P
HP 4.3.0+
only) XML
entities a
re
|
528 |
|
* retu
rned as se
perate dat
a handler
calls and
are parsed
with
|
|
528 |
|
* retu
rned as se
perate dat
a handler
calls and
are parsed
with
|
529 |
|
* PHP'
s html_ent
ity_decode
() functio
n</li>
|
|
529 |
|
* PHP'
s html_ent
ity_decode
() functio
n</li>
|
530 |
|
* <li>
XML_OPTION
_STRIP_ESC
APES: stri
ps out the
-- -- com
ment marke
rs
|
|
530 |
|
* <li>
XML_OPTION
_STRIP_ESC
APES: stri
ps out the
-- -- com
ment marke
rs
|
531 |
|
* or C
DATA marku
p inside a
n XML esca
pe, if fou
nd.</li>
|
|
531 |
|
* or C
DATA marku
p inside a
n XML esca
pe, if fou
nd.</li>
|
532 |
|
* </ul
>
|
|
532 |
|
* </ul
>
|
533 |
|
* To g
et HTMLSax
to behave
in the sa
me way as
the native
PHP SAX p
arser,
|
|
533 |
|
* To g
et HTMLSax
to behave
in the sa
me way as
the native
PHP SAX p
arser,
|
534 |
|
* usin
g it's def
ault state
, you need
to switch
on XML_OP
TION_LINEF
EED_BREAK,
|
|
534 |
|
* usin
g it's def
ault state
, you need
to switch
on XML_OP
TION_LINEF
EED_BREAK,
|
535 |
|
* XML_
OPTION_ENT
ITIES_PARS
ED and XML
_OPTION_CA
SE_FOLDING
|
|
535 |
|
* XML_
OPTION_ENT
ITIES_PARS
ED and XML
_OPTION_CA
SE_FOLDING
|
536 |
|
* @par
am string
name of pa
rser optio
n
|
|
536 |
|
* @par
am string
name of pa
rser optio
n
|
537 |
|
* @par
am int (op
tional) 1
to switch
on, 0 for
off
|
|
537 |
|
* @par
am int (op
tional) 1
to switch
on, 0 for
off
|
538 |
|
* @acc
ess public
|
|
538 |
|
* @acc
ess public
|
539 |
|
* @ret
urn boolea
n
|
|
539 |
|
* @ret
urn boolea
n
|
540 |
|
*/
|
|
540 |
|
*/
|
541 |
|
functi
on set_opt
ion($name,
$value=1)
{
|
|
541 |
|
functi
on set_opt
ion($name,
$value=1)
{
|
542 |
|
if
( array_k
ey_exists(
$name,$thi
s->state_p
arser->par
ser_option
s) ) {
|
|
542 |
|
if
( array_k
ey_exists(
$name,$thi
s->state_p
arser->par
ser_option
s) ) {
|
543 |
|
$this->s
tate_parse
r->parser_
options[$n
ame] = $va
lue;
|
|
543 |
|
$this->s
tate_parse
r->parser_
options[$n
ame] = $va
lue;
|
544 |
|
return t
rue;
|
|
544 |
|
return t
rue;
|
545 |
|
}
else {
|
|
545 |
|
}
else {
|
546 |
|
require_
once('PEAR
.php');
|
|
546 |
|
require_
once('PEAR
.php');
|
547 |
|
PEAR::ra
iseError('
XML_HTMLSa
x3::set_op
tion('.$na
me.') ille
gal');
|
|
547 |
|
PEAR::ra
iseError('
XML_HTMLSa
x3::set_op
tion('.$na
me.') ille
gal');
|
548 |
|
}
|
|
548 |
|
}
|
549 |
|
}
|
|
549 |
|
}
|
550 |
|
|
|
550 |
|
|
551 |
|
/**
|
|
551 |
|
/**
|
552 |
|
* Sets
the data
handler me
thod which
deals wit
h the cont
ents of XM
L
|
|
552 |
|
* Sets
the data
handler me
thod which
deals wit
h the cont
ents of XM
L
|
553 |
|
* elem
ents.<br /
>
|
|
553 |
|
* elem
ents.<br /
>
|
554 |
|
* The
handler me
thod must
accept two
arguments
, the firs
t being an
|
|
554 |
|
* The
handler me
thod must
accept two
arguments
, the firs
t being an
|
555 |
|
* inst
ance of XM
L_HTMLSax3
and the s
econd bein
g the cont
ents of an
|
|
555 |
|
* inst
ance of XM
L_HTMLSax3
and the s
econd bein
g the cont
ents of an
|
556 |
|
* XML
element e.
g.
|
|
556 |
|
* XML
element e.
g.
|
557 |
|
* <pre
>
|
|
557 |
|
* <pre
>
|
558 |
|
* func
tion myDat
aHander(&
$parser,$d
ata){}
|
|
558 |
|
* func
tion myDat
aHander(&
$parser,$d
ata){}
|
559 |
|
* </pr
e>
|
|
559 |
|
* </pr
e>
|
560 |
|
* @par
am string
name of me
thod
|
|
560 |
|
* @par
am string
name of me
thod
|
561 |
|
* @acc
ess public
|
|
561 |
|
* @acc
ess public
|
562 |
|
* @ret
urn void
|
|
562 |
|
* @ret
urn void
|
563 |
|
* @see
set_objec
t
|
|
563 |
|
* @see
set_objec
t
|
564 |
|
*/
|
|
564 |
|
*/
|
565 |
|
functi
on set_dat
a_handler(
$data_meth
od) {
|
|
565 |
|
functi
on set_dat
a_handler(
$data_meth
od) {
|
566 |
|
$t
his->state
_parser->h
andler_obj
ect_data =
& $this->s
tate_parse
r->handler
_default;
|
|
566 |
|
$t
his->state
_parser->h
andler_obj
ect_data =
& $this->s
tate_parse
r->handler
_default;
|
567 |
|
$t
his->state
_parser->h
andler_met
hod_data =
$data_met
hod;
|
|
567 |
|
$t
his->state
_parser->h
andler_met
hod_data =
$data_met
hod;
|
568 |
|
}
|
|
568 |
|
}
|
569 |
|
|
|
569 |
|
|
570 |
|
/**
|
|
570 |
|
/**
|
571 |
|
* Sets
the open
and close
tag handle
rs
|
|
571 |
|
* Sets
the open
and close
tag handle
rs
|
572 |
|
* <br
/>The open
handler m
ethod must
accept th
ree argume
nts; the p
arser,
|
|
572 |
|
* <br
/>The open
handler m
ethod must
accept th
ree argume
nts; the p
arser,
|
573 |
|
* the
tag name a
nd an arra
y of attri
butes e.g.
|
|
573 |
|
* the
tag name a
nd an arra
y of attri
butes e.g.
|
574 |
|
* <pre
>
|
|
574 |
|
* <pre
>
|
575 |
|
* func
tion myOpe
nHander(&
$parser,$t
agname,$at
trs=array(
)){}
|
|
575 |
|
* func
tion myOpe
nHander(&
$parser,$t
agname,$at
trs=array(
)){}
|
576 |
|
* </pr
e>
|
|
576 |
|
* </pr
e>
|
577 |
|
* The
close hand
ler method
must acce
pt two arg
uments; th
e parser a
nd
|
|
577 |
|
* The
close hand
ler method
must acce
pt two arg
uments; th
e parser a
nd
|
578 |
|
* the
tag name e
.g.
|
|
578 |
|
* the
tag name e
.g.
|
579 |
|
* <pre
>
|
|
579 |
|
* <pre
>
|
580 |
|
* func
tion myClo
seHander(&
$parser,$
tagname){}
|
|
580 |
|
* func
tion myClo
seHander(&
$parser,$
tagname){}
|
581 |
|
* </pr
e>
|
|
581 |
|
* </pr
e>
|
582 |
|
* @par
am string
name of op
en method
|
|
582 |
|
* @par
am string
name of op
en method
|
583 |
|
* @par
am string
name of cl
ose method
|
|
583 |
|
* @par
am string
name of cl
ose method
|
584 |
|
* @acc
ess public
|
|
584 |
|
* @acc
ess public
|
585 |
|
* @ret
urn void
|
|
585 |
|
* @ret
urn void
|
586 |
|
* @see
set_objec
t
|
|
586 |
|
* @see
set_objec
t
|
587 |
|
*/
|
|
587 |
|
*/
|
588 |
|
functi
on set_ele
ment_handl
er($openin
g_method,
$closing_m
ethod) {
|
|
588 |
|
functi
on set_ele
ment_handl
er($openin
g_method,
$closing_m
ethod) {
|
589 |
|
$t
his->state
_parser->h
andler_obj
ect_elemen
t =& $this
->state_pa
rser->hand
ler_defaul
t;
|
|
589 |
|
$t
his->state
_parser->h
andler_obj
ect_elemen
t =& $this
->state_pa
rser->hand
ler_defaul
t;
|
590 |
|
$t
his->state
_parser->h
andler_met
hod_openin
g = $openi
ng_method;
|
|
590 |
|
$t
his->state
_parser->h
andler_met
hod_openin
g = $openi
ng_method;
|
591 |
|
$t
his->state
_parser->h
andler_met
hod_closin
g = $closi
ng_method;
|
|
591 |
|
$t
his->state
_parser->h
andler_met
hod_closin
g = $closi
ng_method;
|
592 |
|
}
|
|
592 |
|
}
|
593 |
|
|
|
593 |
|
|
594 |
|
/**
|
|
594 |
|
/**
|
595 |
|
* Sets
the proce
ssing inst
ruction ha
ndler meth
od e.g. fo
r PHP open
|
|
595 |
|
* Sets
the proce
ssing inst
ruction ha
ndler meth
od e.g. fo
r PHP open
|
596 |
|
* and
close tags
<br />
|
|
596 |
|
* and
close tags
<br />
|
597 |
|
* The
handler me
thod must
accept thr
ee argumen
ts; the pa
rser, the
|
|
597 |
|
* The
handler me
thod must
accept thr
ee argumen
ts; the pa
rser, the
|
598 |
|
* PI t
arget and
data insid
e the PI
|
|
598 |
|
* PI t
arget and
data insid
e the PI
|
599 |
|
* <pre
>
|
|
599 |
|
* <pre
>
|
600 |
|
* func
tion myPIH
ander(& $p
arser,$tar
get, $data
){}
|
|
600 |
|
* func
tion myPIH
ander(& $p
arser,$tar
get, $data
){}
|
601 |
|
* </pr
e>
|
|
601 |
|
* </pr
e>
|
602 |
|
* @par
am string
name of me
thod
|
|
602 |
|
* @par
am string
name of me
thod
|
603 |
|
* @acc
ess public
|
|
603 |
|
* @acc
ess public
|
604 |
|
* @ret
urn void
|
|
604 |
|
* @ret
urn void
|
605 |
|
* @see
set_objec
t
|
|
605 |
|
* @see
set_objec
t
|
606 |
|
*/
|
|
606 |
|
*/
|
607 |
|
functi
on set_pi_
handler($p
i_method)
{
|
|
607 |
|
functi
on set_pi_
handler($p
i_method)
{
|
608 |
|
$t
his->state
_parser->h
andler_obj
ect_pi =&
$this->sta
te_parser-
>handler_d
efault;
|
|
608 |
|
$t
his->state
_parser->h
andler_obj
ect_pi =&
$this->sta
te_parser-
>handler_d
efault;
|
609 |
|
$t
his->state
_parser->h
andler_met
hod_pi = $
pi_method;
|
|
609 |
|
$t
his->state
_parser->h
andler_met
hod_pi = $
pi_method;
|
610 |
|
}
|
|
610 |
|
}
|
611 |
|
|
|
611 |
|
|
612 |
|
/**
|
|
612 |
|
/**
|
613 |
|
* Sets
the XML e
scape hand
ler method
e.g. for
comments a
nd doctype
|
|
613 |
|
* Sets
the XML e
scape hand
ler method
e.g. for
comments a
nd doctype
|
614 |
|
* decl
arations<b
r />
|
|
614 |
|
* decl
arations<b
r />
|
615 |
|
* The
handler me
thod must
accept two
arguments
; the pars
er and the
|
|
615 |
|
* The
handler me
thod must
accept two
arguments
; the pars
er and the
|
616 |
|
* cont
ents of th
e escaped
section
|
|
616 |
|
* cont
ents of th
e escaped
section
|
617 |
|
* <pre
>
|
|
617 |
|
* <pre
>
|
618 |
|
* func
tion myEsc
apeHander(
& $parser,
$data){}
|
|
618 |
|
* func
tion myEsc
apeHander(
& $parser,
$data){}
|
619 |
|
* </pr
e>
|
|
619 |
|
* </pr
e>
|
620 |
|
* @par
am string
name of me
thod
|
|
620 |
|
* @par
am string
name of me
thod
|
621 |
|
* @acc
ess public
|
|
621 |
|
* @acc
ess public
|
622 |
|
* @ret
urn void
|
|
622 |
|
* @ret
urn void
|
623 |
|
* @see
set_objec
t
|
|
623 |
|
* @see
set_objec
t
|
624 |
|
*/
|
|
624 |
|
*/
|
625 |
|
functi
on set_esc
ape_handle
r($escape_
method) {
|
|
625 |
|
functi
on set_esc
ape_handle
r($escape_
method) {
|
626 |
|
$t
his->state
_parser->h
andler_obj
ect_escape
=& $this-
>state_par
ser->handl
er_default
;
|
|
626 |
|
$t
his->state
_parser->h
andler_obj
ect_escape
=& $this-
>state_par
ser->handl
er_default
;
|
627 |
|
$t
his->state
_parser->h
andler_met
hod_escape
= $escape
_method;
|
|
627 |
|
$t
his->state
_parser->h
andler_met
hod_escape
= $escape
_method;
|
628 |
|
}
|
|
628 |
|
}
|
629 |
|
|
|
629 |
|
|
630 |
|
/**
|
|
630 |
|
/**
|
631 |
|
* Sets
the JSP/A
SP markup
handler<br
/>
|
|
631 |
|
* Sets
the JSP/A
SP markup
handler<br
/>
|
632 |
|
* The
handler me
thod must
accept two
arguments
; the pars
er and
|
|
632 |
|
* The
handler me
thod must
accept two
arguments
; the pars
er and
|
633 |
|
* body
of the JA
SP tag
|
|
633 |
|
* body
of the JA
SP tag
|
634 |
|
* <pre
>
|
|
634 |
|
* <pre
>
|
635 |
|
* func
tion myJas
pHander(&
$parser, $
data){}
|
|
635 |
|
* func
tion myJas
pHander(&
$parser, $
data){}
|
636 |
|
* </pr
e>
|
|
636 |
|
* </pr
e>
|
637 |
|
* @par
am string
name of me
thod
|
|
637 |
|
* @par
am string
name of me
thod
|
638 |
|
* @acc
ess public
|
|
638 |
|
* @acc
ess public
|
639 |
|
* @ret
urn void
|
|
639 |
|
* @ret
urn void
|
640 |
|
* @see
set_objec
t
|
|
640 |
|
* @see
set_objec
t
|
641 |
|
*/
|
|
641 |
|
*/
|
642 |
|
functi
on set_jas
p_handler
($jasp_met
hod) {
|
|
642 |
|
functi
on set_jas
p_handler
($jasp_met
hod) {
|
643 |
|
$t
his->state
_parser->h
andler_obj
ect_jasp =
& $this->s
tate_parse
r->handler
_default;
|
|
643 |
|
$t
his->state
_parser->h
andler_obj
ect_jasp =
& $this->s
tate_parse
r->handler
_default;
|
644 |
|
$t
his->state
_parser->h
andler_met
hod_jasp =
$jasp_met
hod;
|
|
644 |
|
$t
his->state
_parser->h
andler_met
hod_jasp =
$jasp_met
hod;
|
645 |
|
}
|
|
645 |
|
}
|
646 |
|
|
|
646 |
|
|
647 |
|
/**
|
|
647 |
|
/**
|
648 |
|
* Retu
rns the cu
rrent stri
ng positio
n of the "
cursor" in
side the X
ML
|
|
648 |
|
* Retu
rns the cu
rrent stri
ng positio
n of the "
cursor" in
side the X
ML
|
649 |
|
* docu
ment
|
|
649 |
|
* docu
ment
|
650 |
|
* <br
/>Intended
for use f
rom within
a user de
fined hand
ler called
|
|
650 |
|
* <br
/>Intended
for use f
rom within
a user de
fined hand
ler called
|
651 |
|
* via
the $parse
r referenc
e e.g.
|
|
651 |
|
* via
the $parse
r referenc
e e.g.
|
652 |
|
* <pre
>
|
|
652 |
|
* <pre
>
|
653 |
|
* func
tion myDat
aHandler(&
$parser,$
data) {
|
|
653 |
|
* func
tion myDat
aHandler(&
$parser,$
data) {
|
654 |
|
*
echo( 'Cur
rent posit
ion: '.$pa
rser->get_
current_po
sition() )
;
|
|
654 |
|
*
echo( 'Cur
rent posit
ion: '.$pa
rser->get_
current_po
sition() )
;
|
655 |
|
* }
|
|
655 |
|
* }
|
656 |
|
* </pr
e>
|
|
656 |
|
* </pr
e>
|
657 |
|
* @acc
ess public
|
|
657 |
|
* @acc
ess public
|
658 |
|
* @ret
urn int
|
|
658 |
|
* @ret
urn int
|
659 |
|
* @see
get_lengt
h
|
|
659 |
|
* @see
get_lengt
h
|
660 |
|
*/
|
|
660 |
|
*/
|
661 |
|
functi
on get_cur
rent_posit
ion() {
|
|
661 |
|
functi
on get_cur
rent_posit
ion() {
|
662 |
|
re
turn $this
->state_pa
rser->posi
tion;
|
|
662 |
|
re
turn $this
->state_pa
rser->posi
tion;
|
663 |
|
}
|
|
663 |
|
}
|
664 |
|
|
|
664 |
|
|
665 |
|
/**
|
|
665 |
|
/**
|
666 |
|
* Retu
rns the st
ring lengt
h of the X
ML documen
t being pa
rsed
|
|
666 |
|
* Retu
rns the st
ring lengt
h of the X
ML documen
t being pa
rsed
|
667 |
|
* @acc
ess public
|
|
667 |
|
* @acc
ess public
|
668 |
|
* @ret
urn int
|
|
668 |
|
* @ret
urn int
|
669 |
|
*/
|
|
669 |
|
*/
|
670 |
|
functi
on get_len
gth() {
|
|
670 |
|
functi
on get_len
gth() {
|
671 |
|
re
turn $this
->state_pa
rser->leng
th;
|
|
671 |
|
re
turn $this
->state_pa
rser->leng
th;
|
672 |
|
}
|
|
672 |
|
}
|
673 |
|
|
|
673 |
|
|
674 |
|
/**
|
|
674 |
|
/**
|
675 |
|
* Star
t parsing
some XML
|
|
675 |
|
* Star
t parsing
some XML
|
676 |
|
* @par
am string
XML docume
nt
|
|
676 |
|
* @par
am string
XML docume
nt
|
677 |
|
* @acc
ess public
|
|
677 |
|
* @acc
ess public
|
678 |
|
* @ret
urn void
|
|
678 |
|
* @ret
urn void
|
679 |
|
*/
|
|
679 |
|
*/
|
680 |
|
functi
on parse($
data) {
|
|
680 |
|
functi
on parse($
data) {
|
681 |
|
$t
his->state
_parser->p
arse($data
);
|
|
681 |
|
$t
his->state
_parser->p
arse($data
);
|
682 |
|
}
|
|
682 |
|
}
|
683 |
|
}
|
|
683 |
|
}
|
684 |
|
?>
|
|
684 |
|
?>
|