Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification.
The following page has been changed by SimonKitching: http://wiki.apache.org/jakarta-commons/Digester/FAQ The comment on the change is: Add entry about matching on attribute value ------------------------------------------------------------------------------ p.parse(inputDocument); }}} + == How do I match elements based on attribute values? == + + Occasionally, people ask how they can fire a rule for an element based on the + value of an attribute, eg + {{{ + <item value="enabled"> + }}} + but not for + {{{ + <item value="disabled"> + }}} + + There is no simple way to do this with Digester; the built-in rule-matching + engines only provide the ability to match on element name. There is no support + available for XPath expressions like "[EMAIL PROTECTED]'enabled']". + + It might be possible to create a custom "filtering" rule that has a child rule, + and fires that child rule only when the appropriate conditions are set. There + are no examples of such a solution, however. + + A possible solution is to perform an XSLT transform to filter out or rename elements that + match certain conditions before using Digester to process the document. + + SAX "filters" may also be useful; see class org.xml.sax.XMLFilter in the standard java + javadocs. Transforming the name of matching elements should then allow rules to match + based on the element name only. + + If you are aware of other solutions to this issue, please add that information here. + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
