On Mon, 2005-06-20 at 14:01 -0400, Frank W. Zammetti wrote: > Hi... I went through the Digester docs, but couldn't find the answer to my > specific question (although the answer seemed to be hinted at)... is it > possible to have a matching pattern of simply "*" so that every element in > the document being parsed fires the corresponding rule? > > What I'm trying to do is have a simple XML format with a list of elements: > > <myDoc> > <item1>11</item1> > <item2>22</item2> > <item3>33</item3> > </myDoc> > > ... and I want to have a rule fire to take each of those and insert them > in to a map (just a call to a generic setter), but without knowing > before-hand that item1, item2 and item3 will be present (i.e., maybe it's > item4, item5 and item6 instead). So I figured just match "*" would do it, > but am looking for verification. TIA! >
The standard rule-matching engine (RulesBase) doesn't support this. It allows leading wildcards (eg "*/item1"), but doesn't support a wildcard on its own. The ExtendedBaseRules class allows trailing wildcards, so "myDoc/*" will match any direct child element of myDoc which is what you want I believe. It also allows completely-wild expressions "*" and "!*". It doesn't have any expression to specify "any descendant of myDoc". See the javadoc for class ExtendedBaseRules for more info. The RegExRules class is even more powerful (but slower). There is a sneaky way of effectively supporting trailing-wildcard with the standard RulesBase matching engine if you are writing your own rule; the SetNestedElementRule class has an example of this. But ExtendedBaseRules is probably what you are looking for. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
