Hi, all.
I'd like to make a proposal for an addition to Digester (Struts 1.1) to
allow the setting of tag attribute methods. Essentially, I want to be
able to have XML like this:
<project>
<element name="element1" some-key="key1" another-key="key2">
<child-elements>
...
where some-key maps to get/setSomeKey and another-key maps to
get/setAnotherKey. As I understand Digester now, attribute names may not
use hyphens since that would make them illegal getter/setter function
names.
I have two ideas on how to perform this:
1. Check attribute names for hyphens (-), remove them, and convert the
next character to upper case before calling introspection.
2. Add a method to allow mapping /project/element@some-key and
/project/element@another-key to their respective getter/setters.
(The use of "@" means that it's an attribute of /project/element, as is
done in XQL. Wild cards done similar to XQL (two "//" instead of "*/")
for defining an element might be another point to consider.)
A depate about using attributes as opposed to sub-elements aside, might
this be a desired addition for others using Digester?
--
Michael Westbay
Work: Beacon-IT http://www.beacon-it.co.jp/
Home: http://www.seaple.icc.ne.jp/~westbay
Commentary: http://www.japanesebaseball.com/