2002/css-validator/org/w3c/css/css StyleSheetGenerator.java,1.9,1.10

Update of /sources/public/2002/css-validator/org/w3c/css/css
In directory hutz:/tmp/cvs-serv9239/org/w3c/css/css

Modified Files:
	StyleSheetGenerator.java 
Log Message:
 . Adding the css_link to display when the page is valid (depending on the version) 
   This link is writen in urls.properties
 . Adding a test so there is no error when the lang is not set
 . Restoring the fileNotFound message so it is not strange when somebody is trying 
   to use the file:// protocol
 . Changing the links when there is documentation about an error. But uri are not
   defined for CSS1 nor CSS3... @see bug 4092[1]
 . Changing the name of some parse error so it's ok with previous soap output
   @see bug 750[2]

[1] : http://www.w3.org/Bugs/Public/show_bug.cgi?id=4092
[2] : http://www.w3.org/Bugs/Public/show_bug.cgi?id=750

Index: StyleSheetGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- StyleSheetGenerator.java	31 Jul 2007 09:49:48 -0000	1.9
+++ StyleSheetGenerator.java	6 Aug 2007 13:50:02 -0000	1.10
@@ -23,6 +23,7 @@
 import org.w3c.css.parser.CssErrorToken;
 import org.w3c.css.parser.CssParseException;
 import org.w3c.css.parser.Errors;
+import org.w3c.css.properties.PropertiesLoader;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.util.Messages;
@@ -99,7 +100,7 @@
 		// Setting all the variables of the velocity context
 		ApplContext ac_default = new ApplContext(default_lang);
 		String k;
-		if (ac.getLang().equals(default_lang)) {
+		if (ac.getLang() == null || ac.getLang().equals(default_lang)) {
 			Iterator it = ac_default.getMsg().properties.keySet().iterator();
 			while (it.hasNext()) {
 				k = String.valueOf(it.next());
@@ -145,6 +146,7 @@
 		context.put("no_errors_report", new Boolean(false));
 		context.put("charset", ac.getContentEncoding());
 		context.put("cssversion", ac.getCssVersion());
+		context.put("css_link", getURLProperty("@url-base_"+ac.getCssVersion()));
 		context.put("is_valid", (errors.getErrorCount() == 0) ? "true" : "false");
 		context.put("author", "www-validator-css");
 		context.put("author-email", "Email.html");
@@ -245,18 +247,12 @@
 
 					if (ex instanceof FileNotFoundException) {
 						errors_content[i].put("ClassName", "notfound");
-						String stringError = ex.getMessage();
-						int index = stringError.lastIndexOf(':');
-						String str = stringError.substring(0, index);
-						// The Exception name 'StringError' was previously
-						// displayed
-						errors_content[i].put("ErrorMsg", ac.getMsg().getGeneratorString("not-found") + ": " + str);
+						errors_content[i].put("ErrorMsg", ac.getMsg().getGeneratorString("not-found") + ": " + ex.getMessage());
 
 					} else if (ex instanceof CssParseException) {
 						produceParseException((CssParseException) ex, errors_content[i]);
 					} else if (ex instanceof InvalidParamException) {
 						errors_content[i].put("ClassName", "invalidparam");
-
 					} else if (ex instanceof IOException) {
 						String stringError = ex.toString();
 						// int index = stringError.indexOf(':');
@@ -342,10 +338,24 @@
 		ht_error.put("ClassName", "parse-error");
 		String name = error.getProperty();
 		String ret;
-		if ((name != null) && (getURLProperty(name) != null)) {
+		if ((name != null) && (getURLProperty(name) != null) && PropertiesLoader.getProfile(ac.getCssVersion()).containsKey(name)) {
 			//we add a link information
+			// we check if the property doesn't exist in this css version
 			ht_error.put("link_before_parse_error", ac.getMsg().getGeneratorString("property"));
-			ht_error.put("link_value_parse_error", getURLProperty("@url-base") + getURLProperty(name));
+			// Since CSS3 is only a working draft, the links don't exist yet in CSS3...
+			// And this is the same with CSS1 because the links are not working the same way...
+			// This can be removed as soon as the CSS3 specifications are made and CSS1 use the links
+			// and the link is changed in urls.properties
+			String lnk;
+			if (ac.getCssVersion().equals("css3"))
+				lnk = getURLProperty("@url-base_css2.1");
+			else if (ac.getCssVersion().equals("css1"))
+				lnk = getURLProperty("@url-base_css2"); 
+			else
+				lnk = context.get("css_link").toString();
+			// this would be replaced by :
+			// ht_error.put("link_value_parse_error", context.get("css_link") + getURLProperty(name));
+			ht_error.put("link_value_parse_error", lnk + getURLProperty(name));
 			ht_error.put("link_name_parse_error", name);
 		}
 		if ((error.getException() != null) && (error.getMessage() != null)) {
@@ -369,7 +379,7 @@
 			}
 		} else {
 			ret = ac.getMsg().getGeneratorString("unrecognize");
-			ht_error.put("span_class_parse_error", "other");
+			ht_error.put("span_class_parse_error", "unrecognized");
 			ht_error.put("span_value_parse_error", queryReplace(error.getSkippedString()));
 		}
 		ht_error.put("ErrorMsg", ret);

Received on Monday, 6 August 2007 13:50:11 UTC