commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: Digester and attribute matching?
Date Sun, 11 Apr 2004 13:29:26 GMT
On 8 Apr 2004, at 17:36, Chen, Tim wrote:

> I saw that in the list archives it was not supported but
> 1) is it planned to be able to support something like
> digester.addCallMethod("foo[@bar=\"blah"\]", "foo"); ?

(simon's covered this pretty well. a long time ago scott knew most 
about this so if he's still around, now would be a good time for him to 
jump in ;)

> 2) is there a way around it currently?
> I see that all the rules have a way to see the attributes before 
> processing
> but I don't know how to stop that rule from processing.

if stopping a rule firing on the basic of attributes, that can be done 
by a wrapper Rule implementation. this should test the attributes and 
only execute the rule if they match your expectations. the only wrinkle 
is that you'll probably need to push the implementation onto the stack. 
here's the type of thing i mean (not tested and with badly named 

public interface AttributesApprover {
	public boolean approved(Attributes attributes);

public class doNothingRule extends Rule {}

public class AttributesFilter extends Rule {
	private ArrayStack ruleStack = new ArrayStack();
	private AttributesApprover approver;
	private Rule rule;
	public void begin(String namespace, String name, Attributes 
attributes) {
		if (approver.approve(attributes)) {
		} else {
			ruleStack.push(new DoNothingRule());
		((Rule)ruleStack.peek()).begin(namespace, name, attributes);

	public void body(String namespace, String name, String text) 
{		((Rule)ruleStack.peek()).body(namespace, name, text);

	public void end(String namespace, String name,) 
{		((Rule)ruleStack.pop()).end(namespace, name,);

- robert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message