commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: NodeCreateRule Question
Date Sat, 22 Nov 2003 02:47:57 GMT
On Sat, 2003-11-22 at 06:26, Marwan Aziz wrote:
> I also have the following rules defined:
> digester.addFactoryCreate("a/b", ....);
> digester.addSetProperties("a/b");
> digester.addSetNExt("a/b", ....);
> digester.addObjectCreate("a/b/c", ....);
> digester.addSetProperties("a/b/c");
> digester.addSetNext("a/b/c", ....);
> This works fine. What I want to do also is to 
> "extract" the <b> element (and its subelement) 
> and then insert it into another XML document. 
> I recognize that I have to use the NodeCreateRule, 
> however, I am not sure where to place the rule. 
> From the docs, it is mentioned that "rules that 
> would match XML nodes under the element that matches 
> a NodeCreateRule will never be triggered by Digester,
>  which usually is the behavior one would expect.". 
> Is it possible to mix NodeCreateRule with FactoryCreateRule??
>  or should I parse the file again to extract the nodes??

You will need to parse the file again. Using NodeCreateRule will prevent
any rule-matching against input "beneath" the node that is being used.

NodeCreateRule basically detaches Digester from the XML parser and
handles the incoming SAX events itself until the end of the matching
node is reached. So Digester never even knows that the elements under
the matching node exist.

It would be great to have a better way to handle this in Digester. If
you can come up with an implementation that allows both the node and
rules, please submit it! I think that it could be possible, by inserting
a "sax filter" between the parser and the Digester rather than
completely redirecting the events as is currently done.

Regards,  Simon

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

View raw message