author | Eugene Ostroukhov <eugeneo@symbian.org> |
Fri, 12 Mar 2010 10:14:08 -0800 | |
changeset 262 | 1461282d0fd5 |
parent 191 | 61c04b3eb3e7 |
permissions | -rw-r--r-- |
191
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
// |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
// $Id: StyleSheetCom.java,v 1.22 2007-09-13 09:35:46 julien Exp $ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
// |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
// (c) COPYRIGHT MIT and INRIA, 1997. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
// Please first read the full copyright statement in file COPYRIGHT.html |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
package org.w3c.css.css; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
import java.io.File; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
import java.io.IOException; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
import java.io.OutputStreamWriter; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
import java.io.PrintWriter; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
import java.net.MalformedURLException; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
import java.net.URL; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
import java.net.URLConnection; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
import org.w3c.css.parser.CssFouffa; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
import org.w3c.css.parser.CssSelectors; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
import org.w3c.css.parser.CssStyle; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
import org.w3c.css.properties.PropertiesLoader; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import org.w3c.css.properties.css1.CssProperty; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
import org.w3c.css.util.ApplContext; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
import org.w3c.css.util.HTTPURL; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
import org.w3c.css.util.Util; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
import org.w3c.www.mime.MimeType; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
/** |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
* @version $Revision: 1.22 $import javax.servlet.http.HttpServletResponse; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
public class StyleSheetCom { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
/* ApplContext ac = new ApplContext("ja, en, zh"); */ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
ApplContext ac; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
String lang; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
String documentBase = "text"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
URL htmlURL; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
String file; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
int warningLevel = 2; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
PrintWriter out; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
String defaultmedium; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
String cssversion; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
String profile; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
String contenttype; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
// @@ HACK |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
static boolean showCSS = false; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
private Exception exception; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
public void htmlRequest() throws Exception { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
StyleSheet style = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
55 |
TagSoupStyleSheetHandler handler = new TagSoupStyleSheetHandler(htmlURL, ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
handler.parse(htmlURL); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
style = handler.getStyleSheet(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
if (style != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
style.setType("text/html"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
if (style != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
style.findConflicts(ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
StyleSheetGenerator output = |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
new StyleSheetGenerator(ac, file, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
style, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
documentBase, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
warningLevel); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
output.print(out); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
System.err.println("No style sheet found in your HTML document"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
ac.setInput("text/xml"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
public void xmlRequest() throws Exception { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
StyleSheet style = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
XMLStyleSheetHandler handler = new XMLStyleSheetHandler(htmlURL, ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
handler.parse(htmlURL); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
style = handler.getStyleSheet(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
81 |
if (style != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
82 |
style.setType("text/xml"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
83 |
style.findConflicts(ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
84 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
85 |
System.err.println("No style sheet found in your HTML document"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
86 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
87 |
StyleSheetGenerator output = |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
88 |
new StyleSheetGenerator(ac, file, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
89 |
style, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
90 |
documentBase, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
91 |
warningLevel); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
92 |
output.print(out); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
93 |
ac.setInput("text/xml"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
94 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
95 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
96 |
public void cssRequest(CssSelectors selector, String defaultmedium) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
97 |
CssParser parser = new StyleSheetParser(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
98 |
ac.setMedium(defaultmedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
99 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
100 |
/* |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
101 |
if (defaultmedium != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
102 |
parser.setDefaultMedium(defaultmedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
103 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
104 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
105 |
parser.parseURL(ac, htmlURL, null, null, null, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
106 |
StyleSheetOrigin.AUTHOR); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
107 |
parser.getStyleSheet().findConflicts(ac); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
108 |
if (selector != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
109 |
System.err.println("<color value=\"" |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
110 |
+ parser.getStyleSheet().CascadingOrder(new org.w3c.css.properties.css1.CssColor(), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
111 |
parser.getStyleSheet(), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
112 |
selector)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
113 |
CssStyle s = parser.getStyleSheet().getStyle(selector); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
114 |
CssProperty _sl = |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
115 |
((org.w3c.css.properties.css1.Css1Style) s).getColor(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
116 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
117 |
s.print(new org.w3c.css.parser.CssPrinterStyle () { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
118 |
public void print(CssProperty property) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
119 |
System.out.print(property.getPropertyName()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
120 |
System.out.print(": "); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
121 |
System.out.print(property.toString()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
122 |
System.out.println(';'); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
123 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
124 |
}); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
125 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
126 |
StyleSheetGenerator output = |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
127 |
new StyleSheetGenerator(ac, file, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
128 |
parser.getStyleSheet(), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
129 |
documentBase, |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
130 |
warningLevel); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
131 |
output.print(out); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
132 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
133 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
134 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
135 |
public static void main(String args[]) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
136 |
throws IOException, MalformedURLException { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
137 |
int i = 0; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
138 |
CssSelectors selector = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
139 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
140 |
StyleSheetCom style = new StyleSheetCom(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
141 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
142 |
// Fix for http://www.w3.org/Bugs/Public/show_bug.cgi?id=292 |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
143 |
style.contenttype = "text"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
144 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
145 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
146 |
style.file = args[i]; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
147 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
148 |
while (i < args.length && args[i].charAt(0) == '-') { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
149 |
String argument = args[i].substring(1).toLowerCase(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
150 |
if (argument.equals("e")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
151 |
style.warningLevel = -1; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
152 |
} else if (argument.equals("s")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
153 |
StyleSheetCom.showCSS = true; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
154 |
} else if (argument.equals("c")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
155 |
selector = createSelectors(args[++i]); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
156 |
} else if (argument.equals("format")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
157 |
StyleSheetGenerator. |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
158 |
printAvailableFormat(new PrintWriter(System.err)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
159 |
} else if (argument.startsWith("@")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
160 |
style.defaultmedium = argument; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
161 |
} else if (argument.equals("css1") || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
162 |
argument.equals("css2") || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
163 |
argument.equals("css21") || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
164 |
argument.equals("css3") || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
165 |
argument.equals("svg") || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
166 |
argument.equals("svgbasic") || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
167 |
argument.equals("svgtiny")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
168 |
style.cssversion = argument; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
169 |
} else if (argument.equals("mobile") || argument.equals("tv")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
170 |
style.profile = argument; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
171 |
} else if (argument.equals("atsc")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
172 |
style.profile = "atsc-tv"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
173 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
174 |
int idx = argument.lastIndexOf('.'); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
175 |
if(idx >= 0 && idx < argument.length() - 1) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
176 |
style.lang = argument.substring(idx+1); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
177 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
178 |
style.lang = "en"; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
179 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
180 |
style.documentBase = argument; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
181 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
182 |
i++; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
183 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
184 |
style.ac = new ApplContext(style.lang); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
185 |
if (style.cssversion != null) |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
186 |
style.ac.setCssVersion(style.cssversion); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
187 |
if (style.profile != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
188 |
style.ac.setProfile(style.profile); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
189 |
style.ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
190 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
191 |
if (style.cssversion == null && style.ac.getCssVersion() == null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
192 |
style.ac.setCssVersion(PropertiesLoader.config.getProperty("defaultProfile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
193 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
194 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
195 |
/* System.out.println( "Usage: validator " + |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
196 |
StyleSheetCom.class.getName() + |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
197 |
// " [-<your format>] [-fromxml] <url>"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
198 |
" [-s||-e||-<your format>] [<url>|<file>]*"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
199 |
*/ |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
200 |
System.out.println( "Usage: validator " + |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
201 |
" [ -s || -e || -<your format> || -cssversion/profile ] [<url>|<file>]*"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
202 |
System.out.println( "\t-s\tShow the validated style sheet"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
203 |
System.out.println( "\t-e\tDo NOT show warnings"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
204 |
System.out.println( "\tuse the option -format to see" |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
205 |
+ " available format."); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
206 |
System.out.println( "\tCSS version\t-css1 || -css2 || -css21 || -css3 || -svg || -svgbasic || -svgtiny"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
207 |
System.out.println( "\tProfile\t\t -atsc || -mobile || tv"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
208 |
//System.out.println( "\tCSS version\t-css1 || -css2"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
209 |
// System.out.println( "\tProfile\t\t-svg || -atsc || -mobile"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
210 |
System.exit(1); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
211 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
212 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
213 |
String encoding = style.ac.getMsg().getString("output-encoding-name"); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
214 |
if(encoding != null) style.out = new PrintWriter(new OutputStreamWriter(System.out, encoding)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
215 |
else style.out = new PrintWriter(new OutputStreamWriter(System.out)); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
216 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
217 |
while (i < args.length) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
218 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
219 |
String doc = args[i]; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
220 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
221 |
style.htmlURL = new URL(doc); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
222 |
style.file = style.htmlURL.toString(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
223 |
} catch (MalformedURLException ex) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
224 |
File f = new File(args[i]); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
225 |
style.file = f.getAbsolutePath(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
226 |
style.htmlURL = new URL("file", null, -1, style.file); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
227 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
228 |
i++; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
229 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
230 |
String urlLower = style.htmlURL.toString().toLowerCase(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
231 |
if (urlLower.endsWith(".css")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
232 |
style.cssRequest(selector, style.defaultmedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
233 |
} else if (urlLower.endsWith(".html") |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
234 |
|| urlLower.endsWith(".shtml") |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
235 |
|| urlLower.endsWith("/")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
236 |
style.htmlRequest(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
237 |
} else if (urlLower.endsWith(".xml")) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
238 |
style.xmlRequest(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
239 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
240 |
URLConnection urlC = HTTPURL.getConnection(style.htmlURL, null); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
241 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
242 |
if (urlC.getContentType() != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
243 |
MimeType mt = null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
244 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
245 |
mt = new MimeType(urlC.getContentType()); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
246 |
} catch (Exception ex) {}; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
247 |
if (MimeType.TEXT_HTML.match(mt) == MimeType.MATCH_SPECIFIC_SUBTYPE) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
248 |
style.htmlRequest(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
249 |
} else if ((MimeType.TEXT_XML.match(mt) == MimeType.MATCH_SPECIFIC_SUBTYPE) || |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
250 |
(MimeType.APPLICATION_XHTML_XML.match(mt) == MimeType.MATCH_SPECIFIC_SUBTYPE)) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
251 |
style.xmlRequest(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
252 |
} else if (MimeType.TEXT_CSS.match(mt) == MimeType.MATCH_SPECIFIC_SUBTYPE) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
253 |
style.cssRequest(selector, style.defaultmedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
254 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
255 |
} else { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
256 |
style.cssRequest(selector, style.defaultmedium); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
257 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
258 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
259 |
urlC.getInputStream().close(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
260 |
} catch (IOException e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
261 |
e.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
262 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
263 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
264 |
} catch (org.xml.sax.SAXException e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
265 |
if (e.getException() != null) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
266 |
e.getException().printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
267 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
268 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
269 |
e.printStackTrace(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
270 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
271 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
272 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
273 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
274 |
private static CssSelectors createSelectors(String s) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
275 |
try { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
276 |
CssFouffa fouffa = |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
277 |
new CssFouffa(null, new java.io.StringBufferInputStream(s), |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
278 |
new URL("file://nofile")); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
279 |
return fouffa.parseSelector(); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
280 |
} catch (Exception e) { |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
281 |
System.err.println(e); |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
282 |
return null; |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
283 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
284 |
} |
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
285 |
|
61c04b3eb3e7
Bug 2001 - css validator to separate plug-in
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
286 |
} |