W3C home > Mailing lists > Public > www-validator-cvs@w3.org > February 2009

2002/css-validator/org/w3c/css/css StyleSheetGenerator.java,1.24,1.25 xhtml.properties,1.30,1.31

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 17 Feb 2009 09:39:58 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1LZMQo-000235-IW@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/css
In directory hutz:/tmp/cvs-serv7323/org/w3c/css/css

Modified Files:
	StyleSheetGenerator.java xhtml.properties 
Log Message:
Addresses Bug 6582
http://www.w3.org/Bugs/Public/show_bug.cgi?id=6582

Using the new function from the context to figure out if the input
is a fake URI or not, we strip the name as needed, and do not put the
link in the Errors and Warnings.
The heading "results for..." is also fixed.



Index: xhtml.properties
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/xhtml.properties,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- xhtml.properties	14 Feb 2009 00:10:32 -0000	1.30
+++ xhtml.properties	17 Feb 2009 09:39:56 -0000	1.31
@@ -13,7 +13,8 @@
     </head>
     <body>
       <div id="banner">
-       <h1 id="title"><a href="http://www.w3.org/"><img alt="W3C" width="110" height="61" id="logo" src="./images/w3c.png" /></a>
+       <h1 id="title"><a href="http://www.w3.org/"><img alt="W3C" width="110" height="61" 
+           		 				id="logo" src="./images/w3c.png" /></a>
        <a href="./"><span>CSS Validation Service</span></a></h1>
 
        <p id="tagline">
@@ -142,7 +143,11 @@
                 #set ( $sf = $err.SourceFile )
             
                 <div class='error-section'>
+		#if ( $fake_input ) 
+                    <h4>URI : $file_title</h4>
+		#else
                     <h4>URI : <a href="$sf">$sf</a></h4>
+		#end
                     <table>
                 #set ( $open = true )
             #end
@@ -203,7 +208,11 @@
             #set ( $sf = $warning.SourceFile )
             
                 <div class='warning-section'>
+		#if ( $fake_input ) 
+                    <h4>URI : $file_title</h4>
+		#else
                     <h4>URI : <a href="$sf">$sf</a></h4>
+		#end
                     <table>
             #set ( $open = true )
         #end

Index: StyleSheetGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- StyleSheetGenerator.java	13 Feb 2009 21:50:15 -0000	1.24
+++ StyleSheetGenerator.java	17 Feb 2009 09:39:56 -0000	1.25
@@ -58,52 +58,69 @@
     static {
         availableFormat = new Utf8Properties();
         try {
-            java.io.InputStream f = StyleSheetGenerator.class.getResourceAsStream("format.properties");
+            java.io.InputStream f;
+	    f = StyleSheetGenerator.class.getResourceAsStream(
+							   "format.properties");
             availableFormat.load(f);
             f.close();
         } catch (Exception e) {
-            System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: couldn't load format properties ");
+            System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: "+
+			       "couldn't load format properties ");
             System.err.println("  " + e.toString());
         }
 
         availablePropertiesURL = new Utf8Properties();
         try {
-            java.io.InputStream f = StyleSheetGenerator.class.getResourceAsStream("urls.properties");
+            java.io.InputStream f;
+	    f = StyleSheetGenerator.class.getResourceAsStream(
+							     "urls.properties");
             availablePropertiesURL.load(f);
             f.close();
         } catch (Exception e) {
-            System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: couldn't load URLs properties ");
+            System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: "+
+			       "couldn't load URLs properties ");
             System.err.println("  " + e.toString());
         }
 
         try {
             Velocity.setProperty(Velocity.RESOURCE_LOADER, "file");
             Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
-            Velocity.setProperty("jar." + Velocity.RESOURCE_LOADER + ".class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
+            Velocity.setProperty("jar." + Velocity.RESOURCE_LOADER + ".class",
+	       "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
             URL path = StyleSheetGenerator.class.getResource("/");
             if(path != null) {
-                Velocity.addProperty("file." + Velocity.RESOURCE_LOADER + ".path", path.getFile());
-                Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER + ".path", "jar:" + path + "css-validator.jar");
+                Velocity.addProperty("file." + Velocity.RESOURCE_LOADER +
+				     ".path", path.getFile());
+                Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER+".path",
+				      "jar:" + path + "css-validator.jar");
             }
-
             Velocity.init();
         } catch(Exception e) {
-            System.err.println("Failed to initialize Velocity. Validator might not work as expected.");
+            System.err.println("Failed to initialize Velocity. "+
+			       "Validator might not work as expected.");
         }
     }
 	
