The Answer to Life, the Universe, and Everything

Thursday, May 17, 2007

Commons Digester Variable

The variable in xml data can be converted with Digester with the easy following codes.
Digester digester = DigesterLoader.createDigester(getURL(ruleFile));
Map vars = new HashMap();
vars.put("hello","Czesc!");
MultiVariableExpander expander = new MultiVariableExpander();
expander.addSource("$", vars);
Substitutor substitutor = new VariableSubstitutor(expander);
digester.setSubstitutor(substitutor);

No comments: