- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 26 Apr 2006 12:44:17 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/css
In directory hutz:/tmp/cvs-serv763/org/w3c/css/css
Modified Files:
CssRuleList.java HTMLStyleSheetParser.java
StyleReportFactory.java StyleSheetCom.java
StyleSheetGenerator2.java StyleSheetGeneratorHTML2.java
Log Message:
cmdline version revamped now using org.w3c.css.css.CssValidator
http://www.w3.org/Bugs/Public/show_bug.cgi?id=2920
recorrected (now it only applies for CSS2.1)
text output is now real text, and not HTML served as text
Index: StyleSheetCom.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetCom.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- StyleSheetCom.java 20 Mar 2006 06:51:18 -0000 1.14
+++ StyleSheetCom.java 26 Apr 2006 12:44:14 -0000 1.15
@@ -233,7 +233,6 @@
while (i < args.length) {
try {
String doc = args[i];
-
try {
style.htmlURL = new URL(doc);
style.file = style.htmlURL.toString();
@@ -246,10 +245,10 @@
String urlLower = style.htmlURL.toString().toLowerCase();
if (urlLower.endsWith(".css")) {
- style.cssRequest(selector, style.defaultmedium);
+ style.cssRequest(selector, style.defaultmedium);
} else if (urlLower.endsWith(".html")
|| urlLower.endsWith(".shtml")
- || urlLower.endsWith("/")) {
+ || urlLower.endsWith("/")) {
style.htmlRequest();
} else if (urlLower.endsWith(".xml")) {
style.xmlRequest();
Index: StyleSheetGeneratorHTML2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGeneratorHTML2.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- StyleSheetGeneratorHTML2.java 19 Apr 2006 11:28:05 -0000 1.18
+++ StyleSheetGeneratorHTML2.java 26 Apr 2006 12:44:14 -0000 1.19
@@ -173,7 +173,7 @@
// prints the stylesheet at the screen
public void produceStyleSheet() {
- Vector atRules = style.newGetRules();
+ Vector atRules = style.newGetRules();
for (int idx = 0; idx < atRules.size(); idx++) {
// out.print(((CssRuleList)atRules.elementAt(idx)).toHTML());
((CssRuleList) atRules.elementAt(idx)).toHTML(out);
@@ -280,7 +280,7 @@
if (ex instanceof FileNotFoundException) {
ret.append("\n<p>");
ret.append(ac.getMsg().getGeneratorString("not-found"));
- ret.append("<span class='error'>");
+ ret.append("<span class='error'> ");
ret.append(ex.getMessage());
ret.append("</span>\n");
} else if (ex instanceof CssParseException) {
Index: StyleReportFactory.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleReportFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- StyleReportFactory.java 14 Sep 2005 15:14:17 -0000 1.5
+++ StyleReportFactory.java 26 Apr 2006 12:44:14 -0000 1.6
@@ -29,6 +29,11 @@
document,
warningLevel);
}
+ if(document.equals("text")) {
+ return new StyleSheetGenerator2(title, style,
+ document,
+ warningLevel);
+ }
return new StyleSheetGeneratorHTML2(ac, title, style,
"html",
warningLevel);
Index: CssRuleList.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/CssRuleList.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- CssRuleList.java 14 Sep 2005 15:14:17 -0000 1.11
+++ CssRuleList.java 26 Apr 2006 12:44:14 -0000 1.12
@@ -46,8 +46,31 @@
public String toString() {
StringBuffer ret = new StringBuffer();
+ if (null != atRule && atRule.isEmpty()) {
+ if (!atRuleString.equals("")) {
+ ret.append(atRuleString);
+ ret.append("\n\n");
+ }
+ } else {
+ if (!atRuleString.equals("")) {
+ ret.append(atRuleString);
+ ret.append(" {\n\n");
+ }
+ for (int i = 0; i < rulelist.size() ; i++ ) {
+ ret.append((CssStyleRule)rulelist.elementAt(i));
+ }
- if (atRule.isEmpty()) {
+ if (!atRuleString.equals("")) {
+ ret.append("}\n");
+ }
+ }
+ return ret.toString();
+ }
+
+/* public String toString() {
+ StringBuffer ret = new StringBuffer();
+
+ if (atRule == null || atRule.isEmpty()) {
if (null != atRule && !atRuleString.equals("")) {
ret.append(atRuleString);
ret.append(' ');
@@ -72,7 +95,7 @@
}
}
return ret.toString();
- }
+ }*/
/* public String toHTML() {
StringBuffer ret = new StringBuffer();
Index: HTMLStyleSheetParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/HTMLStyleSheetParser.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- HTMLStyleSheetParser.java 14 Sep 2005 15:14:17 -0000 1.17
+++ HTMLStyleSheetParser.java 26 Apr 2006 12:44:14 -0000 1.18
@@ -47,7 +47,7 @@
String urlLower = urlString.toLowerCase();
String media = ac.getMedium();
- if (!"http".equals(htmlURL.getProtocol())) {
+ if (!"http".equals(htmlURL.getProtocol())) {
if (urlLower.endsWith(".css")) {
StyleSheetParser parser = new StyleSheetParser();
parser.parseURL(ac, htmlURL, null, null, media,
@@ -78,8 +78,9 @@
} finally {
Util.fromHTMLFile = false;
}
- }
- throw new Exception("Unknown file");
+ } else {
+ throw new Exception("Unknown file");
+ }
} else {
URLConnection connection = null;
@@ -171,8 +172,9 @@
XMLStyleSheetHandler handler;
handler = new XMLStyleSheetHandler(htmlURL, ac);
handler.parse(urlString, connection);
- style = handler.getStyleSheet();
- if (style != null) {
+ style = handler.getStyleSheet();
+
+ if (style != null) {
style.setType("text/xml");
}
}
Index: StyleSheetGenerator2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator2.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- StyleSheetGenerator2.java 14 Sep 2005 15:14:17 -0000 1.5
+++ StyleSheetGenerator2.java 26 Apr 2006 12:44:14 -0000 1.6
@@ -26,7 +26,7 @@
/**
* @version $Revision$
*/
-public final class StyleSheetGenerator2 {
+public final class StyleSheetGenerator2 extends StyleReport {
// SortedHashtable items;
Hashtable items;
@@ -43,9 +43,9 @@
private int warningLevel;
- private Utf8Properties general;
+ private Utf8Properties general;
- private static Utf8Properties availableFormat;
+ private static Utf8Properties availableFormat;
private static Hashtable formats = new Hashtable();
@@ -65,15 +65,15 @@
String document, int warningLevel) {
// this small part prints the stylesheet to the screen
- if (StyleSheetCom.showCSS == true) {
+ if (StyleSheetCom.showCSS == true || CssValidator.showCSS == true) {
if (style.charset != null) {
System.out.println("@charset " + style.charset + ";\n");
}
Vector atRules = style.newGetRules();
+
for (int i = 0; i < atRules.size(); i++) {
- System.out.println(((CssRuleList) atRules.elementAt(i))
- .toString());
+ System.out.println(((CssRuleList) atRules.elementAt(i)).toString());
}
}
@@ -126,6 +126,7 @@
public void print(PrintWriter out) {
this.out = out; // must be in first !
String output = processSimple("document");
+
if (output != null) {
out.println(output);
} else {
@@ -255,7 +256,7 @@
if (warnings.getWarningCount() != 0) {
int i = 0;
warnings.sort();
- for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
+ for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
Warning warn = warning[i];
if (warn.getLevel() <= warningLevel) {
@@ -264,8 +265,9 @@
ret.append("\n URI : ");
ret.append(oldSourceFile).append('\n');
}
- if (warn.getLine() != oldLine
- || !warn.getWarningMessage().equals(oldMessage)) {
+ /*if (warn.getLine() != oldLine
+ || !warn.getWarningMessage().equals(oldMessage)) {*/
+
oldLine = warn.getLine();
oldMessage = warn.getWarningMessage();
ret.append("Line : ").append(oldLine);
@@ -281,7 +283,7 @@
}
ret.append(" \n");
- }
+ //}
}
}
}
@@ -304,7 +306,7 @@
return processStyle(general.getProperty(s), general);
}
- private String processStyle(String str, Utf8Properties prop) {
+ private String processStyle(String str, Utf8Properties prop) {
if (str == null) {
return "";
}
Received on Wednesday, 26 April 2006 12:44:25 UTC