-    public StyleSheetGenerator(String title, StyleSheet style, String document, int warningLevel) {
+    public StyleSheetGenerator(String title, StyleSheet style, String document,
+			       int warningLevel)
+    {
         this(null, title, style, document, warningLevel);
     }
 
-    public StyleSheetGenerator(ApplContext ac, String title, StyleSheet style, String document, int warningLevel) {
+    public StyleSheetGenerator(ApplContext ac, String title, StyleSheet style,
+			       String document, int warningLevel) {
         this.ac = ac;
         this.style = style;
         this.title = title;
         this.template_file = availableFormat.getProperty(document);
 
         context = new VelocityContext();
-        context.put("file_title", title);
+	if (ac.isInputFake()) {
+	    title = title.substring(title.lastIndexOf('/')+1);
+	    context.put("file_title", title);
+	} else {
+	    context.put("file_title", title);
+	}	    
         
         // W3C_validator_result
         warnings = style.getWarnings();
@@ -149,13 +166,15 @@
         }
 		
         // generated values
-        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
+        SimpleDateFormat formatter;
+	formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
         formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
         context.put("currentdate", formatter.format(new Date()));
         context.put("lang", ac.getContentLanguage());
         context.put("errors_count", new Integer(errors.getErrorCount()));
         context.put("warnings_count", new Integer(warnings.getWarningCount()));
-        context.put("ignored-warnings_count", new Integer(warnings.getIgnoredWarningCount()));
+        context.put("ignored-warnings_count", 
+		               new Integer(warnings.getIgnoredWarningCount()));
         context.put("warning_level", new Integer(warningLevel));
         context.put("rules_count", new Integer(items.size()));
         context.put("no_errors_report", new Boolean(false));
@@ -163,8 +182,9 @@
         context.put("cssversion", ac.getCssVersion());
         context.put("css_profile", ac.getProfile());
         context.put("css", ac.getMsg().getString(ac.getCssVersion()));
-        context.put("css_link", getURLProperty("@url-base_"+ac.getCssVersion()));
-        context.put("is_valid", (errors.getErrorCount() == 0) ? "true" : "false");
+        context.put("css_link",getURLProperty("@url-base_"+ac.getCssVersion()));
+        context.put("is_valid", (errors.getErrorCount() == 0)?"true":"false");
+	context.put("fake_input", new Boolean(ac.isInputFake()));
         context.put("author", "www-validator-css");
         context.put("author-email", "Email.html");
         if (style.charset != null)
@@ -258,12 +278,14 @@
                     h.put("Error", csserror);
                     h.put("CtxName", "nocontext");
                     h.put("CtxMsg", "");
-                    h.put("ErrorMsg", ((ex.getMessage() == null) ? "" : ex.getMessage()));
+                    h.put("ErrorMsg", ((ex.getMessage() == null) ? "" :
+				                             ex.getMessage()));
                     h.put("ClassName", "unkownerror");
                     if (ex instanceof FileNotFoundException) {
                         h.put("ClassName", "notfound");
-                        h.put("ErrorMsg", ac.getMsg().getGeneratorString("not-found") + ": " + ex.getMessage());
-
+                        h.put("ErrorMsg", 
+			      ac.getMsg().getGeneratorString("not-found") + 
+			      ": " + ex.getMessage());
                     } else if (ex instanceof CssParseException) {
                         produceParseException((CssParseException) ex, h);
                     } else if (ex instanceof InvalidParamException) {
@@ -291,7 +313,8 @@
                               + terror.getSkippedString());
                     } else {
                         h.put("ClassName", "unkownerror");
-                        h.put("ErrorMsg", ac.getMsg().getErrorString("unknown") + " " + ex);
+                        h.put("ErrorMsg", ac.getMsg().getErrorString("unknown")
+			                  + " " + ex);
                         if (ex instanceof NullPointerException) {
                             // ohoh, a bug
                             ex.printStackTrace();
@@ -330,12 +353,14 @@
      * @param error, the error to check
      * @param ht_error, the Hastable with information about this error
      */
-    private void produceParseException(CssParseException error, Hashtable<String,Object> ht_error) {
+    private void produceParseException(CssParseException error, 
+				       Hashtable<String,Object> ht_error) {
         if (error.getContexts() != null && error.getContexts().size() != 0) {
             ht_error.put("CtxName", "codeContext");
             StringBuffer buf = new StringBuffer();
             // Loop on the list of contexts for errors
-            for (Enumeration e = error.getContexts().elements(); e.hasMoreElements();) {
+	    Enumeration e;
+            for (e = error.getContexts().elements(); e.hasMoreElements();) {
                 Object t = e.nextElement();
                 // if the list is not null, add a comma
                 if (t != null) {
@@ -345,31 +370,39 @@
                     }
                 }
             }
-            if (buf.length() != 0)
+            if (buf.length() != 0) {
                 ht_error.put("CtxMsg", String.valueOf(buf));
+	    }
         } else {
             ht_error.put("CtxName", "nocontext");
         }
         ht_error.put("ClassName", "parse-error");
         String name = error.getProperty();
         String ret;
-        if ((name != null) && (getURLProperty(name) != null) && PropertiesLoader.getProfile(ac.getCssVersion()).containsKey(name)) {
+        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"));
-            // 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
+            ht_error.put("link_before_parse_error",
+			 ac.getMsg().getGeneratorString("property"));
+            // 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"))
+            if (ac.getCssVersion().equals("css3")) {
                 lnk = getURLProperty("@url-base_css2.1");
-            else if (ac.getCssVersion().equals("css1"))
+            } else if (ac.getCssVersion().equals("css1")) {
                 lnk = getURLProperty("@url-base_css2"); 
-            else
+            } 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",
+	    //              context.get("css_link") + getURLProperty(name));
             ht_error.put("link_value_parse_error", lnk + getURLProperty(name));
             ht_error.put("link_name_parse_error", name);
         }
@@ -386,16 +419,19 @@
             }
             if (error.getSkippedString() != null) {
                 ht_error.put("span_class_parse_error", "skippedString");
-                ht_error.put("span_value_parse_error", queryReplace(error.getSkippedString()));
+                ht_error.put("span_value_parse_error", 
+			     queryReplace(error.getSkippedString()));
             } else if (error.getExp() != null) {
                 ret += " : " + queryReplace(error.getExp().toStringFromStart());
                 ht_error.put("span_class_parse_error", "exp");
-                ht_error.put("span_value_parse_error", queryReplace(error.getExp().toString()));
+                ht_error.put("span_value_parse_error", 
+			     queryReplace(error.getExp().toString()));
             }
         } else {
             ret = ac.getMsg().getGeneratorString("unrecognize");
             ht_error.put("span_class_parse_error", "unrecognized");
-            ht_error.put("span_value_parse_error", queryReplace(error.getSkippedString()));
+            ht_error.put("span_value_parse_error", 
+			 queryReplace(error.getSkippedString()));
         }
         ht_error.put("ErrorMsg", ret);
     }
@@ -442,10 +478,12 @@
     }
 
     /**
-     * The user doesn't want to see the error report when this function is called
+     * The user doesn't want to see the error report when this function 
+     * is called
      */
     public void desactivateError() {
-        context.put("no_errors_report", new Boolean(true)); // activate the no errors report
+        context.put("no_errors_report", new Boolean(true));
+	// activate the no errors report
     }
 
 }
Received on Tuesday, 17 February 2009 09:40:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:08 GMT