- From: Julien Grand-Mourcel via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 13 Jul 2007 13:32:22 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/css
In directory hutz:/tmp/cvs-serv13393/org/w3c/css/css
Modified Files:
StyleReportFactory.java StyleSheetCom.java CssStyleRule.java
xml.properties StyleSheetGeneratorHTML.java format.properties
StyleReport.java XMLStyleSheetHandler.java StyleSheet.java
StyleSheetGenerator.java CssRuleList.java DocumentParser.java
NewStyleSheet.java
Added Files:
ucn.properties xhtml.properties soap12.properties .cvsignore
Removed Files:
xhtml.properties.nl xhtml.properties.ja
StyleSheetGeneratorHTML2.java xhtml.properties.zh-cn
ucn.properties.en xhtml.properties.pl-PL xhtml.properties.fr
StyleReportUCN.java xhtml.properties.es xhtml.properties.it
xhtml.properties.en soap12.properties.en xhtml.properties.de
StyleReportSOAP12.java StyleSheetGenerator2.java
Log Message:
Adding patch to use Velocity template engine.
And some other changes...
--- xhtml.properties.fr DELETED ---
--- xhtml.properties.pl-PL DELETED ---
Index: DocumentParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/DocumentParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DocumentParser.java 24 Apr 2007 11:14:22 -0000 1.1
+++ DocumentParser.java 13 Jul 2007 13:32:19 -0000 1.2
@@ -24,131 +24,122 @@
*/
public final class DocumentParser {
- private StyleSheet style;
- private URL htmlURL;
- private Exception exception;
- private ApplContext ac;
+ private StyleSheet style;
+ private URL htmlURL;
+ private Exception exception;
+ private ApplContext ac;
- /**
- * Create a new DocumentParser
- *
- * @exception Exception An error
- */
- public DocumentParser(ApplContext ac, String urlString)
- throws Exception {
- this.htmlURL = HTTPURL.getURL(urlString);
- this.ac = ac;
- urlString = htmlURL.toString();
- String urlLower = urlString.toLowerCase();
- String media = ac.getMedium();
- String urlProtocol = htmlURL.getProtocol();
+ /**
+ * Create a new DocumentParser
+ *
+ * @exception Exception
+ * An error
+ */
+ public DocumentParser(ApplContext ac, String urlString) throws Exception {
+ this.htmlURL = HTTPURL.getURL(urlString);
+ this.ac = ac;
+ urlString = htmlURL.toString();
+ String urlLower = urlString.toLowerCase();
+ String media = ac.getMedium();
+ String urlProtocol = htmlURL.getProtocol();
- if (!"http".equals(urlProtocol) && !"https".equals(urlProtocol)) {
- if (urlLower.endsWith(".css")) {
- StyleSheetParser parser = new StyleSheetParser();
- parser.parseURL(ac, htmlURL, null, null, media,
- StyleSheetOrigin.AUTHOR);
- style = parser.getStyleSheet();
- } else if (urlLower.endsWith(".html")
- || urlLower.endsWith(".shtml")
- || urlLower.endsWith("/")) {
- TagSoupStyleSheetHandler handler;
- handler = new TagSoupStyleSheetHandler(htmlURL, ac);
- handler.parse(htmlURL);
- style = handler.getStyleSheet();
- if (style != null) {
- style.setType("text/html");
- }
- } else if (urlLower.endsWith(".xhtml")
- || urlLower.endsWith(".xml")) {
- XMLStyleSheetHandler handler;
- handler = new XMLStyleSheetHandler(htmlURL, ac);
- handler.parse(htmlURL);
- style = handler.getStyleSheet();
- if (style != null) {
- style.setType("text/xml");
- }
- } else {
- throw new Exception("Unknown file");
- }
- } else {
- URLConnection connection = null;
+ if (!"http".equals(urlProtocol) && !"https".equals(urlProtocol)) {
+ if (urlLower.endsWith(".css")) {
+ StyleSheetParser parser = new StyleSheetParser();
+ parser.parseURL(ac, htmlURL, null, null, media, StyleSheetOrigin.AUTHOR);
+ style = parser.getStyleSheet();
+ } else if (urlLower.endsWith(".html") || urlLower.endsWith(".shtml") || urlLower.endsWith("/")) {
+ TagSoupStyleSheetHandler handler = new TagSoupStyleSheetHandler(htmlURL, ac);
+ handler.parse(htmlURL);
+ style = handler.getStyleSheet();
+ if (style != null) {
+ style.setType("text/html");
+ }
+ } else if (urlLower.endsWith(".xhtml") || urlLower.endsWith(".xml")) {
+ // Seems like we need to use tagsout in this case as well
+ XMLStyleSheetHandler handler = new XMLStyleSheetHandler(htmlURL, ac);
+ handler.parse(htmlURL);
+ style = handler.getStyleSheet();
+ if (style != null) {
+ style.setType("text/xml");
+ }
+ } else {
+ throw new Exception("Unknown file");
+ }
+ } else {
+ URLConnection connection = null;
- try {
- boolean isXML = false;
- String cType;
+ try {
+ boolean isXML = false;
+ String cType;
- // @@ hum, maybe? (plh, yes probably :-) )
- String credential = ac.getCredential();
+ // @@ hum, maybe? (plh, yes probably :-) )
+ String credential = ac.getCredential();
- connection = HTTPURL.getConnection(htmlURL, ac);
- htmlURL = connection.getURL();
+ connection = HTTPURL.getConnection(htmlURL, ac);
+ htmlURL = connection.getURL();
- String httpCL = connection.getHeaderField("Content-Location");
- if (httpCL != null) {
- htmlURL = HTTPURL.getURL(htmlURL, httpCL);
- }
+ String httpCL = connection.getHeaderField("Content-Location");
+ if (httpCL != null) {
+ htmlURL = HTTPURL.getURL(htmlURL, httpCL);
+ }
- cType = connection.getContentType();
- if (cType == null) {
- cType = "unknown/unknown";
- }
- MimeType contentType = null;
- try {
- contentType = new MimeType(cType);
- } catch (MimeTypeFormatException ex) {
- }
+ cType = connection.getContentType();
+ if (cType == null) {
+ cType = "unknown/unknown";
+ }
+ MimeType contentType = null;
+ try {
+ contentType = new MimeType(cType);
+ } catch (MimeTypeFormatException ex) {
+ }
- if (Util.onDebug) {
- System.err.println( "[DEBUG] content type is [" +
- contentType + ']');
- }
+ if (Util.onDebug) {
+ System.err.println("[DEBUG] content type is [" + contentType + ']');
+ }
- if (contentType.match(MimeType.TEXT_HTML) ==
- MimeType.MATCH_SPECIFIC_SUBTYPE) {
- TagSoupStyleSheetHandler handler;
- handler = new TagSoupStyleSheetHandler(htmlURL, ac);
- handler.parse(urlString, connection);
- style = handler.getStyleSheet();
-
- if (style != null) {
- style.setType("text/html");
- }
- } else if (contentType.match(MimeType.TEXT_CSS) ==
- MimeType.MATCH_SPECIFIC_SUBTYPE ) {
- StyleSheetParser parser = new StyleSheetParser();
- parser.parseURL(ac, htmlURL, null, null, media,
- StyleSheetOrigin.AUTHOR);
- style = parser.getStyleSheet();
- } else if ((contentType.match(MimeType.TEXT_XML) ==
- MimeType.MATCH_SPECIFIC_SUBTYPE) ||
- (contentType.match(MimeType.APPLICATION_XHTML_XML) ==
- MimeType.MATCH_SPECIFIC_SUBTYPE)) {
- XMLStyleSheetHandler handler;
- handler = new XMLStyleSheetHandler(htmlURL, ac);
- handler.parse(urlString, connection);
- style = handler.getStyleSheet();
-
- if (style != null) {
- style.setType("text/xml");
- }
- } else {
- throw new IOException("Unknown mime type : "+ contentType);
+ if (contentType.match(MimeType.TEXT_HTML) == MimeType.MATCH_SPECIFIC_SUBTYPE) {
+ TagSoupStyleSheetHandler handler;
+ handler = new TagSoupStyleSheetHandler(htmlURL, ac);
+ handler.parse(urlString, connection);
+ style = handler.getStyleSheet();
+
+ if (style != null) {
+ style.setType("text/html");
+ }
+ } else if (contentType.match(MimeType.TEXT_CSS) == MimeType.MATCH_SPECIFIC_SUBTYPE) {
+ StyleSheetParser parser = new StyleSheetParser();
+ parser.parseURL(ac, htmlURL, null, null, media, StyleSheetOrigin.AUTHOR);
+ style = parser.getStyleSheet();
+ } else if ((contentType.match(MimeType.TEXT_XML) == MimeType.MATCH_SPECIFIC_SUBTYPE)
+ || (contentType.match(MimeType.APPLICATION_XHTML_XML) == MimeType.MATCH_SPECIFIC_SUBTYPE)) {
+ // TagSoup ?
+ XMLStyleSheetHandler handler = new XMLStyleSheetHandler(htmlURL, ac);
+ handler.parse(urlString, connection);
+ style = handler.getStyleSheet();
+
+ if (style != null) {
+ style.setType("text/xml");
+ }
+ } else {
+ throw new IOException("Unknown mime type : " + contentType);
+ }
+ } finally {
+ try {
+ connection.getInputStream().close();
+ } catch (Exception e) {
+ }
+ }
}
- } finally {
- try {
- connection.getInputStream().close();
- } catch (Exception e) {}
- }
}
- }
- /**
- * Returns the recognized style sheet.
- * @return A style sheet.
- */
- public StyleSheet getStyleSheet() {
- return style;
- }
+ /**
+ * Returns the recognized style sheet.
+ *
+ * @return A style sheet.
+ */
+ public StyleSheet getStyleSheet() {
+ return style;
+ }
} // HTMLStyleSheetParser
Index: StyleSheetGeneratorHTML.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGeneratorHTML.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- StyleSheetGeneratorHTML.java 19 Apr 2006 11:28:05 -0000 1.7
+++ StyleSheetGeneratorHTML.java 13 Jul 2007 13:32:19 -0000 1.8
@@ -1,577 +1,459 @@
-//
-// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
-//
-// (c) COPYRIGHT MIT and INRIA, 1997.
-// Please first read the full copyright statement in file COPYRIGHT.html
-
+/**
+ *
+ */
package org.w3c.css.css;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
-import java.text.DateFormat;
+import java.nio.CharBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.StringTokenizer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.TimeZone;
+import java.util.Vector;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.Template;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.w3c.css.error.ErrorReportHTML;
import org.w3c.css.parser.CssError;
import org.w3c.css.parser.CssErrorToken;
import org.w3c.css.parser.CssParseException;
-import org.w3c.css.parser.CssPrinterStyle;
-import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.Errors;
-import org.w3c.css.properties.css1.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.SortedHashtable;
+import org.w3c.css.util.Messages;
import org.w3c.css.util.Utf8Properties;
-import org.w3c.css.util.Util;
-import org.w3c.css.util.Warning;
import org.w3c.css.util.Warnings;
+import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
+
/**
- * @version $Revision$
+ * @author Julien Grand-Mourcel
+ * @author Maria Kaceriakova
+ * @date 2007-06-29
+ * This class uses Velocity to output the validator results
+ *
*/
-public final class StyleSheetGeneratorHTML implements CssPrinterStyle {
-
- StyleSheet style;
-
- SortedHashtable items;
-
- Warnings warnings;
-
- Errors errors;
-
- ApplContext ac;
-
- private CssSelectors selector;
-
- private CssProperty property;
-
- private PrintWriter out;
-
- private int warningLevel;
-
- private Utf8Properties general;
+public class StyleSheetGeneratorHTML extends StyleReport {
+ private PrintWriter out;
+ private Template template;
+ private String template_file;
+ private String default_lang = "en";
+ private ApplContext ac;
+ private StyleSheet style;
+ private String title;
+ private VelocityContext context;
+ private Warnings warnings;
+ private Errors errors;
+ private Vector items;
private static Utf8Properties availableFormat;
-
private static Utf8Properties availablePropertiesURL;
- private static Hashtable formats = new Hashtable();
-
- /**
- * Create a new StyleSheetGenerator
- *
- * @param title
- * The title for the generated document
- * @param style
- * The style sheet
- * @param document
- * The name of the source file
- * @param warningLevel
- * If you want to reduce warning output. (-1 means no warnings)
- */
- public StyleSheetGeneratorHTML(ApplContext ac, String title,
- StyleSheet style, String document, int warningLevel) {
- this.ac = ac;
- this.style = style;
- general = new Utf8Properties(setDocumentBase(getDocumentName(ac, document)));
- general.put("file-title", title);
- warnings = style.getWarnings();
- errors = style.getErrors();
- items = (SortedHashtable) style.getRules();
- this.warningLevel = warningLevel;
-
- general.put("errors-count", Integer.toString(errors.getErrorCount()));
- general.put("warnings-count", Integer.toString(warnings
- .getWarningCount()));
- general.put("rules-count", Integer.toString(items.size()));
+ static {
+ URL url;
+ availableFormat = new Utf8Properties();
+ try {
+ url = StyleSheetGenerator.class.getResource("format.properties");
+ java.io.InputStream f = url.openStream();
+ availableFormat.load(f);
+ f.close();
+ } catch (Exception e) {
+ System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: couldn't load format properties ");
+ System.err.println(" " + e.toString());
+ }
- if (errors.getErrorCount() == 0) {
- desactivateError();
- }
- if ((errors.getErrorCount() != 0) || (!title.startsWith("http://"))) {
- general.put("no-errors", "");
+ availablePropertiesURL = new Utf8Properties();
+ try {
+ url = StyleSheetGenerator.class.getResource("urls.properties");
+ java.io.InputStream f = url.openStream();
+ availablePropertiesURL.load(f);
+ f.close();
+ } catch (Exception e) {
+ System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: couldn't load URLs properties ");
+ System.err.println(" " + e.toString());
+ }
}
- if (warnings.getWarningCount() == 0 || warningLevel == -1) {
- general.put("go-warnings", ""); // remove go-warnings
- general.put("warnings", ""); // remove warnings
- }
- if (items.size() == 0) {
- general.put("go-rules", ""); // remove go-rules
- general.put("rules", ""); // remove rules
- general.put("no-errors", "");
- } else {
- general.put("no-rules", ""); // remove no-rules
- }
+ public StyleSheetGeneratorHTML(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);
- if (errors.getErrorCount() != 0 || warnings.getWarningCount() != 0) {
- // remove no-error-or-warning
- general.put("no-error-or-warning", "");
- }
+ context = new VelocityContext();
+ context.put("file_title", title);
+ // W3C_validator_result
+ warnings = style.getWarnings();
+ errors = style.getErrors();
+ items = style.newGetRules();
- if (Util.onDebug)
- general.list(System.err);
+ try {
+ // Get the variables and put them in the velocity context
+ grep(new File(StyleSheetGeneratorHTML.class.getResource(template_file).getFile()));
+ } catch (Exception e) {
+ // Extraction of variables has not been correctly made.
+ // We have to set them all...
+ ApplContext ac_default = new ApplContext(default_lang);
+ String k;
+ if (ac.getLang().equals(default_lang)) {
+ Iterator it = ac_default.getMsg().properties.keySet().iterator();
+ while (it.hasNext()) {
+ k = String.valueOf(it.next());
+ context.put(k, ac.getMsg().getString(k));
+ }
+ } else {
+ Iterator it = ac_default.getMsg().properties.keySet().iterator();
+ while (it.hasNext()) {
+ k = String.valueOf(it.next());
+ if (ac.getMsg().getString(k) == null)
+ context.put(k, ac_default.getMsg().getString(k));
+ else
+ context.put(k, ac.getMsg().getString(k));
+ }
+ }
+ }
+
+ if (title.trim().startsWith("http://") || title.trim().equals("file://localhost/TextArea")) {
+ HashMap[] languages = new HashMap[Messages.languages_name.size()];
+ String name;
+ for (int i = 0; i < Messages.languages_name.size(); ++i) {
+ name = String.valueOf(Messages.languages_name.get(i));
+ HashMap l = new HashMap();
+ l.put("name", name);
+ l.put("real", ((Utf8Properties) Messages.languages.get(name)).getProperty("language_name"));
+ languages[i] = l;
+ }
+ context.put("languages", languages);
+ String link = ac.getLink().replaceAll("&lang=.*&", "&");
+ link = link.replaceAll("&lang=.*$", "");
+ context.put("link", "?" + link.replaceAll("&", "&"));
+ }
+
+ // generated values
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mss'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("warning_level", new Integer(warningLevel));
+ context.put("rules_count", new Integer(items.size()));
+ context.put("no_errors_report", new Boolean(false));
+ context.put("charset", ac.getContentEncoding());
+ context.put("cssversion", ac.getCssVersion());
+ context.put("is_valid", (errors.getErrorCount() == 0) ? "true" : "false");
+ context.put("author", "www-validator-css");
+ context.put("author-email", "Email.html");
+ if (style.charset != null)
+ context.put("style_charset", style.charset);
- DateFormat df = null;
+ produceError();
+ produceWarning();
+ produceStyleSheet();
- if (ac.getLang() != null) {
- try {
- df = DateFormat.getDateTimeInstance(DateFormat.FULL,
- DateFormat.FULL, new Locale(ac.getLang()
- .substring(0, 2), "US"));
- } catch (Exception e) {
- df = DateFormat.getDateTimeInstance(DateFormat.FULL,
- DateFormat.FULL, Locale.US);
- }
- }
- if (df != null) {
- general.put("today", df.format(new Date()));
- } else {
- general.put("today", new Date().toString());
+ try {
+ Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, this.getClass().getResource("").getPath());
+ Velocity.init();
+ template = Velocity.getTemplate(template_file);
+ } catch (ResourceNotFoundException rnfe) {
+ System.err.println(rnfe.getMessage());
+ rnfe.printStackTrace();
+ } catch (ParseErrorException pee) {
+ System.err.println(pee.getMessage());
+ pee.printStackTrace();
+ } catch (MethodInvocationException mie) {
+ System.err.println(mie.getMessage());
+ mie.printStackTrace();
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ }
}
- }
- public void desactivateError() {
- general.put("go-errors", ""); // remove go-errors
- general.put("errors", ""); // remove errors
- }
-
- /**
- * Returns a string representation of the object.
- */
- public void print(PrintWriter out) {
- this.out = out; // must be in first !
- String output = processSimple("document");
- if (output != null) {
- out.println(output);
- } else {
- out.println(ac.getMsg().getGeneratorString("request"));
+ private final static String getURLProperty(String name) {
+ return availablePropertiesURL.getProperty(name);
}
- out.flush();
- }
-
- public void produceRule() {
- Object[] array = items.getSortedArray();
- for (int i = 0; i < array.length; i++) {
- selector = (CssSelectors) array[i];
- if (!selector.isEmpty()) {
- out.print(processStyle(general.getProperty("rule"), general));
- }
- }
- }
+ private void grep(File f) throws IOException {
+ Charset charset = Charset.forName("UTF-8");
+ CharsetDecoder decoder = charset.newDecoder();
- public void produceSelector(CssSelectors selectorLocal) {
- out.print(selectorLocal);
- }
+ // Open the file and then get a channel from the stream
+ FileInputStream fis = new FileInputStream(f);
+ FileChannel fc = fis.getChannel();
- public void produceDeclaration() {
- selector.getStyle().print(this);
- }
+ // Get the file's size and then map it into memory
+ int sz = (int) fc.size();
+ MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
- public void print(CssProperty property) {
- Utf8Properties prop = new Utf8Properties(general);
- prop.put("property-name", property.getPropertyName().toString());
- prop.put("property-value", property.toString());
+ // Decode the file into a char buffer
+ CharBuffer cb = decoder.decode(bb);
- if (!property.getImportant()) {
- prop.put("important-style", "");
- }
- out.print(processStyle(prop.getProperty("declaration"), prop));
- }
+ // Perform the search
+ getVars(f, cb);
- public void produceParseException(CssParseException error, StringBuffer ret) {
- if (error.getContexts() != null && error.getContexts().size() != 0) {
- StringBuffer buf = new StringBuffer();
- for (Enumeration e = error.getContexts().elements(); e
- .hasMoreElements();) {
- Object t = e.nextElement();
- if (t != null) {
- buf.append(t);
- if (e.hasMoreElements())
- buf.append(", ");
- }
- }
- if (buf.length() != 0) {
- ret.append(ac.getMsg().getGeneratorString("context"));
- ret.append(" : <STRONG>").append(buf);
- ret.append("</STRONG> ");
- }
+ // Close the channel and the stream
+ fc.close();
}
- String name = error.getProperty();
- if ((name != null) && (getURLProperty(name) != null)) {
- ret.append(ac.getMsg().getGeneratorString("property"));
- ret.append(" : <A HREF=\"");
- ret.append(getURLProperty("@url-base"));
- ret.append(getURLProperty(name)).append("\">");
- ret.append(name).append("</A>");
+
+ private String getVar(CharSequence cs) {
+ String k = String.valueOf(cs);
+ int start = ( k.indexOf('{') == -1 ) ? (( k.indexOf('!') == -1 ) ? 1 : 2 ) : k.indexOf('{') + 1;
+ int end = ( k.indexOf('}') == -1 ) ? k.length() : k.indexOf('}');
+ return k.substring(start, end);
}
- if ((error.getException() != null) && (error.getMessage() != null)) {
- ret.append("\n<DD>");
- if (error.isParseException()) {
- ret.append(queryReplace(error.getMessage())).append('\n');
- } else {
- Exception ex = error.getException();
- if (ex instanceof NumberFormatException) {
- ret
- .append(ac.getMsg().getGeneratorString(
- "invalid-number"));
+
+
+ /**
+ * Add to the context the values of the variables in the html file
+ * The variables in the html file are getting using regular expressions
+ *
+ */
+ private void getVars(File f, CharBuffer cb) {
+ // $ [ ! ][ { ][ a..z, A..Z ][ a..z, A..Z, 0..9, -, _ ][ } ]
+ //Pattern pattern = Pattern.compile("$!?{?[a-zA-Z][a-zA-Z0-9-_]*}?");
+ Pattern pattern = Pattern.compile("\\$[!]?([a-zA-Z][a-zA-Z0-9\\-_]*)|(\\{[a-zA-Z][a-zA-Z0-9\\-_]*\\})");
+ Matcher pm = pattern.matcher(cb); // Pattern matcher
+
+ String k;
+
+ if (ac.getLang().equals(default_lang)) {
+ while (pm.find()) {
+ k = getVar(pm.group());
+ context.put(k, ac.getMsg().getString(k));
+ }
} else {
- ret.append(queryReplace(ex.getMessage()));
+ ApplContext ac_default = new ApplContext(default_lang);
+ while (pm.find()) {
+ k = getVar(pm.group());
+ if (ac.getMsg().getString(k) == null)
+ context.put(k, ac_default.getMsg().getString(k));
+ else
+ context.put(k, ac.getMsg().getString(k));
+ }
}
- }
- if (error.getSkippedString() != null) {
- ret.append(" : <STRONG>");
- ret.append(queryReplace(error.getSkippedString()));
- ret.append("</STRONG>\n");
- } else if (error.getExp() != null) {
- ret.append(" : ");
- ret.append(queryReplace(error.getExp().toStringFromStart()));
- ret.append("<STRONG>");
- ret.append(queryReplace(error.getExp().toString()));
- ret.append("</STRONG>\n");
- }
- } else {
- ret.append("\n<DD>");
- ret.append(ac.getMsg().getGeneratorString("unrecognize"));
- ret.append(" - <STRONG>");
- ret.append(queryReplace(error.getSkippedString()));
- ret.append("</STRONG>\n");
}
- }
+ /**
+ * Store the valid stylesheet into a string and add it to the context so it
+ * can be displayed
+ *
+ */
+ private void produceStyleSheet() {
+ Vector atRules = style.newGetRules();
+ String ret = "";
+ for (int idx = 0; idx < atRules.size(); idx++) {
+ ret += ((CssRuleList) atRules.elementAt(idx)).toHTML();
+ ret += "\n";
+ }
+ context.put("rules_list", ret);
+ }
- public void produceError() {
- StringBuffer ret = new StringBuffer(1024);
- String oldSourceFile = null;
+ /**
+ *
+ *
+ */
+ private void produceError() {
+ Hashtable[] errors_content = new Hashtable[errors.getErrorCount()];
- try {
- if (errors.getErrorCount() != 0) {
- int i = 0;
- ret.append("\n<UL>");
+ try {
+ if (errors.getErrorCount() != 0) {
+ int i = 0;
for (CssError[] error = errors.getErrors(); i < error.length; i++) {
- Exception ex = error[i].getException();
- String file = error[i].getSourceFile();
- if (!file.equals(oldSourceFile)) {
- oldSourceFile = file;
- /*
- * if (i != 0) { ret.append("</DL>"); }
- */
- ret.append("\n<LI><DL> URI : "
- + "<A TARGET=\"workspace\" HREF=\"");
- ret.append(file).append("\">");
- ret.append(file).append("</A>");
- }
- ret.append("\n<DT>");
- ret.append(ac.getMsg().getGeneratorString("line"));
- ret.append(": ").append(error[i].getLine());
- ret.append(' ');
- if (ex instanceof FileNotFoundException) {
- ret.append("\n<DD>");
- ret.append(ac.getMsg().getGeneratorString("not-found"));
- ret.append("<STRONG>");
- ret.append(ex.getMessage());
- ret.append("</STRONG>\n");
- } else if (ex instanceof CssParseException) {
- produceParseException((CssParseException) ex, ret);
- } else if (ex instanceof InvalidParamException) {
- ret.append("\n<DD>");
- ret.append(queryReplace(ex.getMessage())).append('\n');
- } else if (ex instanceof IOException) {
- String stringError = ex.toString();
- int index = stringError.indexOf(':');
- ret.append("\n<DD>");
- ret.append(stringError.substring(0, index));
- ret.append(" : <STRONG>");
- ret.append(ex.getMessage()).append("<STRONG>\n");
- } else if (error[i] instanceof CssErrorToken) {
- CssErrorToken terror = (CssErrorToken) error[i];
- ret.append("\n<DD>").append(" ");
- ret.append(terror.getErrorDescription()).append(" : ");
- ret.append(terror.getSkippedString()).append('\n');
- } else {
- ret.append("\n<DD>");
- ret.append("<STRONG>Uncaught error</STRONG>");
- ret.append(ex).append('\n');
-
- if (ex instanceof NullPointerException) {
- // ohoh, a bug
- ex.printStackTrace();
- }
- }
- }
- ret.append("</DL></UL>");
- }
+ Exception ex = error[i].getException();
+ errors_content[i] = new Hashtable();
+ errors_content[i].put("Error", error[i]);
+ errors_content[i].put("CtxName", "nocontext");
+ errors_content[i].put("CtxMsg", "");
+ errors_content[i].put("ErrorMsg", ((ex.getMessage() == null) ? "" : ex.getMessage()));
+ errors_content[i].put("ClassName", "unkownerror");
- out.println(ret.toString());
- } catch (Exception e) {
- out.println(ac.getMsg().getGeneratorString("request"));
- e.printStackTrace();
- }
- }
+ 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") + ": <em>" + str
+ + "</em>");
- public void produceWarning() {
+ } else if (ex instanceof CssParseException) {
+ produceParseException((CssParseException) ex, errors_content[i]);
+ } else if (ex instanceof InvalidParamException) {
+ errors_content[i].put("ClassName", "invalidparam");
- StringBuffer ret = new StringBuffer(1024);
- String oldSourceFile = "";
- int oldLine = -1;
- String oldMessage = "";
- try {
- if (warnings.getWarningCount() != 0) {
- int i = 0;
- warnings.sort();
- ret.append("\n<UL>");
- for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
+ } else if (ex instanceof IOException) {
+ String stringError = ex.toString();
+ // int index = stringError.indexOf(':');
+ // The Exception name 'StringError' was previously
+ // displayed
+ // between </td> and <td class='nocontext' ...
+ // It's now displayed inside the <td class='nocontext'>
+ // tag
+ // because we would need a new variable to put it there
+ // for
+ // just one rare case
+ // TODO: why not using ex.toString()?
+ errors_content[i].put("CtxMsg", stringError);// .substring(0,
+ // index));
+ errors_content[i].put("ClassName", "io");
- Warning warn = warning[i];
- if (warn.getLevel() <= warningLevel) {
- if (!warn.getSourceFile().equals(oldSourceFile)) {
- if (i != 0) {
- ret.append("</DL>");
- }
- oldSourceFile = warn.getSourceFile();
- ret.append("\n<LI><DL><DT> URI : "
- + "<A TARGET=\"workspace\" HREF=\"");
- ret.append(oldSourceFile).append("\">");
- ret.append(oldSourceFile).append("</A>");
+ } else if (error[i] instanceof CssErrorToken) {
+ CssErrorToken terror = (CssErrorToken) error[i];
+ errors_content[i].put("ClassName", "errortoken");
+ errors_content[i].put("ErrorMsg", terror.getErrorDescription() + " : "
+ + terror.getSkippedString());
+ } else {
+ errors_content[i].put("ClassName", "unkownerror");
+ errors_content[i].put("ErrorMsg", ac.getMsg().getErrorString("unknown") + " " + ex);
+ if (ex instanceof NullPointerException) {
+ // ohoh, a bug
+ ex.printStackTrace();
+ }
+ }
+ }
}
- if (warn.getLine() != oldLine
- || !warn.getWarningMessage().equals(oldMessage)) {
- oldLine = warn.getLine();
- oldMessage = warn.getWarningMessage();
- ret.append("\n<DD><STRONG> Line : ");
- ret.append(oldLine);
-
- if (warn.getLevel() != 0) {
- ret.append(" Level : ");
- ret.append(warn.getLevel());
- }
- ret.append(" </STRONG> ");
- ret.append(oldMessage);
+ context.put("errors_content", errors_content);
+ } catch (Exception e) {
+ context.put("errors_content", errors_content);
+ context.put("request", ac.getMsg().getGeneratorString("request"));
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
- if (warn.getContext() != null) {
- ret.append(" : ").append(warn.getContext());
- }
+ /**
+ * Add an array of warnings to the context so it c an be displayed
+ *
+ */
+ private void produceWarning() {
+ try {
+ if (warnings.getWarningCount() != 0) {
+ warnings.sort();
+ context.put("warnings_list", warnings.getWarnings());
}
- }
+ } catch (Exception e) {
+ out.println(ac.getMsg().getGeneratorString("request"));
+ e.printStackTrace();
}
- ret.append("</DL></UL>");
- }
- out.println(ret.toString());
- } catch (Exception e) {
- out.println(ac.getMsg().getGeneratorString("request"));
- e.printStackTrace();
}
- }
-
- private String queryReplace(String s) {
- if (s != null) {
- int len = s.length();
- StringBuffer ret = new StringBuffer(len);
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (c == '<') {
- ret.append("<");
- } else if (c == '>') {
- ret.append(">");
+ /**
+ *
+ * @param error
+ * @param ht_error
+ */
+ private void produceParseException(CssParseException error, Hashtable 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();) {
+ Object t = e.nextElement();
+ // if the list is not null, add a comma
+ if (t != null) {
+ buf.append(t);
+ if (e.hasMoreElements()) {
+ buf.append(", ");
+ }
+ }
+ }
+ if (buf.length() != 0)
+ ht_error.put("CtxMsg", String.valueOf(buf));
} else {
- ret.append(c);
+ ht_error.put("CtxName", "nocontext");
}
- }
- return ret.toString();
- } else {
- return "[empty string]";
- }
- }
-
- private final String processSimple(String s) {
- return processStyle(general.getProperty(s), general);
- }
-
- private String processStyle(String str, Utf8Properties prop) {
- try {
- int i = 0;
- while ((i = str.indexOf("<!-- #", i)) >= 0) {
- int lastIndexOfEntity = str.indexOf("-->", i);
- String entity = str.substring(i + 6, lastIndexOfEntity - 1)
- .toLowerCase();
- if (entity.equals("rule")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceRule();
- } else if (entity.equals("selectors")) {
- if (selector.getNext() != null) {
- // contextuals selectors
- String value = prop.getProperty(entity);
- if (value != null) {
- str = str.substring(0, i) + value
- + str.substring(lastIndexOfEntity + 3);
+ ht_error.put("ClassName", "message");
+ String name = error.getProperty();
+ String ret = "";
+ if ((name != null) && (getURLProperty(name) != null)) {
+ ret += ac.getMsg().getGeneratorString("property");
+ ret += " : <a href=\"" + getURLProperty("@url-base");
+ ret += getURLProperty(name) + "\">" + name + "</a> ";
+ }
+ if ((error.getException() != null) && (error.getMessage() != null)) {
+ if (error.isParseException()) {
+ ret += queryReplace(error.getMessage());
} else {
- i += 6; // skip this unknown entity
+ Exception ex = error.getException();
+ if (ex instanceof NumberFormatException) {
+ ret += ac.getMsg().getGeneratorString("invalid-number");
+ } else {
+ ret += queryReplace(ex.getMessage());
+ }
+ }
+ if (error.getSkippedString() != null) {
+ ret += "<span class='skippedString'>";
+ ret += queryReplace(error.getSkippedString());
+ ret += "</span>";
+ } else if (error.getExp() != null) {
+ ret += " : ";
+ ret += queryReplace(error.getExp().toStringFromStart());
+ ret += "<span class='exp'>";
+ ret += queryReplace(error.getExp().toString());
+ ret += "</span>";
}
- } else {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceSelector(selector);
- }
- } else if (entity.equals("selector")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceSelector(selector);
- } else if (entity.equals("declaration")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceDeclaration();
- } else if (entity.equals("warning")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceWarning();
- } else if (entity.equals("error")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceError();
- } else if (entity.equals("hook-html-validator")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- if (style.getType().equals("text/html")) {
- out.println(ac.getMsg().getGeneratorString("doc-html",
- general.get("file-title").toString()));
- } else {
- out.println(ac.getMsg().getGeneratorString("doc"));
- }
} else {
- String value = prop.getProperty(entity);
- if (value != null) {
- str = str.substring(0, i) + value
- + str.substring(lastIndexOfEntity + 3);
- } else {
- i += 6; // skip this unknown entity
- }
+ ret += ac.getMsg().getGeneratorString("unrecognize");
+ ret += " - <span class='other'>";
+ ret += queryReplace(error.getSkippedString());
+ ret += "</span>";
}
- }
-
- return str;
- } catch (Exception e) {
- e.printStackTrace();
- return str;
+ ht_error.put("ErrorMsg", ret);
}
- }
- public final static void printAvailableFormat(PrintWriter out) {
- Enumeration e = availableFormat.propertyNames();
- out.println(" -- listing available output format --");
- while (e.hasMoreElements()) {
- String key = ((String) e.nextElement()).toLowerCase();
- out.println("Format : " + key);
- out.println(" File : " + getDocumentName(null, key));
- }
- out.flush();
- }
+ private String queryReplace(String s) {
+ if (s != null) {
+ int len = s.length();
+ StringBuffer ret = new StringBuffer(len);
+ char c;
- private Utf8Properties setDocumentBase(String document) {
- Utf8Properties properties = (Utf8Properties) formats.get(document);
- if (properties == null) {
- URL url;
- properties = new Utf8Properties();
- try {
- url = StyleSheetGenerator.class.getResource(document);
- java.io.InputStream f = url.openStream();
- properties.load(f);
- f.close();
- properties.put("author", "www-validator-css");
- properties.put("author-email", "Email.html");
- } catch (Exception e) {
- System.err.println("org.w3c.css.css.StyleSheetGenerator: "
- + "couldn't load properties " + document);
- System.err.println(" " + e.toString());
- printAvailableFormat(new PrintWriter(System.err));
- }
- formats.put(document, properties);
+ for (int i = 0; i < len; i++) {
+ switch (c = s.charAt(i)) {
+ case '&' : ret.append("&"); break;
+ case '\'' : ret.append("'"); break;
+ case '\"' : ret.append(""e;"); break;
+ case '<' : ret.append("<"); break;
+ case '>' : ret.append(">"); break;
+ default : ret.append(c);
+ }
+ }
+ return ret.toString();
+ }
+ return "[empty string]";
}
- return new Utf8Properties(properties);
- }
-
- private final static String getDocumentName(ApplContext ac,
- String documentName) {
- documentName = documentName.toLowerCase();
- String document = null;
- if (ac != null && ac.getLang() != null) {
- StringTokenizer tokens = new StringTokenizer(ac.getLang(), ",");
-
- while (tokens.hasMoreTokens()) {
- String l = tokens.nextToken().trim().toLowerCase();
- document = availableFormat.getProperty(documentName + "." + l);
- if (document != null) {
- break;
- }
- int minusIndex = l.indexOf('-');
- if (minusIndex != -1) {
- // suppressed -cn in zh-cn (example)
- l = l.substring(0, minusIndex);
- document = availableFormat.getProperty(documentName + "."
- + l);
- }
- if (document != null) {
- break;
+ public void print(PrintWriter out) {
+ this.out = out;
+ try {
+ template.merge(context, out);
+ } catch (Exception e) {
+ new ErrorReportHTML(ac, title, "", e).print(out);
}
- }
- }
- if (document == null) {
- document = availableFormat.getProperty(documentName);
- }
- if (document == null) {
- System.err.println("Unable to find " + documentName
- + " output format");
- return documentName;
- } else {
- return document;
+ out.flush();
}
- }
- private final static String getURLProperty(String name) {
- return availablePropertiesURL.getProperty(name);
- }
-
- static {
- URL url;
- availableFormat = new Utf8Properties();
- try {
- url = StyleSheetGenerator.class.getResource("format.properties");
- java.io.InputStream f = url.openStream();
- availableFormat.load(f);
- f.close();
- } catch (Exception e) {
- System.err.println("org.w3c.css.css.StyleSheetGenerator: "
- + "couldn't load format properties ");
- System.err.println(" " + e.toString());
+ public void desactivateError() {
+ context.put("no_errors_report", new Boolean(true)); // activate the no errors report
}
- availablePropertiesURL = new Utf8Properties();
- try {
- url = StyleSheetGenerator.class.getResource("urls.properties");
- java.io.InputStream f = url.openStream();
- availablePropertiesURL.load(f);
- f.close();
- } catch (Exception e) {
- System.err.println("org.w3c.css.css.StyleSheetGenerator: "
- + "couldn't load URLs properties ");
- System.err.println(" " + e.toString());
- }
- }
}
Index: CssStyleRule.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/CssStyleRule.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CssStyleRule.java 12 Dec 2006 04:36:17 -0000 1.14
+++ CssStyleRule.java 13 Jul 2007 13:32:19 -0000 1.15
@@ -5,106 +5,98 @@
package org.w3c.css.css;
-import java.io.PrintWriter;
import java.util.Vector;
import org.w3c.css.properties.css1.CssProperty;
import org.w3c.css.util.Util;
-
public class CssStyleRule {
- public CssStyleRule(String indent, String selectors,
- Vector properties, boolean important) {
- this.selectors = selectors;
- this.properties = properties;
- this.important = important;
- this.indent = indent;
- }
-
- public String toString() {
- StringBuffer ret = new StringBuffer();
- if (selectors != null) {
- ret.append(selectors);
- ret.append(' ');
- ret.append('{');
- ret.append('\n');
+ public CssStyleRule(String indent, String selectors, Vector properties, boolean important) {
+ this.selectors = selectors;
+ this.properties = properties;
+ this.indent = indent;
}
- for (int i = 0; i < properties.size() ; i++) {
- CssProperty property = (CssProperty)properties.elementAt(i);
- ret.append(indent);
- ret.append(" ");
- ret.append(property.getPropertyName());
- ret.append(" : ");
- ret.append(property.toString());
- if (property.getImportant()) {
- ret.append(" important");
- }
- ret.append(';');
- ret.append('\n');
- }
- if (selectors != null) {
- ret.append(indent);
- ret.append('}');
- ret.append('\n');
- ret.append('\n');
+ public String toString() {
+ StringBuffer ret = new StringBuffer();
+ if (selectors != null) {
+ ret.append(selectors);
+ ret.append(' ');
+ ret.append('{');
+ ret.append('\n');
+ }
+
+ for (int i = 0; i < properties.size(); i++) {
+ CssProperty property = (CssProperty) properties.elementAt(i);
+ ret.append(indent);
+ ret.append(" ");
+ ret.append(property.getPropertyName());
+ ret.append(" : ");
+ ret.append(property.toString());
+ if (property.getImportant()) {
+ ret.append(" important");
+ }
+ ret.append(';');
+ ret.append('\n');
+ }
+ if (selectors != null) {
+ ret.append(indent);
+ ret.append('}');
+ ret.append('\n');
+ ret.append('\n');
+ }
+ return ret.toString();
}
- return ret.toString();
- }
- /*
- public String toHTML() {
- StringBuffer ret = new StringBuffer("<li><span class='selector'>");
- if (selectors != null) {
- ret.append(selectors);
- ret.append("</span> {<ul class='vRule'>\n");
- }
- for (int i = 0; i < properties.size() ; i++) {
- CssProperty property = (CssProperty)properties.elementAt(i);
- ret.append("<li>");
- ret.append(property.getPropertyName());
- ret.append(" : <span class='vPropertyValue'>");
- ret.append(property.toString());
- ret.append("</span>");
- if (property.getImportant()) {
- ret.append(" !important");
- }
- ret.append(";</li>\n");
- }
- ret.append("</ul>}</li>\n\n");
- return ret.toString();
- }
- */
- public void toHTML(PrintWriter out) {
- if(properties != null) {
- out.print("<div class='selector'>\n<span class='selectorValue'>");
- if (selectors != null) {
- out.print(selectors);
- out.print("</span> {\n<div class='RuleList'>\n");
- }
+ /*
+ * public String toHTML() { StringBuffer ret = new StringBuffer("<li><span
+ * class='selector'>"); if (selectors != null) { ret.append(selectors);
+ * ret.append("</span> {<ul class='vRule'>\n"); }
+ *
+ * for (int i = 0; i < properties.size() ; i++) { CssProperty property =
+ * (CssProperty)properties.elementAt(i); ret.append("<li>");
+ * ret.append(property.getPropertyName()); ret.append(" : <span
+ * class='vPropertyValue'>"); ret.append(property.toString()); ret.append("</span>");
+ * if (property.getImportant()) { ret.append(" !important"); } ret.append(";</li>\n"); }
+ * ret.append("</ul>}</li>\n\n"); return ret.toString(); }
+ */
+
+ /**
+ * This method returns a part of the style sheet to be displayed
+ * Some identation (\t) was necessary to maintain the correct formatting
+ * of the html output.
+ */
+ public String toHTML() {
+ String ret = "";
+ if (properties != null) {
+ ret = "\n\t\t\t\t<div class='selector'>\n\t\t\t\t\t<span class='selectorValue'>";
+ if (selectors != null) {
+ ret += selectors;
+ ret += "</span> {\n\t\t\t\t\t<div class='RuleList'>\n";
+ }
- for (int i = 0; i < properties.size() ; i++) {
- CssProperty property = (CssProperty)properties.elementAt(i);
- out.print(" <div class='Rule'>");
- out.print("<span class='Property'>");
- out.print(Util.escapeHTML(property.getPropertyName()));
- out.print("</span>");
- out.print(" : <span class='PropertyValue'>");
- out.print(Util.escapeHTML(property.toString()));
- out.print("</span>");
- if (property.getImportant()) {
- out.print(" !important");
+ for (int i = 0; i < properties.size(); i++) {
+ CssProperty property = (CssProperty) properties.elementAt(i);
+ ret += "\t\t\t\t\t\t<div class='Rule'>";
+ ret += "<span class='Property'>";
+ ret += Util.escapeHTML(property.getPropertyName());
+ ret += "</span>";
+ ret += " : <span class='PropertyValue'>";
+ ret += Util.escapeHTML(property.toString());
+ ret += "</span>";
+ if (property.getImportant()) {
+ ret += " !important";
+ }
+ ret += ";</div>\n";
+ }
+ ret += "\t\t\t\t\t</div>}\n\t\t\t\t</div>\n\n";
}
- out.print(";</div>\n");
- }
- out.print("</div>}\n</div>\n\n");
+ return ret;
}
- }
- private String indent;
- private String selectors;
- private Vector properties;
- private boolean important;
+ private String indent;
+ private String selectors;
+ private Vector properties;
}
Index: StyleSheetGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- StyleSheetGenerator.java 14 Sep 2005 15:14:17 -0000 1.6
+++ StyleSheetGenerator.java 13 Jul 2007 13:32:19 -0000 1.7
@@ -1,9 +1,4 @@
-//
-// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
-//
-// (c) COPYRIGHT MIT and INRIA, 1997.
-// Please first read the full copyright statement in file COPYRIGHT.html
+/* Remade by Sijtsche de Jong */
package org.w3c.css.css;
@@ -13,11 +8,11 @@
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Vector;
import org.w3c.css.parser.CssError;
import org.w3c.css.parser.CssErrorToken;
import org.w3c.css.parser.CssParseException;
-import org.w3c.css.parser.CssPrinterStyle;
import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.Errors;
import org.w3c.css.properties.css1.CssProperty;
@@ -31,7 +26,7 @@
/**
* @version $Revision$
*/
-public final class StyleSheetGenerator implements CssPrinterStyle {
+public final class StyleSheetGenerator extends StyleReport {
// SortedHashtable items;
Hashtable items;
@@ -48,14 +43,14 @@
private int warningLevel;
- private Utf8Properties general;
+ private Utf8Properties general;
- private static Utf8Properties availableFormat;
+ private static Utf8Properties availableFormat;
private static Hashtable formats = new Hashtable();
/**
- * Create a new StyleSheetGenerator
+ * Create a new StyleSheetGenerator2
*
* @param title
* The title for the generated document
@@ -66,8 +61,21 @@
* @param warningLevel
* If you want to reduce warning output. (-1 means no warnings)
*/
- public StyleSheetGenerator(String title, StyleSheet style, String document,
- int warningLevel) {
+ public StyleSheetGenerator(String title, StyleSheet style,
+ String document, int warningLevel) {
+
+ // this small part prints the stylesheet to the screen
+ 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());
+ }
+ }
general = new Utf8Properties(setDocumentBase(getDocumentName(document)));
general.put("file-title", title);
@@ -75,7 +83,6 @@
warnings = style.getWarnings();
errors = style.getErrors();
- // items = (SortedHashtable) style.getRules();
items = style.getRules();
this.warningLevel = warningLevel;
@@ -105,6 +112,7 @@
if (Util.onDebug)
general.list(System.err);
+
}
public void desactivateError() {
@@ -118,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 {
@@ -130,42 +139,6 @@
out.flush();
}
- public void produceRule() {
- // Object[] array = items.getSortedArray();
- int i = 0;
- Object array[] = new Object[items.size()];
- for (Enumeration e = items.elements(); e.hasMoreElements(); i++) {
- array[i] = e.nextElement();
- }
-
- for (int idx = 0; idx < array.length; idx++) {
- selector = (CssSelectors) array[idx];
- if (!selector.isEmpty()) {
- out.print(processStyle(general.getProperty("rule"), general));
- }
- }
- }
-
- public void produceSelector(CssSelectors selectorLocal) {
- // out.print(selectorLocal.getAtRule());
- out.print(selectorLocal);
- }
-
- public void produceDeclaration() {
- selector.getStyle().print(this);
- }
-
- public void print(CssProperty property) {
- Utf8Properties prop = new Utf8Properties(general);
- prop.put("property-name", property.getPropertyName().toString());
- prop.put("property-value", property.toString());
-
- if (!property.getImportant()) {
- prop.put("important-style", "");
- }
- out.print(processStyle(prop.getProperty("declaration"), prop));
- }
-
void produceParseException(CssParseException error, StringBuffer ret) {
if (error.getContexts() != null && error.getContexts().size() != 0) {
StringBuffer buf = new StringBuffer();
@@ -269,7 +242,7 @@
}
out.println(ret.toString());
} catch (Exception e) {
- out.println("An error appears during error's output, sorry.");
+ out.println("An error appears during error's ouput, sorry.");
e.printStackTrace();
}
}
@@ -283,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) {
@@ -292,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);
@@ -309,7 +283,7 @@
}
ret.append(" \n");
- }
+ //}
}
}
}
@@ -332,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 "";
}
@@ -343,41 +317,8 @@
int lastIndexOfEntity = str.indexOf("-->", i);
String entity = str.substring(i + 6, lastIndexOfEntity - 1)
.toLowerCase();
- if (entity.equals("rule")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceRule();
- } else if (entity.equals("selectors")) {
- out.print(selector.getAtRule() + "{\n");
- if (selector.getNext() != null) {
- // contextuals selectors
- String value = prop.getProperty(entity);
- if (value != null) {
- str = str.substring(0, i) + value
- + str.substring(lastIndexOfEntity + 3);
- } else {
- i += 6; // skip this unknown entity
- }
- } else {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceSelector(selector);
- }
- out.print("}\n");
- } else if (entity.equals("selector")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceSelector(selector);
- } else if (entity.equals("declaration")) {
- out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity + 3);
- i = 0;
- produceDeclaration();
- } else if (entity.equals("warning")) {
+ if (entity.equals("warning")) {
out.print(str.substring(0, i));
str = str.substring(lastIndexOfEntity + 3);
i = 0;
@@ -397,7 +338,10 @@
}
}
}
-
+ /*
+ * if (errors.getErrorCount() == 0 && warnings.getWarningCount() ==
+ * 0) { out.print("No errors or warnings found"); }
+ */
return str;
} catch (Exception e) {
e.printStackTrace();
--- xhtml.properties.de DELETED ---
Index: StyleSheetCom.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetCom.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- StyleSheetCom.java 24 Apr 2007 11:14:22 -0000 1.17
+++ StyleSheetCom.java 13 Jul 2007 13:32:19 -0000 1.18
@@ -60,14 +60,14 @@
if (style != null) {
style.findConflicts(ac);
if (documentBase.startsWith("html")) {
- StyleSheetGeneratorHTML2 output =
- new StyleSheetGeneratorHTML2(ac, file,
+ StyleSheetGeneratorHTML output =
+ new StyleSheetGeneratorHTML(ac, file,
style,
documentBase,
warningLevel);
output.print(out);
} else {
- StyleSheetGenerator2 style2 = new StyleSheetGenerator2(file,
+ StyleSheetGenerator style2 = new StyleSheetGenerator(file,
style,
documentBase,
warningLevel);
@@ -91,14 +91,14 @@
if (style != null) {
style.findConflicts(ac);
if (documentBase.startsWith("html")) {
- StyleSheetGeneratorHTML2 output =
- new StyleSheetGeneratorHTML2(ac, file,
+ StyleSheetGeneratorHTML output =
+ new StyleSheetGeneratorHTML(ac, file,
style,
documentBase,
warningLevel);
output.print(out);
} else {
- StyleSheetGenerator2 style2 = new StyleSheetGenerator2(file,
+ StyleSheetGenerator style2 = new StyleSheetGenerator(file,
style,
documentBase,
warningLevel);
@@ -140,15 +140,15 @@
}
});
} else if (documentBase.startsWith("html")) {
- StyleSheetGeneratorHTML2 output =
- new StyleSheetGeneratorHTML2(ac, file,
+ StyleSheetGeneratorHTML output =
+ new StyleSheetGeneratorHTML(ac, file,
parser.getStyleSheet(),
documentBase,
warningLevel);
output.print(out);
} else {
- StyleSheetGenerator2 output =
- new StyleSheetGenerator2(file,
+ StyleSheetGenerator output =
+ new StyleSheetGenerator(file,
parser.getStyleSheet(),
documentBase,
warningLevel);
Index: XMLStyleSheetHandler.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/XMLStyleSheetHandler.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- XMLStyleSheetHandler.java 16 Dec 2006 20:22:27 -0000 1.24
+++ XMLStyleSheetHandler.java 13 Jul 2007 13:32:19 -0000 1.25
@@ -45,688 +45,696 @@
/**
* @version $Revision$
- * @author Philippe Le Hegaret
+ * @author Philippe Le Hegaret
*/
-public class XMLStyleSheetHandler implements ContentHandler,
- LexicalHandler, ErrorHandler, EntityResolver {
+public class XMLStyleSheetHandler implements ContentHandler, LexicalHandler,
+ ErrorHandler, EntityResolver {
[...1258 lines suppressed...]
+ value.append('\'');
+ } else {
+ return table;
+ }
+ state -= 10;
+ break;
+ default:
+ return table;
+ }
+ }
+ current++;
+ }
+ if (name.length() != 0 && value.length() != 0) {
+ table.put(name.toString(), value.toString());
+ }
+ return table;
}
- return table;
- }
}
--- StyleSheetGeneratorHTML2.java DELETED ---
Index: xml.properties
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/xml.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- xml.properties 13 Mar 2002 19:55:01 -0000 1.1
+++ xml.properties 13 Jul 2007 13:32:19 -0000 1.2
@@ -1,60 +1,22 @@
-important-style: \ important
-
-rules: \
-<!-- #rule -->
-
-rule: \
-\n<rule>\n\
-<!-- #selectors -->\
-<!-- #declaration -->\
-</rule>\n
-
-selectors: \
-\ \ <context-sensitive>\n\
- <!-- #selector -->\
-\ \ </context-sensitive>\n
-
-selector: \ \ \
-<selector\
-<!-- #element-style -->\
-<!-- #id-style -->\
-<!-- #class-style -->\
-<!-- #pseudo-class-style -->\
-<!-- #pseudo-element-style -->\
-/>\n
-
-element-style:\
-\ type="<!-- #element -->"
-
-id-style:\
-\ id="<!-- #id -->"
-
-class-style:\
-\ class="<!-- #class -->"
-
-pseudo-class-style:\
-\ pseudo-class="<!-- #pseudo-class -->"
-
-pseudo-element-style:\
-\ pseudo-element="<!-- #pseudo-element -->"
-
-
-declaration: \
-\ \ <declaration \
-property="<!-- #property-name -->" value="<!-- #property-value -->"<!-- #important-style -->\
-/>\n
-
-document: \
-<?xml version="1.0"?>\n\n\
-<!DOCTYPE xml-css>\n\
-<xml-css>\n\
-<!-- file : <!-- #file-title --> -->\n\
-<!-- \n\
-It is an XML test and may be updated, replaced or obsoleted by other\n\
-documents at any time.\n\
-It is inappropriate to use W3C Working Drafts as reference material or to\n\
-cite them as other than "work in progress".\n\
--->\n\
-<!-- #rules -->\n\
+<?xml version="1.0"?>
+<!DOCTYPE xml-css>
+<xml-css>
+<!-- file : $file_title -->
+<!--
+It is an XML test and may be updated, replaced or obsoleted by other
+documents at any time.
+It is inappropriate to use W3C Working Drafts as reference material or to
+cite them as other than "work in progress".
+-->
+ <rule>
+ <selector type="$element"
+ id="$id"
+ class="$class"
+ pseudo-class="$pseudo-class"
+ pseudo-element="$pseudo-element" />
+ <declaration property="$property-name"
+ value="$property-value"
+ important />
+ </rule>
</xml-css>
--- xhtml.properties.ja DELETED ---
--- xhtml.properties.nl DELETED ---
--- ucn.properties.en DELETED ---
--- NEW FILE: ucn.properties ---
<?xml version='1.0' encoding="$charset"?>
<observationresponse xmlns="http://www.w3.org/unicorn/observationresponse"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/unicorn/observationresponse file:observer-response.xsd">
<uri>$file_title</uri>
<checkedby>http://jigsaw.w3.org/css-validator/</checkedby>
<version>$cssversion</version>
<date>$currentdate</date>
<passed>$is_valid</passed>
<result>
#if ( $errors_count > 0 )
<errors xml:lang="$lang">
<errorcount>$errors_count</errorcount>
#foreach ( $error_content in $errors_content )
#set ( $err = $error_content.get("Error") )
#set ( $error_msg = $error_content.get("ErrorMsg") )
#set ( $context_name = $error_content.get("CtxName") )
#set ( $context_msg = $error_content.get("CtxMsg") )
#set ( $class_name = $error_content.get("ClassName") )
<error>
<line_number>$err.Line</line_number>
<context_msg name="$context_name">#if ( $context_msg ) $context_msg #end</context_msg>
<message name="$class_name">$error_msg</message>
</error>
#end
</errors>
#end
#if ( $warnings_count > 0 )
<warnings xml:lang="$lang">
<warningcount>$warnings_count</warningcount>
#foreach ( $warning in $warnings_list )
<warning>
<line_number>$warning.Line</line_number>
<code_context>#if ( $warning.Context ) $warning.Context #end</code_context>
<message level="$warning.Level">$warning.WarningMessage</message>
</warning>
#end
</warnings>
#end
#if ( $errors_count == 0 )
<informations xml:lang="$lang">
<infocount>1</infocount>
<infolist>
<uri>$file_title</uri>
<info>
<message>$doc_validates</message>
<longmessage>
<a href="http://jigsaw.w3.org/css-validator/">
<img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="$valid_CSS" />
</a>
</longmessage>
<longmessage>$no_errors_interoperable_msg</longmessage>
<longmessage>
<code>
<p>
<a href="http://jigsaw.w3.org/css-validator/">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!" />
</a>
</p>
</code>
($no_errors_close_tags_msg)
</longmessage>
<longmessage>$no_errors_dl_local_msg</longmessage>
<longmessage>$no_errors_create_link_msg</longmessage>
<longmessage>
<code>
http://jigsaw.w3.org/css-validator/validator?uri=http://www.w3.org
or http://jigsaw.w3.org/css-validator/check/referer
</code>
($no_errors_forHTML_only_msg)
</longmessage>
<longmessage>($no_errors_bookmark_msg)</longmessage>
<longmessage>$note_valide_html</longmessage>
</info>
</infolist>
</informations>
#end
</result>
</observationresponse>
--- StyleSheetGenerator2.java DELETED ---
--- NEW FILE: .cvsignore ---
observer-response.xsd
properties.zip
Index: StyleReportFactory.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleReportFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- StyleReportFactory.java 12 Dec 2006 07:13:26 -0000 1.8
+++ StyleReportFactory.java 13 Jul 2007 13:32:19 -0000 1.9
@@ -9,37 +9,16 @@
public class StyleReportFactory {
- /**
- * Give back a "StyleReport" object based on various
- * parameters, but mainly output"
- */
- public static StyleReport getStyleReport(ApplContext ac,
- String title,
- StyleSheet style,
- String document,
- int warningLevel) {
- if ((document == null) || (document.equals("html"))
- || (document.equals("xhtml"))) {
- return new StyleSheetGeneratorHTML2(ac, title, style,
- "xhtml", // getting rid of duplicate templates
- warningLevel);
- }
- if (document.equals("soap12")) {
- return new StyleReportSOAP12(ac, title, style,
- document,
- warningLevel);
- }
- if(document.equals("text")) {
- return new StyleSheetGenerator2(title, style,
- document,
- warningLevel);
- }
- if(document.equals("ucn")) {
- return new StyleReportUCN(ac, title, style, document, warningLevel);
+ /**
+ * Give back a "StyleReport" object based on various parameters, but mainly
+ * output"
+ */
+ public static StyleReport getStyleReport(ApplContext ac, String title,
+ StyleSheet style, String document, int warningLevel) {
+ if (document.equals("text"))
+ return new StyleSheetGenerator(title, style, document, warningLevel);
+ if (document.equals("soap12") || document.equals("ucn") || document.equals("xml"))
+ return new StyleSheetGeneratorHTML(ac, title, style, document, warningLevel);
+ return new StyleSheetGeneratorHTML(ac, title, style, "xhtml", warningLevel);
}
- return new StyleSheetGeneratorHTML2(ac, title, style,
- "xhtml",
- warningLevel);
- }
}
-
Index: NewStyleSheet.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/NewStyleSheet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- NewStyleSheet.java 8 Aug 2005 13:18:04 -0000 1.4
+++ NewStyleSheet.java 13 Jul 2007 13:32:19 -0000 1.5
@@ -16,104 +16,113 @@
public class NewStyleSheet {
- String uri;
- String title;
- private Errors errors;
- private Warnings warnings;
+ String uri;
+ String title;
+ private Errors errors;
+ private Warnings warnings;
- /**
- * Add some errors to this style.
- *
- * @param errors Some errors.
- */
- public void addErrors(Errors errors) {
- if (errors.getErrorCount() != 0) {
- getErrors().addErrors(errors);
+ /**
+ * Add some errors to this style.
+ *
+ * @param errors
+ * Some errors.
+ */
+ public void addErrors(Errors errors) {
+ if (errors.getErrorCount() != 0) {
+ getErrors().addErrors(errors);
+ }
}
- }
- /**
- * Add some warnings to this style.
- *
- * @param warnings Some warnings.
- */
- public void addWarnings(Warnings warnings) {
- if (warnings.getWarningCount() != 0)
- getWarnings().addWarnings(warnings);
- }
+ /**
+ * Add some warnings to this style.
+ *
+ * @param warnings
+ * Some warnings.
+ */
+ public void addWarnings(Warnings warnings) {
+ if (warnings.getWarningCount() != 0)
+ getWarnings().addWarnings(warnings);
+ }
- /**
- * Returns all errors.
- */
- public final Errors getErrors() {
- return errors;
- }
+ /**
+ * Returns all errors.
+ */
+ public final Errors getErrors() {
+ return errors;
+ }
- /**
- * Returns all warnings.
- */
- public final Warnings getWarnings() {
- return warnings;
- }
+ /**
+ * Returns all warnings.
+ */
+ public final Warnings getWarnings() {
+ return warnings;
+ }
- static Vector atRuleList = new Vector(); //contains all @rules (CssRuleLists)
+ static Vector atRuleList = new Vector(); // contains all @rules
- public void newAtRule(AtRule atRule) {
- CssRuleList rulelist = new CssRuleList();
- rulelist.addAtRule(atRule);
- atRuleList.addElement(rulelist);
- indent = " ";
- }
+ // (CssRuleLists)
- public void endOfAtRule() {
- CssRuleList rulelist = new CssRuleList();
- atRuleList.addElement(rulelist); //for the new set of rules
- pseudopage = "";
- important = false;
- selectortext = "";
- indent = "";
- }
+ public void newAtRule(AtRule atRule) {
+ CssRuleList rulelist = new CssRuleList();
+ rulelist.addAtRule(atRule);
+ atRuleList.addElement(rulelist);
+ indent = " ";
+ }
- public void setImportant(boolean important) {
- this.important = important;
- }
+ public void endOfAtRule() {
+ CssRuleList rulelist = new CssRuleList();
+ atRuleList.addElement(rulelist); // for the new set of rules
+ pseudopage = "";
+ important = false;
+ selectortext = "";
+ indent = "";
+ }
- public void setSelectorList(Vector selectors) {
- String slave = selectors.toString();
- slave = slave.substring(slave.indexOf("[") + 1, slave.indexOf("]"));
- selectortext = slave;
- }
+ public void setImportant(boolean important) {
+ this.important = important;
+ }
- public void setProperty(Vector properties) {
- this.properties = properties;
- }
+ public void setSelectorList(Vector selectors) {
+ String slave = selectors.toString();
+ slave = slave.substring(slave.indexOf("[") + 1, slave.indexOf("]"));
+ selectortext = slave;
+ }
- public void endOfRule() {
- CssStyleRule stylerule = new CssStyleRule(indent, selectortext,
- properties, important);
- CssRuleList rulelist;
- if (!atRuleList.isEmpty()) {
- rulelist = (CssRuleList)atRuleList.lastElement();
- useless = atRuleList.removeElement(rulelist);
- } else {
- rulelist = new CssRuleList();
+ public void setProperty(Vector properties) {
+ this.properties = properties;
}
- rulelist.addStyleRule(stylerule);
- atRuleList.addElement(rulelist);
- }
- public void pseudoPage(String name) {
- pseudopage = name;
- }
+ public void endOfRule() {
+ CssStyleRule stylerule = new CssStyleRule(indent, selectortext,
+ properties, important);
+ CssRuleList rulelist;
+ if (!atRuleList.isEmpty()) {
+ rulelist = (CssRuleList) atRuleList.lastElement();
+ useless = atRuleList.removeElement(rulelist);
+ } else {
+ rulelist = new CssRuleList();
+ }
+ rulelist.addStyleRule(stylerule);
+ atRuleList.addElement(rulelist);
+ }
- public Vector getRules() {
- return atRuleList;
- }
+ public void pseudoPage(String name) {
+ pseudopage = name;
+ }
- static String pseudopage;
- static String selectortext;
- static boolean important;
- static Vector properties;
- boolean useless;
- static String indent = new String();
+ public Vector getRules() {
+ return atRuleList;
+ }
+
+ static String pseudopage;
+
+ static String selectortext;
+
+ static boolean important;
+
+ static Vector properties;
+
+ boolean useless;
+
+ static String indent = new String();
}
--- xhtml.properties.es DELETED ---
--- xhtml.properties.en DELETED ---
Index: format.properties
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/format.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- format.properties 15 Dec 2006 02:09:31 -0000 1.7
+++ format.properties 13 Jul 2007 13:32:19 -0000 1.8
@@ -1,21 +1,7 @@
-# Available output format for the StyleSheetGenerator
+# Available output format for the StyleSheetGeneratorHTML & StyleSheetGenerator(text)
-# be careful, errors and warnings are not yet implemented
-xhtml: xhtml.properties.en
-xhtml.zh-cn: xhtml.properties.zh-cn
-xhtml.zh: xhtml.properties.zh-cn
-xhtml.en: xhtml.properties.en
-xhtml.ja: xhtml.properties.ja
-xhtml.fr: xhtml.properties.fr
-xhtml.es: xhtml.properties.es
-xhtml.de: xhtml.properties.de
-xhtml.nl: xhtml.properties.nl
-xhtml.pl: xhtml.properties.pl-PL
-xhtml.pl-PL: xhtml.properties.pl-PL
-xhtml.it: xhtml.properties.it
+xhtml: xhtml.properties
xml: xml.properties
text: text.properties
-soap12.en: soap12.properties.en
-soap12: soap12.properties.en
-ucn.en: ucn.properties.en
-ucn: ucn.properties.en
\ No newline at end of file
+soap12: soap12.properties
+ucn: ucn.properties
\ No newline at end of file
--- xhtml.properties.zh-cn DELETED ---
--- StyleReportSOAP12.java DELETED ---
Index: StyleSheet.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheet.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- StyleSheet.java 16 Dec 2006 20:22:27 -0000 1.12
+++ StyleSheet.java 13 Jul 2007 13:32:19 -0000 1.13
@@ -178,7 +178,7 @@
}
/**
- * Returns the uniq context for a context
+ * Returns the unique context for a context
*
* @param selector the context to find.
*/
--- StyleReportUCN.java DELETED ---
--- xhtml.properties.it DELETED ---
--- NEW FILE: xhtml.properties ---
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<title>$W3C_validator_results $file_title</title>
<link href="http://jigsaw.w3.org/css-validator/" rel="validator" />
<link type="text/css" rel='stylesheet' href='style/base.css' />
<link type="text/css" rel='stylesheet' href='style/results.css' />
</head>
<body>
#if ( $link )
<ul id="lang_choice">
#foreach ( $language in $languages )
#set ( $name = $language.get("name") )
#if ( $language.get("real") )
#set ( $real = $language.get("real") )
#else
#set ( $real = $language.get("name") )
#end
<li><a href="$link&lang=$name"
lang="$name"
xml:lang="$name"
hreflang="$name"
rel="alternate">$real</a>
</li>
#end
</ul>
#end
<div id="banner">
<h1 id="title">
<a href="http://www.w3.org/">
<img height="48" alt="W3C" id="logo" src="http://www.w3.org/Icons/WWW/w3c_home_nb" />
</a>
<a href="./">
<img src="images/css_validation_service.png" alt="$CSS_validation_service" />
</a>
</h1>
</div>
<p id="tagline"></p>
<ul class="navbar" id="jumpbar">
<li><strong>$jump_to:</strong></li>
#if ($errors_count > 0)
<li><a href="#errors">$errors ($errors_count)</a></li>
#end
#if ($warnings_count > 0)
<li><a href="#warnings">$warnings ($warnings_count)</a></li>
#end
<li><a href="#css">$validated_CSS</a></li>
</ul>
<h2>$W3C_validator_results <a href="$file_title">$file_title</a></h2>
#if ( !$no_errors_report )
#if ($errors_count == 0)
<!-- NO ERRORS -->
<div id='congrats'>
<h3>$congrats</h3>
<p>
<a style="float: right" href="http://jigsaw.w3.org/css-validator/">
<img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="$valid_CSS" />
</a>
$doc_validates
</p>
<p>
$no_errors_interoperable_msg
</p>
<pre class='example'>
<p>
<a href="http://jigsaw.w3.org/css-validator/">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="$valid_CSS" />
</a>
</p>
</pre>
<p>($no_errors_close_tags_msg)</p>
<p>
$no_errors_dl_local_msg
</p>
<p>
$no_errors_create_link_msg
</p>
<pre>
http://jigsaw.w3.org/css-validator/validator?uri=$file_title
or http://jigsaw.w3.org/css-validator/check/referer ($no_errors_forHTML_only_msg)
</pre>
<p>($no_errors_bookmark_msg)</p>
</div>
<p class="backtop"><a href="#banner">↑ $top</a></p>
#else
<!-- DEALING WITH ERRORS -->
#if ( $hook_html_validator )
$hook_html_validator
#end
#set ( $sf = "" )
#set ( $open = false )
<div id="errors">
<h3>$errors_sorry_msg ($errors_count)</h3>
#if ( $request )
<h4>$request</h4>
#end
<div class='error-section-all'>
#foreach ( $error_content in $errors_content )
#set ( $err = $error_content.get("Error") )
#set ( $error_msg = $error_content.get("ErrorMsg") )
#set ( $context_name = $error_content.get("CtxName") )
#set ( $context_msg = $error_content.get("CtxMsg") )
#set ( $class_name = $error_content.get("ClassName") )
#if ( $sf != $err.SourceFile )
#if ( $open )
</table>
<!--end of individual error section-->
</div>
#end
#set ( $sf = $err.SourceFile )
<div class='error-section'>
<h4>URI : <a href="$sf">$sf</a></h4>
<table>
#set ( $open = true )
#end
<tr class='error'>
<td class='linenumber' title='Line $err.Line'>$err.Line</td>
<td class='$context_name'>#if ( $context_msg ) $context_msg #end</td>
<td class='$class_name'>$error_msg</td>
</tr>
#end
#if ( $open )
</table>
</div>
#end
</div>
</div>
<p class="backtop"><a href="#banner">↑ $top</a></p>
#end
#end
#if ($warnings_count > 0)
<!-- DEALING WITH WARNINGS -->
<div id="warnings">
<h3>$warnings ($warnings_count)</h3>
<div class='warning-section-all'>
#set ( $sf = "" )
#set ( $open = false )
#foreach ( $warning in $warnings_list )
#if ( $sf != $warning.SourceFile )
#if ( $open )
</table>
<!--end of individual warning section-->
</div>
#end
#set ( $sf = $warning.SourceFile )
<div class='warning-section'>
<h4>URI : <a href="$sf">$sf</a></h4>
<table>
#set ( $open = true )
#end
#if ( $warning.Level <= $warning_level )
<tr class='warning'>
<td class='linenumber' title='Line $warning.Line'>$warning.Line</td>
<td class='codeContext'>#if ( $warning.Context ) $warning.Context #end</td>
<td class='level$warning.Level' title='warning level $warning.Level'>$warning.WarningMessage</td>
</tr>
#end
#end
#if ( $open )
</table>
</div>
#end
</div>
</div>
<p class="backtop"><a href="#banner">↑ $top</a></p>
#end
<div id="css">
#if ($rules_count > 0 && $rules_list && $rules_list != "")
<h3>$valid_CSS_info</h3>
<div class='vAtRule'>
#if ($style_charset)
<div class='vCharset'>@charset "$charset";</div>
#end
$rules_list
</div>
#else
<h2>$CSS_not_found</h2>
#end
</div>
<p class="backtop"><a href="#banner">↑ $top</a></p>
<ul class="navbar" id="menu">
<li><strong><a href="./" title="$home_title">$home</a></strong> <span class="hideme">|</span></li>
<li><a href="about.html" title="$about_title">$about</a> <span class="hideme">|</span></li>
<li><a href="documentation.html" title="$doc_title">$doc</a> <span class="hideme">|</span></li>
<li><a href="DOWNLOAD.html" title="$dl_title">$dl</a> <span class="hideme">|</span></li>
<li><a href="Email.html" title="$feedback_title">$feedback</a> <span class="hideme">|</span></li>
<li><a href="thanks.html" title="$credits_title">$credits</a></li>
</ul>
<p id="activity_logos">
<a href="http://www.w3.org/QA/" title="$W3C_quality_msg"><img src="http://www.w3.org/QA/2002/12/qa-small.png" alt="QA" /></a><a href="http://www.w3.org/Style/CSS/learning" title="$learn_more_msg"><img src="images/woolly-icon" alt="CSS" /></a>
</p>
<p id="support_logo">
$support<br />
<a href="http://www.w3.org/Consortium/supporters">
<img src="http://www.w3.org/Consortium/supporter-logos/csupporter.png" alt="$supporter" />
</a>
</p>
<p class="copyright">
<a rel="Copyright" href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
© 1994-2007
<a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a>®
(<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>,
<a href="http://www.ercim.org/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>),
All Rights Reserved.
W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
<a rel="Copyright" href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a>
and <a rel="Copyright" href="http://www.w3.org/Consortium/Legal/copyright-software">software licensing</a>
rules apply. Your interactions with this site are in accordance
with our <a href="http://www.w3.org/Consortium/Legal/privacy-statement#Public">public</a> and
<a href="http://www.w3.org/Consortium/Legal/privacy-statement#Members">Member</a> privacy statements.
</p>
</body>
</html>
Index: CssRuleList.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/CssRuleList.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CssRuleList.java 12 Dec 2006 04:36:17 -0000 1.14
+++ CssRuleList.java 13 Jul 2007 13:32:19 -0000 1.15
@@ -5,7 +5,6 @@
package org.w3c.css.css;
-import java.io.PrintWriter;
import java.util.Vector;
import org.w3c.css.parser.AtRule;
@@ -13,142 +12,115 @@
public class CssRuleList {
- AtRule atRule;
- String atRuleString;
- Vector rulelist;
- public String pseudopage;
- String indent;
-
- public CssRuleList() {
- atRule = null;
- atRuleString = new String();
- rulelist = new Vector();
- String pseudopage = new String();
- indent = new String();
- }
-
- public void addStyleRule(CssStyleRule stylerule) {
- rulelist.addElement(stylerule);
- }
-
- public Vector getStyleRules() {
- return rulelist;
- }
-
- public void addAtRule(AtRule atRule) {
- this.atRule = atRule;
- atRuleString = atRule.toString();
- }
+ AtRule atRule;
+ String atRuleString;
+ Vector rulelist;
+ public String pseudopage;
+ String indent;
- public String getAtRule() {
- return atRuleString;
- }
+ public CssRuleList() {
+ atRule = null;
+ atRuleString = new String();
+ rulelist = new Vector();
+ indent = new String();
+ }
- 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));
- }
+ public void addStyleRule(CssStyleRule stylerule) {
+ rulelist.addElement(stylerule);
+ }
- if (!atRuleString.equals("")) {
- ret.append("}\n");
- }
+ public Vector getStyleRules() {
+ return rulelist;
}
- 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(' ');
- ret.append('\n');
- }
- } else {
- if (!atRuleString.equals("")) {
- ret.append(atRuleString);
- ret.append(' ');
- ret.append('{');
- ret.append('\n');
- indent = " ";
- }
- for (int i = 0; i < rulelist.size() ; i++ ) {
- ret.append(indent);
- ret.append(((CssStyleRule)rulelist.elementAt(i)).toString());
- }
+ public void addAtRule(AtRule atRule) {
+ this.atRule = atRule;
+ atRuleString = atRule.toString();
+ }
- if (!atRuleString.equals("")) {
- ret.append('}');
- ret.append('\n');
- }
+ public String getAtRule() {
+ return atRuleString;
}
- return ret.toString();
- }*/
- /* public String toHTML() {
- StringBuffer ret = new StringBuffer();
+ 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 (null != atRule && atRule.isEmpty()) {
- if (!atRuleString.equals("")) {
- ret.append("<li><span class='atSelector'>");
- ret.append(atRuleString);
- ret.append("</span></li> \n\n");
- }
- } else {
- if (!atRuleString.equals("")) {
- ret.append("<li><span class='atSelector'>");
- ret.append(atRuleString);
- ret.append("</span> {\n<ul>\n");
- }
- for (int i = 0; i < rulelist.size() ; i++ ) {
- ret.append(((CssStyleRule)rulelist.elementAt(i)).toHTML());
- }
+ if (!atRuleString.equals("")) {
+ ret.append("}\n");
+ }
+ }
+ return ret.toString();
+ }
- if (!atRuleString.equals("")) {
- ret.append("</ul>}</li>\n");
- }
- }
- return ret.toString();
- }
- */
- public void toHTML(PrintWriter out) {
- if (null != atRule && atRule.isEmpty()) {
- if (!atRuleString.equals("")) {
- out.print("<div class='atRule'><span class='atSelector'>");
- out.print(Util.escapeHTML(atRuleString));
- out.print("</span></div> \n\n");
- }
- } else {
- if (!atRuleString.equals("")) {
- out.print("<div class='atRule'><span class='atSelector'>");
- out.print(Util.escapeHTML(atRuleString));
- out.print("</span> {\n<div>\n");
- }
- for (int i = 0; i < rulelist.size() ; i++ ) {
- ((CssStyleRule)rulelist.elementAt(i)).toHTML(out);
- }
+ /*
+ * public String toString() { StringBuffer ret = new StringBuffer();
+ *
+ * if (atRule == null || atRule.isEmpty()) { if (null != atRule &&
+ * !atRuleString.equals("")) { ret.append(atRuleString); ret.append(' ');
+ * ret.append('\n'); } } else { if (!atRuleString.equals("")) {
+ * ret.append(atRuleString); ret.append(' '); ret.append('{');
+ * ret.append('\n'); indent = " "; } for (int i = 0; i < rulelist.size() ;
+ * i++ ) { ret.append(indent);
+ * ret.append(((CssStyleRule)rulelist.elementAt(i)).toString()); }
+ *
+ * if (!atRuleString.equals("")) { ret.append('}'); ret.append('\n'); } }
+ * return ret.toString(); }
+ */
- if (!atRuleString.equals("")) {
- out.print("</div>}</div>\n");
- }
+ /*
+ * public String toHTML() { StringBuffer ret = new StringBuffer();
+ *
+ * if (null != atRule && atRule.isEmpty()) { if (!atRuleString.equals("")) {
+ * ret.append("<li><span class='atSelector'>"); ret.append(atRuleString);
+ * ret.append("</span></li> \n\n"); } } else { if
+ * (!atRuleString.equals("")) { ret.append("<li><span
+ * class='atSelector'>"); ret.append(atRuleString); ret.append("</span> {\n<ul>\n"); }
+ * for (int i = 0; i < rulelist.size() ; i++ ) {
+ * ret.append(((CssStyleRule)rulelist.elementAt(i)).toHTML()); }
+ *
+ * if (!atRuleString.equals("")) { ret.append("</ul>}</li>\n"); } }
+ * return ret.toString(); }
+ */
+ public String toHTML() {
+ String ret = "\t\t\t\t\t";
+ if (null != atRule && atRule.isEmpty()) {
+ if (!atRuleString.equals("")) {
+ ret += "<div class='atRule'><span class='atSelector'>";
+ ret += Util.escapeHTML(atRuleString);
+ ret += "</span></div> \n\n";
+ }
+ } else {
+ if (!atRuleString.equals("")) {
+ ret += "<div class='atRule'><span class='atSelector'>";
+ ret += Util.escapeHTML(atRuleString);
+ ret += "</span> {\n\t\t\t\t\t\t<div>\n";
+ }
+ for (int i = 0; i < rulelist.size(); i++) {
+ ret += ((CssStyleRule) rulelist.elementAt(i)).toHTML();
+ }
+ if (!atRuleString.equals("")) {
+ ret += "\t\t\t\t\t\t</div>}\n\t\t\t\t\t</div>\n";
+ }
+ }
+ return ret;
}
- }
- public void clear() {
- atRuleString = "";
- rulelist.removeAllElements();
- pseudopage = "";
- }
+ public void clear() {
+ atRuleString = "";
+ rulelist.removeAllElements();
+ pseudopage = "";
+ }
}
--- soap12.properties.en DELETED ---
Index: StyleReport.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleReport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- StyleReport.java 14 Sep 2005 15:14:17 -0000 1.3
+++ StyleReport.java 13 Jul 2007 13:32:19 -0000 1.4
@@ -10,7 +10,7 @@
public abstract class StyleReport {
abstract public void print(PrintWriter out);
-
+
abstract public void desactivateError();
}
--- NEW FILE: soap12.properties ---
<?xml version='1.0' encoding="$charset"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<m:cssvalidationresponse
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:m="http://www.w3.org/2005/07/css-validator">
<m:uri>$file_title</m:uri>
<m:checkedby>http://jigsaw.w3.org/css-validator/</m:checkedby>
<m:csslevel>$cssversion</m:csslevel>
<m:date>$currentdate</m:date>
<m:validity>$is_valid</m:validity>
<m:result>
#if ( $errors_count > 0 )
<m:errors xml:lang="$lang">
<m:errorcount>$errors_count</m:errorcount>
#foreach ( $error_content in $errors_content )
#set ( $err = $error_content.get("Error") )
#set ( $error_msg = $error_content.get("ErrorMsg") )
#set ( $class_name = $error_content.get("ClassName") )
#if ( $sf != $err.SourceFile )
#if ( $open )
</m:errorlist>
#end
#set ( $sf = $err.SourceFile )
<m:errorlist>
<m:uri>$sf</m:uri>
#set ( $open = true )
#end
<m:error>
<m:line>$err.Line</m:line>
<m:errortype>$class_name</m:errortype>
<m:message>$error_msg</m:message>
</m:error>
#end
#if ( $open )
</m:errorlist>
#end
</m:errors>
#end
#if ( $warnings_count > 0 )
<m:warnings xml:lang="$lang">
<m:warningcount>$warnings_count</m:warningcount>
#set ( $sf = "" )
#set ( $open = false )
#foreach ( $warning in $warnings_list )
#if ( $sf != $warning.SourceFile )
#if ( $open )
</m:warninglist>
#end
#set ( $sf = $warning.SourceFile )
<m:warninglist>
<m:uri>$sf</m:uri>
#set ( $open = true )
#end
#if ( $warning.Level <= $warning_level )
<m:warning>
<m:line>$warning.Line</m:line>
<m:level>$warning.Level</m:level>
<m:message>$warning.WarningMessage</m:message>
#if ( $warning.Context )
<m:context>$warning.Context</m:context>
#end
</m:warning>
#end
#end
#if ( $open )
</m:warninglist>
#end
</m:warnings>
#end
</m:result>
</m:cssvalidationresponse>
</env:Body>
</env:Envelope>
Received on Friday, 13 July 2007 13:32:43 UTC