|
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 |
| package org.w3c.tidy; |
|
55 |
| |
|
56 |
| import org.w3c.dom.Attr; |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| public class AttVal extends Object implements Cloneable |
|
67 |
| { |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| protected AttVal next; |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| protected Attribute dict; |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| protected Node asp; |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| protected Node php; |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| protected int delim; |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| protected String attribute; |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| protected String value; |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| protected Attr adapter; |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
39
| public AttVal()
|
|
113 |
| { |
|
114 |
39
| super();
|
|
115 |
| } |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
180
| public AttVal(AttVal next, Attribute dict, int delim, String attribute, String value)
|
|
126 |
| { |
|
127 |
180
| this.next = next;
|
|
128 |
180
| this.dict = dict;
|
|
129 |
180
| this.delim = delim;
|
|
130 |
180
| this.attribute = attribute;
|
|
131 |
180
| this.value = value;
|
|
132 |
| } |
|
133 |
| |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
4993
| public AttVal(AttVal next, Attribute dict, Node asp, Node php, int delim, String attribute, String value)
|
|
145 |
| { |
|
146 |
4993
| this.next = next;
|
|
147 |
4993
| this.dict = dict;
|
|
148 |
4993
| this.asp = asp;
|
|
149 |
4993
| this.php = php;
|
|
150 |
4993
| this.delim = delim;
|
|
151 |
4993
| this.attribute = attribute;
|
|
152 |
4993
| this.value = value;
|
|
153 |
| } |
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
2526
| protected Object clone()
|
|
159 |
| { |
|
160 |
2526
| AttVal av = null;
|
|
161 |
2526
| try
|
|
162 |
| { |
|
163 |
2526
| av = (AttVal) super.clone();
|
|
164 |
| } |
|
165 |
| catch (CloneNotSupportedException e) |
|
166 |
| { |
|
167 |
| |
|
168 |
| } |
|
169 |
| |
|
170 |
2526
| if (this.next != null)
|
|
171 |
| { |
|
172 |
582
| av.next = (AttVal) this.next.clone();
|
|
173 |
| } |
|
174 |
2526
| if (this.asp != null)
|
|
175 |
| { |
|
176 |
0
| av.asp = (Node) this.asp.clone();
|
|
177 |
| } |
|
178 |
2526
| if (this.php != null)
|
|
179 |
| { |
|
180 |
0
| av.php = (Node) this.php.clone();
|
|
181 |
| } |
|
182 |
| |
|
183 |
2526
| return av;
|
|
184 |
| } |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
| |
|
189 |
| |
|
190 |
10
| public boolean isBoolAttribute()
|
|
191 |
| { |
|
192 |
10
| Attribute attr = this.dict;
|
|
193 |
10
| if (attr != null)
|
|
194 |
| { |
|
195 |
10
| if (attr.getAttrchk() == AttrCheckImpl.BOOL)
|
|
196 |
| { |
|
197 |
5
| return true;
|
|
198 |
| } |
|
199 |
| } |
|
200 |
| |
|
201 |
5
| return false;
|
|
202 |
| } |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
| |
|
210 |
581
| void checkLowerCaseAttrValue(Lexer lexer, Node node)
|
|
211 |
| { |
|
212 |
581
| if (this.value == null)
|
|
213 |
| { |
|
214 |
0
| return;
|
|
215 |
| } |
|
216 |
| |
|
217 |
581
| String lowercase = this.value.toLowerCase();
|
|
218 |
| |
|
219 |
581
| if (!this.value.equals(lowercase))
|
|
220 |
| { |
|
221 |
69
| if (lexer.isvoyager)
|
|
222 |
| { |
|
223 |
2
| lexer.report.attrError(lexer, node, this, Report.ATTR_VALUE_NOT_LCASE);
|
|
224 |
| } |
|
225 |
| |
|
226 |
69
| if (lexer.isvoyager || lexer.configuration.lowerLiterals)
|
|
227 |
| { |
|
228 |
69
| this.value = lowercase;
|
|
229 |
| } |
|
230 |
| } |
|
231 |
| } |
|
232 |
| |
|
233 |
| |
|
234 |
| |
|
235 |
| |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
4850
| public Attribute checkAttribute(Lexer lexer, Node node)
|
|
240 |
| { |
|
241 |
4850
| TagTable tt = lexer.configuration.tt;
|
|
242 |
| |
|
243 |
4850
| Attribute attr = this.dict;
|
|
244 |
| |
|
245 |
| |
|
246 |
4850
| if (attr != null)
|
|
247 |
| { |
|
248 |
| |
|
249 |
| |
|
250 |
4825
| if (TidyUtils.toBoolean(attr.getVersions() & Dict.VERS_XML))
|
|
251 |
| { |
|
252 |
6
| if (!(lexer.configuration.xmlTags || lexer.configuration.xmlOut))
|
|
253 |
| { |
|
254 |
1
| lexer.report.attrError(lexer, node, this, Report.XML_ATTRIBUTE_VALUE);
|
|
255 |
| } |
|
256 |
| } |
|
257 |
| |
|
258 |
4819
| else if (attr != AttributeTable.attrTitle || !(node.tag == tt.tagA || node.tag == tt.tagLink))
|
|
259 |
| { |
|
260 |
4817
| lexer.constrainVersion(attr.getVersions());
|
|
261 |
| } |
|
262 |
| |
|
263 |
4825
| if (attr.getAttrchk() != null)
|
|
264 |
| { |
|
265 |
4059
| attr.getAttrchk().check(lexer, node, this);
|
|
266 |
| } |
|
267 |
766
| else if (TidyUtils.toBoolean(this.dict.getVersions() & Dict.VERS_PROPRIETARY))
|
|
268 |
| { |
|
269 |
4
| lexer.report.attrError(lexer, node, this, Report.PROPRIETARY_ATTRIBUTE);
|
|
270 |
| } |
|
271 |
| |
|
272 |
| } |
|
273 |
25
| else if (!lexer.configuration.xmlTags
|
|
274 |
| && !(node.tag == null) |
|
275 |
| && this.asp == null |
|
276 |
| && !(node.tag != null && (TidyUtils.toBoolean(node.tag.versions & Dict.VERS_PROPRIETARY)))) |
|
277 |
| { |
|
278 |
24
| lexer.report.attrError(lexer, node, this, Report.UNKNOWN_ATTRIBUTE);
|
|
279 |
| } |
|
280 |
| |
|
281 |
4850
| return attr;
|
|
282 |
| } |
|
283 |
| |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
| |
|
288 |
0
| protected org.w3c.dom.Attr getAdapter()
|
|
289 |
| { |
|
290 |
0
| if (this.adapter == null)
|
|
291 |
| { |
|
292 |
0
| this.adapter = new DOMAttrImpl(this);
|
|
293 |
| } |
|
294 |
0
| return this.adapter;
|
|
295 |
| } |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
| |
|
300 |
| |
|
301 |
0
| public Node getAsp()
|
|
302 |
| { |
|
303 |
0
| return this.asp;
|
|
304 |
| } |
|
305 |
| |
|
306 |
| |
|
307 |
| |
|
308 |
| |
|
309 |
| |
|
310 |
0
| public void setAsp(Node asp)
|
|
311 |
| { |
|
312 |
0
| this.asp = asp;
|
|
313 |
| } |
|
314 |
| |
|
315 |
| |
|
316 |
| |
|
317 |
| |
|
318 |
| |
|
319 |
0
| public String getAttribute()
|
|
320 |
| { |
|
321 |
0
| return this.attribute;
|
|
322 |
| } |
|
323 |
| |
|
324 |
| |
|
325 |
| |
|
326 |
| |
|
327 |
| |
|
328 |
0
| public void setAttribute(String attribute)
|
|
329 |
| { |
|
330 |
0
| this.attribute = attribute;
|
|
331 |
| } |
|
332 |
| |
|
333 |
| |
|
334 |
| |
|
335 |
| |
|
336 |
| |
|
337 |
0
| public int getDelim()
|
|
338 |
| { |
|
339 |
0
| return this.delim;
|
|
340 |
| } |
|
341 |
| |
|
342 |
| |
|
343 |
| |
|
344 |
| |
|
345 |
| |
|
346 |
0
| public void setDelim(int delim)
|
|
347 |
| { |
|
348 |
0
| this.delim = delim;
|
|
349 |
| } |
|
350 |
| |
|
351 |
| |
|
352 |
| |
|
353 |
| |
|
354 |
| |
|
355 |
0
| public Attribute getDict()
|
|
356 |
| { |
|
357 |
0
| return this.dict;
|
|
358 |
| } |
|
359 |
| |
|
360 |
| |
|
361 |
| |
|
362 |
| |
|
363 |
| |
|
364 |
0
| public void setDict(Attribute dict)
|
|
365 |
| { |
|
366 |
0
| this.dict = dict;
|
|
367 |
| } |
|
368 |
| |
|
369 |
| |
|
370 |
| |
|
371 |
| |
|
372 |
| |
|
373 |
0
| public AttVal getNext()
|
|
374 |
| { |
|
375 |
0
| return this.next;
|
|
376 |
| } |
|
377 |
| |
|
378 |
| |
|
379 |
| |
|
380 |
| |
|
381 |
| |
|
382 |
0
| public void setNext(AttVal next)
|
|
383 |
| { |
|
384 |
0
| this.next = next;
|
|
385 |
| } |
|
386 |
| |
|
387 |
| |
|
388 |
| |
|
389 |
| |
|
390 |
| |
|
391 |
0
| public Node getPhp()
|
|
392 |
| { |
|
393 |
0
| return this.php;
|
|
394 |
| } |
|
395 |
| |
|
396 |
| |
|
397 |
| |
|
398 |
| |
|
399 |
| |
|
400 |
0
| public void setPhp(Node php)
|
|
401 |
| { |
|
402 |
0
| this.php = php;
|
|
403 |
| } |
|
404 |
| |
|
405 |
| |
|
406 |
| |
|
407 |
| |
|
408 |
| |
|
409 |
0
| public String getValue()
|
|
410 |
| { |
|
411 |
0
| return this.value;
|
|
412 |
| } |
|
413 |
| |
|
414 |
| |
|
415 |
| |
|
416 |
| |
|
417 |
| |
|
418 |
0
| public void setValue(String value)
|
|
419 |
| { |
|
420 |
0
| this.value = value;
|
|
421 |
| } |
|
422 |
| |
|
423 |
| } |