On Thu, 2006-06-15 at 07:43 -0700, Jeff Marendo wrote: > Simon, > > Thanks for the reply and helpful information. > > >>If user is the root level, then you've not got a lot of object in the > >>map :-) > > Yeah, actually, I did have a single file with multiple users listed within > it as you had suggested, > but I later changed the design so that each user would have his own XML > file. Part of the reason for > that is because I'm also using Betwixt to save objects as XML. Just seemed > a bit easier to split the > users apart into separate files.
Ok, that's a somewhat different problem. I was assuming you'd just trimmed down your input file to a single user element for the purposes of this email, and that you really had multiple user elements in a single input xml file. But instead you're trying to process a set of xml input files one by one, each file including one user definition? Digester doesn't provide any support for processing batches of files, so I presume you're doing: for each file to be processed { Digester d = new Digester(); setUpRules(d); // add your custom rules for parsing a user d.parse(aUserFile); User u = (User) d.getRoot(); // store your user somewhere, eg in a Map } In this case, what's the question about getting *digester* to insert user objects into maps about? > > >>The best solution would be to simply *not* use a map. > [snip] > >> private Map<Users> userMap = new HashMap<Users>(); > Can you clarify that for me? The "<Users>" notation next to the Map and > HashMap classnames is throwing me off > , although I think it just means that they would be storing User instances. > That's java 1.5 generics notation. It just means that the userMap instance is a map that only permits Users objects to be inserted into it (just as you assumed). Actually, I got that syntax wrong (careless!). A map has key and value, so I should have written: private Map<String, User> userMap = new HashMap<String, User>(); which is a map whose keys can only be of type String, and whose values can only be of type User. The old-fashioned non-typed maps are technically the same as: Map<Object, Object> ie accept any Object as key or value. > >>Unfortunately, invoking a custom rule when using the xmlrules module > >>isn't easy. > > Yeah, I was afraid of that. Actually, I was reading the xmlrules docs to try to answer another question today and invoking custom rules doesn't seem to be as hard as I remember. According to the javadoc for the xmlrules *package*, you can write a special class that instantiates a batch of rules and adds them to a digester. You then reference that class via: <include class="..."/> Good luck. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]