2 * @(#)AttrCheckImpl.java 1.11 2000/08/16
6 package net.sourceforge.phpdt.tidy.w3c;
10 * Check attribute values implementations
12 * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
13 * See Tidy.java for the copyright notice.
14 * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
15 * HTML Tidy Release 4 Aug 2000</a>
17 * @author Dave Raggett <dsr@w3.org>
18 * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
19 * @version 1.0, 1999/05/22
20 * @version 1.0.1, 1999/05/29
21 * @version 1.1, 1999/06/18 Java Bean
22 * @version 1.2, 1999/07/10 Tidy Release 7 Jul 1999
23 * @version 1.3, 1999/07/30 Tidy Release 26 Jul 1999
24 * @version 1.4, 1999/09/04 DOM support
25 * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
26 * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
27 * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
28 * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
29 * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
30 * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
31 * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
34 public class AttrCheckImpl {
36 public static class CheckUrl implements AttrCheck {
38 public void check( Lexer lexer, Node node, AttVal attval)
40 if (attval.value == null)
41 Report.attrError(lexer, node, attval.attribute, Report.MISSING_ATTR_VALUE);
42 else if (lexer.configuration.FixBackslash)
44 attval.value = attval.value.replace('\\','/');
50 public static class CheckScript implements AttrCheck {
52 public void check( Lexer lexer, Node node, AttVal attval)
58 public static class CheckAlign implements AttrCheck {
60 public void check( Lexer lexer, Node node, AttVal attval)
64 /* IMG, OBJECT, APPLET and EMBED use align for vertical position */
65 if (node.tag != null && ((node.tag.model & Dict.CM_IMG) != 0))
67 getCheckValign().check(lexer, node, attval);
74 Report.attrError(lexer, node, attval.attribute, Report.MISSING_ATTR_VALUE);
75 else if (! (Lexer.wstrcasecmp(value, "left") == 0 ||
76 Lexer.wstrcasecmp(value, "center") == 0 ||
77 Lexer.wstrcasecmp(value, "right") == 0 ||
78 Lexer.wstrcasecmp(value, "justify") == 0))
79 Report.attrError(lexer, node, attval.value, Report.BAD_ATTRIBUTE_VALUE);
84 public static class CheckValign implements AttrCheck {
86 public void check( Lexer lexer, Node node, AttVal attval)
93 Report.attrError(lexer, node, attval.attribute, Report.MISSING_ATTR_VALUE);
94 else if (Lexer.wstrcasecmp(value, "top") == 0 ||
95 Lexer.wstrcasecmp(value, "middle") == 0 ||
96 Lexer.wstrcasecmp(value, "bottom") == 0 ||
97 Lexer.wstrcasecmp(value, "baseline") == 0)
101 else if (Lexer.wstrcasecmp(value, "left") == 0 ||
102 Lexer.wstrcasecmp(value, "right") == 0)
104 if (!(node.tag != null && ((node.tag.model & Dict.CM_IMG) != 0)))
105 Report.attrError(lexer, node, value, Report.BAD_ATTRIBUTE_VALUE);
107 else if (Lexer.wstrcasecmp(value, "texttop") == 0 ||
108 Lexer.wstrcasecmp(value, "absmiddle") == 0 ||
109 Lexer.wstrcasecmp(value, "absbottom") == 0 ||
110 Lexer.wstrcasecmp(value, "textbottom") == 0)
112 lexer.versions &= Dict.VERS_PROPRIETARY;
113 Report.attrError(lexer, node, value, Report.PROPRIETARY_ATTR_VALUE);
116 Report.attrError(lexer, node, value, Report.BAD_ATTRIBUTE_VALUE);
121 public static class CheckBool implements AttrCheck {
123 public void check( Lexer lexer, Node node, AttVal attval)
129 public static class CheckId implements AttrCheck {
131 public void check( Lexer lexer, Node node, AttVal attval)
137 public static class CheckName implements AttrCheck {
139 public void check( Lexer lexer, Node node, AttVal attval)
145 public static AttrCheck getCheckUrl()
150 public static AttrCheck getCheckScript()
155 public static AttrCheck getCheckAlign()
160 public static AttrCheck getCheckValign()
165 public static AttrCheck getCheckBool()
170 public static AttrCheck getCheckId()
175 public static AttrCheck getCheckName()
181 private static AttrCheck _checkUrl = new CheckUrl();
182 private static AttrCheck _checkScript = new CheckScript();
183 private static AttrCheck _checkAlign = new CheckAlign();
184 private static AttrCheck _checkValign = new CheckValign();
185 private static AttrCheck _checkBool = new CheckBool();
186 private static AttrCheck _checkId = new CheckId();
187 private static AttrCheck _checkName = new CheckName();