Skip to content

Commit 2ac365d

Browse files
committed
simplifying velocity tools init
1 parent 61864ab commit 2ac365d

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

org/w3c/css/css/StyleSheetGenerator.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import org.apache.velocity.runtime.RuntimeConstants;
99
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
1010
import org.apache.velocity.tools.ToolManager;
11-
import org.apache.velocity.tools.config.ConfigurationUtils;
12-
import org.apache.velocity.tools.config.FactoryConfiguration;
11+
import org.apache.velocity.tools.generic.EscapeTool;
1312
import org.w3c.css.error.ErrorReportHTML;
1413
import org.w3c.css.parser.CssError;
1514
import org.w3c.css.parser.CssErrorToken;
@@ -27,7 +26,6 @@
2726
import java.io.FileNotFoundException;
2827
import java.io.IOException;
2928
import java.io.PrintWriter;
30-
import java.nio.file.FileSystems;
3129
import java.text.SimpleDateFormat;
3230
import java.util.ArrayList;
3331
import java.util.Collections;
@@ -92,22 +90,7 @@ public class StyleSheetGenerator extends StyleReport {
9290
Velocity.setProperty("classpath.resource.loader.class",
9391
ClasspathResourceLoader.class.getName());
9492
Velocity.init();
95-
96-
String[] _path_comp = {"org", "apache", "velocity", "tools", "generic", "tools.xml"};
97-
StringBuilder sb_path = new StringBuilder("");
98-
boolean is_first = true;
99-
for (String s : _path_comp) {
100-
if (!is_first) {
101-
sb_path.append(FileSystems.getDefault().getSeparator());
102-
} else {
103-
is_first = false;
104-
}
105-
sb_path.append(s);
106-
}
107-
FactoryConfiguration f;
108-
f = ConfigurationUtils.findInClasspath(sb_path.toString());
109-
velocityToolManager = new ToolManager(false, true);
110-
velocityToolManager.configure(f);
93+
velocityToolManager = new ToolManager();
11194
} catch (Exception e) {
11295
System.err.println("Failed to initialize Velocity. " +
11396
"Validator might not work as expected.");
@@ -130,6 +113,7 @@ public StyleSheetGenerator(ApplContext ac, String title, StyleSheet style,
130113
this.template_file = availableFormat.getProperty(document);
131114

132115
context = new VelocityContext(velocityToolManager.createContext());
116+
context.put("esc", new EscapeTool());
133117
// add a static ref for templates that needs to do some escaping
134118
context.put("Messages", Messages.class);
135119
// adjust the source name if needed

0 commit comments

Comments
 (0)