commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [Digester] question about parent-parameter-access
Date Tue, 02 Sep 2003 08:12:40 GMT
Hi Gero,

It's still not clear to me what your data model is.

I guess what I'm really looking for to understand your problem is a UML
diagram of the classes you are mapping to. This would tell me whether
you are storing attributes as objects in a list, or in a hashmap, and
whether there are references from objects to their siblings, or their
parents, etc.

Now a real UML diagram would probably be overkill, but that's the *sort*
of info required, if you see what I mean? Providing skeleton source code
does the job too, because it also shows the object relations you want to

I'm guessing you have:

  MyAttributeLookupFactory myFactory = new MyAttributeLookupFactory();

  // pushes an Entity object on the stack
  digester.addObjectCreate("entity", Entity.class);
  // pushes onto the stack a clone of a pre-existing Attribute object
  // whose name matches the "name" attribute on this xml node 
  digester.addFactoryCreate("entity/addAttribute", myFactory);

  // tell parent Entity about its child attribute object
  digester.addSetNext("entity/addAttribute", "addAttribute");

  // attributes (of any name) optionally have a unique-index.
  // if a unique-index xml tag is nested within the addAttribute tag,
  // then update the attribute (cloned object) with the values
     "setUniqueIndex", 2);
     "entity/addAttribute/unique-index", 0, "idx_number");
     "entity/addAttribute/unique-index", 1, "idx_order");

This assumes that you have classes:

class Entity {
  public void addAttribute(Attribute attr) {...}

class Attribute {
  public void setUniqueIndex(int idxNumber, int idxOrder) {...}

Now I don't think the above is what you are looking for, but without
using my secret psychic powsers (:-) I can't help you more than this.

Perhaps the above gives you some ideas...

Your project looks interesting...



On Tue, 2003-09-02 at 19:13, Geronimo Ma. Hernandez wrote:
> Thank you, Simon, for your response and sorry for being not good enuf 
> explaining my "problem".
> I'm pretty new to digester and XML.
> I just have an idea of a model and a way I would like to work with it. So I 
> decided to work on a tool to handle the model.
> And as I'm not that visionary, I toggle between different roles: the 
> tool-developer, the tool-user and the model-"watcher".
> Therefore anything changes if all roles agree.
> At the moment I don't have a DTD. I startet writing the xml with an editor and 
> than thought about how to parse the stuff with the digester-rules.
> The xml was just a snippet of the complete model.
> Ok, I try to explain some of the backgrounds of this snippet, cause I think 
> the code is too much to send. If not, give me a note and I'll send you the 
> classes.
> The file I parse is a meta-model of a database, where each 
> attribute-definition is a domain and the entities just use a 
> attribute-definition. So first I process the attribute-definitions with a 
> class for each attribute-type supported. 
> After that I parse the entities.
> The "*/entity"-pattern creates an entity-definition. As the attributes are 
> only references to already scanned definitions, the attributes are added to a 
> map in the entity-definition. At addition, I check the existence of the 
> referenced attribute-definition. 
> For that purpose I created an ObjectCreationFactory, which sets the name 
> attribute and the parent of the entity-definition (at creation, cause as I 
> understood the CallMethodRules, they work at the end of a definition and I 
> found no method-call which fires before the body-processing).
> Ok, when I worked on the index-definitions, I had the choice, to add it as an 
> attribute to "*/entity/addAttribute" or create a new rule for that pattern.
> I decided to go for the second, cause I thought, the majority of the 
> attribute-references won't have any index-declaration. But to add an 
> index-declaration, I need the name of the attribute and I didn't 
> want to duplicate it in the xml.
> Yesterday, when I found the digester.peekParams(n), I gave it a try and 
> created a "CallAncestorParamRule", which peeks a param from the 
> parameter-stack. This works, and it don't look too ugly, but I'm not sure, 
> whether it is in the mood of the digester-stuff?
> Ok, I realized, the method is now public accessible - so was it right what I 
> did?
> If there is another way, on how to do it better, I would appreciate any 
> suggestion - even on points, which I think about as being "fixed". 
> Hope I could clarify a bit, what I'm trying to do ...
> Gero
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message