Digester
Digester
Parsing and Processing Large XML Documents with Digester Rules
Digester/FAQ/XmlRulesOrNotXmlRules
event 기반인 SAX를 내부적으로 사용
Digester 클래스는 org.xml.sax.ContentHandler를 구현하고 있으며, parse stack를 관리하고
Rule 샘플
package prototype.common;
import java.util.Map;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.digester.BeanPropertySetterRule;
public class BeanAndMapPropertySetterRule extends BeanPropertySetterRule {
public BeanAndMapPropertySetterRule(String propertyName){
super(propertyName);
}
public void end(String namespace, String name) throws Exception{
Object top = digester.peek();
if(top instanceof Map) {
PropertyUtils.setProperty(top, propertyName, bodyText);
} else {
super.end(namespace,name);
}
}
}
History
Last edited on 09/08/2008 11:55 by benelog
Comments (0)