You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Geronimo Ma. Hernandez" <ge...@gmx.com> on 2003/09/01 11:24:04 UTC

[Digester] question about parent-parameter-access

Hello,

I try to transform this XML-content:

<entity name="anEntity">
	<addAttribute	name="rowid"/>
	<addAttribute	name="dbid">
		<unique-index	idx_number="1" idx_order="1"/>
	</addAttribute>
</entity>

with a definition-object for enitity. A CallMethodRule gets rid of the 
"entity/addAttribute"-pattern, combined with a CallParamRule for the 
name-attribute. 
For the "entity/addAttribute/unique-index"-pattern I also added a 
CallMethodRule, with CallParamRules for idx_number and idx_order.
But now, I got stuck.

How could I access the name-attribute of /entity/addAttribute ?

With the help of a debugger I found the value "dbid" in digester.params as an 
entry below the parameters for the unique-index method call.

Is it possible to access this value with the existing *Rules-classes, or do I 
have to build a new one? The digester.peekParams(n) is classified as "package 
private" ...
Could anyone shine me a light on how to do it the right way?

Many thanks for your attention.

Gero


Re: [Digester] CallMethodRule - parameter types

Posted by "Geronimo Ma. Hernandez" <ge...@gmx.com>.
Hello,

I have a method which takes two parameters of type Object.
The values from XML-source are converted to String.
Now I would like to have one parameter converted to an Integer.

This is my digester rule:

digester.addCallMethod(MAP_IS_ENTRY_NODE, "put", 2, 
	new String[] { "java.lang.Object"	, "java.lang.Object" });

When I specify the parameters as Integer and String (the types I like in this 
case), I get an InvocationException and I suppose, that the method is not 
found. (CallMethodRule.useExactMatch is false).

I looked at the CallParamRule, but I didn't find a way to specify the type of 
the parameter.

In the CallMethodRule I found different arrays paramTypes and paramClassNames, 
so I suppose, that my situation has been seen coming.
Unfortunately the paramClassNames is private and has no setter.

Does anybody know a way, how I could solve this problem without subclassing 
the object, where the method is called from and also without having to copy 
the CallMethodRule?

Many thanks for your attention.

regards Gero


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] question about parent-parameter-access

Posted by "Geronimo Ma. Hernandez" <ge...@gmx.com>.
Thanks for your note, Simon - and sorry for not responding earlier. 
I was off home - and as I work this out in my spare-time ...

Simon Kitching wrote:
> You are trying to avoid creating an object corresponding to the
> "addAttributes" xml element, yet process subelements associated
> with that element.

I did that, cause the entity-attribute relation is for me just a reference and 
for so not worth to create a class for that purpose.

> This isn't exactly "invalid", but this kind of disconnect between the
> xml structure and your object structure leads to the kind of problems
> you are experiencing. 

I don't consider it really a problem. The digester-stuff is easy to understand 
and as well easy to expand. My "CallAncestorParamRule" works fine for me.

> If you were to define a class
>
> class OptionallyIndexedAttribute {
>   String attributeName;
>   Integer idxNr;
>   Integer idxOrder;
>
>   public void setName() {...};
>   public void setUniqueIndex(int idxNr, int idxOrder) {...};
> }
>
> and have this method on class Entity:
>   addAttribute(OptionallyIndexedAttribute attr) {
>   }

Yes, may be that's the way, I should do it. Gonna think about it.

> (1)
> Assuming that there is only ever zero or one <unique-index> child
> of an <addAttribute> node,
>
> digester.addCallMethod(ADD_ATTRIBUTE_NODE, "addAttribute", 3);
> digester.addCallParam(ADD_ATTRIBUTE_NODE, 0, "name");
> digester.addCallParam(UINDEX_NODE, 1, "idx_number");
> digester.addCallParam(UINDEX_NODE, 2, "idx_order");
>
> and have this method on Entity:
>   addAttribute(String name, Integer idxNr, Integer idxOrder) {...}

I didn't do that, cause at the moment I have 3 different index-types: 
- unique index
- index (not unique)
- full text index
with the corresponding xpath of 
- entity/addAttribute/unique-index
- entity/addAttribute/index
- entity/addAttribute/fulltext

well, I could spend the addAttribute()-method a fourth parameter "index type" 
...

> (2)
> When a "unique-index" element is encountered, you know that it applies
> to the enclosing attribute, which will trigger an "addAttribute" method
> soon. So why not just cache the index info until the addAttribute method
> is invoked?

> This feels a bit hacky to me, but I don't see why it won't work.
> It certainly feels no hackier to me than referencing call parameters

As I devote myself to write easy understandable code, and the index property 
is a property of the entity-attribute-relation, I think, the cleanest way is 
to write a class for the entity-attribute-relation.

Thank you very much for your time and your attention.

regards Gero

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] question about parent-parameter-access

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Tue, 2003-09-02 at 23:03, Geronimo Ma. Hernandez wrote:
> Thanks for your reply, Simon!
> 
> Simon wrote:
> > It's still not clear to me what your data model is.

Ok, I see what you are trying to achieve now.
[please note: all code/suggestions below are untested; any or
all of them could be wrong :-]

I think the cause of your problems with Digester is this:

> class EntityDefinition {
>   public void addAttribute(String attributeName) throws DefinitionException;
>   public void putUniqueIndex(Integer idxNr, Integer idxOrder, String
> 		 attributeName);
> }

You are trying to avoid creating an object corresponding to the
"addAttributes" xml element, yet process subelements associated
with that element.

This isn't exactly "invalid", but this kind of disconnect between the
xml structure and your object structure leads to the kind of problems
you are experiencing. I've been there myself...


If you were to define a class

class OptionallyIndexedAttribute {
  String attributeName;
  Integer idxNr;
  Integer idxOrder;

  public void setName() {...};
  public void setUniqueIndex(int idxNr, int idxOrder) {...};
}

and have this method on class Entity:
  addAttribute(OptionallyIndexedAttribute attr) {
  }

then I think you would find the digester rules suddenly fall into place.
Use an ObjectCreateRule for "entity/addAttribute" to create an
OptionallyIndexedAttribute instance, and then rules triggered by
subelements (unique-index in your case) then operate on an object which
*knows* its name.


Other possibilities:

(1)
Assuming that there is only ever zero or one <unique-index> child
of an <addAttribute> node,

digester.addCallMethod(ADD_ATTRIBUTE_NODE, "addAttribute", 3);
digester.addCallParam(ADD_ATTRIBUTE_NODE, 0, "name");
digester.addCallParam(UINDEX_NODE, 1, "idx_number");
digester.addCallParam(UINDEX_NODE, 2, "idx_order");

and have this method on Entity:
  addAttribute(String name, Integer idxNr, Integer idxOrder) {...}

this will cause the following xml 
  <entity>
    <addAttribuute name="foo"/>
    <addAttribute name="bar"
      <unique-index idx_number="1" idx_order="2"/>
    </addAttribute>
  </entity>

to invoke 
	addAttribute("foo, null, null);
        addAttribute("bar", new Integer(1), new Integer(2));

(2)
When a "unique-index" element is encountered, you know that it applies
to the enclosing attribute, which will trigger an "addAttribute" method
soon. So why not just cache the index info until the addAttribute method
is invoked?

class Entity {
  boolean haveIndex = false;
  int currIdxNr;
  int currIdxOrder;

  void setUniqueIndex(int idxNr, int idxOrder) {
    haveIndex = true;
    currIdxNr = idxNr; 
    currIdxOrder = idxOrder;
  }

  void addAttribute(String name) {
     ....
     if (haveIndex) {
       addAttributeIndex(name, currIdxNr, currIdxOrder);
       haveIndex = false;
     }
  }

}

This feels a bit hacky to me, but I don't see why it won't work.
It certainly feels no hackier to me than referencing call parameters



Hope this helps,

Simon




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] question about parent-parameter-access

Posted by "Geronimo Ma. Hernandez" <ge...@gmx.com>.
Thanks for your reply, Simon!

Simon wrote:
> It's still not clear to me what your data model is.

Well, "my" data model started as a 1:1 view of a database, where a table is an 
entity and a column of a table is an attribute...
Now I advanced a bit in abstaction and you could think of an entity is just a 
set of attributes. This can be a 1:1 view of a database table, this could be 
a part of a table or this could be a set of selected columns of selected 
tables. So you could think of an entity as a dynabean.

An application consists of many different dynabeans and if you want to create 
different dynabeans with the same factory, you need some rules on how to 
create a dynabean.
From my point of view, such a dynabean is just an "invisible link" between UI 
and database, so to abstract this connection, you need some additional 
information/rules for each side of the connection.

Well, that additional information about each side combined with some rules is 
"my" model, and the config-file I process, is somewhat similar like a 
model-file for torque.
Ah, I think one difficulity of "my" model could be, that I try to scan the 
definition of the classes I actual use for the meta-model. It's a logical 
circular reference. 
Anyway, you could replace the names in your mind.

Ok, the mail will get somewhat big, but I try to include the code skeletons.
First of all, the model, the XML-file I gonna transform (explanation after the 
content):

<?xml version="1.0" encoding="ISO-8859-1" ?>
<meta-model>
	<map name="DBTypes">
		<entry value="1" lable="postgres"/>
		<entry value="2" lable="Oracle"/>
		<entry value="3" lable="DB/2"/>
		<entry value="4" lable="mySQL"/>
	</map>
	<map name="TableTypes">
		<entry value="1" lable="normal"/>
		<entry value="2" lable="fast"/>
		<entry value="3" lable="secure"/>
		<entry value="4" lable="temporary"/>
	</map>
	<map name="FldTypes">
		<entry value="1" lable="boolean"/>
		<entry value="2" lable="date"/>
		<entry value="3" lable="datetime"/>
		<entry value="4" lable="decimal"/>
		<entry value="5" lable="foreignkey"/>
		<entry value="6" lable="integer"/>
		<entry value="7" label="rowid"/>
		<entry value="8" lable="text"/>
		<entry value="9" lable="time"/>
	</map>	
	<attributes>
		<eid/>
		<text name="dbname" length="40" visLength="30"/>
		<text name="dbprefix" length="4" visLength="4"/>
		<text name="tsname" length="30" visLength="30"/>
		<text name="tblname" length="30" visLength="30"/>
		<text name="fldname" length="30" visLength="30"/>
		<reference name="dbid" references="Database"/>
		<reference name="tsid" references="Tablespace"/>
		<reference name="tblid" references="Table"/>
		<reference name="fldid" references="Field"/>
		<reference name="dbtype" references="DBTypes" property="value"/>
		<reference name="ttype" references="TableTypes" property="value"/>
		<reference name="ftype" references="FldTypes" property="value"/>
		<text name="path"/>
		<text name="value"/>
		<text name="stduser" length="25" visLength="15"/>
		<text name="ipcre" length="30" visLength="30"/>
		<text name="ipmod" length="30" visLength="30"/>
		<datetime name="dtimecre"/>
		<datetime name="dtimemod"/>
		<integer name="modcnt"/>
		<integer name="bsize" minValue="0"/>
		<integer name="esize" minValue="0"/>
		<integer name="flen" length="4" visLength="5" minValue="1" maxValue="2000"/>
		<integer name="dlen" length="1" visLength="2" minValue="0" maxValue="9"/>
		<integer name="vlen" length="2" visLength="3" minValue="0" maxValue="99"/>
		<boolean name="flauto"/>
		<boolean name="flmand"/>
	</attributes>

	<entity name="Database">
		<addAttribute	name="rowid"/>
		<addAttribute	name="dbname">
                  <unique-index idx_number="1" idx_order="1"/>
                </addAttribute>  
		<addAttribute	name="dbprefix"/>
		<addAttribute	name="dbtype"/>
		<addAttribute	name="path"/>
		<addAttribute	name="stduser"/>
		<addAttribute	name="ipcre"/>
		<addAttribute	name="ipmod"/>
		<addAttribute	name="dtimecre"/>
		<addAttribute	name="dtimemod"/>
		<addAttribute	name="modcnt"/>
	</entity>	
	
	<entity name="Tablespace">
		<addAttribute	name="rowid"/>
		<addAttribute	name="bsize"/>
		<addAttribute	name="esize"/>
		<addAttribute	name="dbid"/>
		<addAttribute	name="flauto"/>
		<addAttribute	name="path"/>
		<addAttribute	name="tsname"/>
		<addAttribute	name="ipcre"/>
		<addAttribute	name="ipmod"/>
		<addAttribute	name="dtimecre"/>
		<addAttribute	name="dtimemod"/>
		<addAttribute	name="modcnt"/>
	</entity>
	<entity name="Table">
		<addAttribute	name="rowid"/>
		<addAttribute	name="bsize"/>
		<addAttribute	name="esize"/>
		<addAttribute	name="dbid">
                  <unique-index idx_number="1" idx_order="1"/>
                </addAttribute>  
		<addAttribute	name="tblname">
                  <unique-index idx_number="1" idx_order="2"/>
                </addAttribute>  
		<addAttribute	name="tsid"/>
		<addAttribute	name="ttype"/>
		<addAttribute	name="ipcre"/>
		<addAttribute	name="ipmod"/>
		<addAttribute	name="dtimecre"/>
		<addAttribute	name="dtimemod"/>
		<addAttribute	name="modcnt"/>
	</entity>
	
	<entity name="Field">
		<addAttribute	name="rowid"/>
		<addAttribute	name="fldname"/>
		<addAttribute	name="ftype"/>
		<addAttribute	name="tblid"/>
		<addAttribute	name="flmand"/>
		<addAttribute	name="value"/>
		<addAttribute	name="flen"/>
		<addAttribute	name="dlen"/>
		<addAttribute	name="vlen"/>
		<addAttribute	name="ipcre"/>
		<addAttribute	name="ipmod"/>
		<addAttribute	name="dtimecre"/>
		<addAttribute	name="dtimemod"/>
		<addAttribute	name="modcnt"/>
	</entity>
</meta-model>

Ok, lets move to the object/rules part step by step:
All definitions of the meta-model are added to a Catalog-instance, which is 
created as a "DefinitionRoot" by the factory, before starting the scanner. 
The Catalog also is the first instance added to the digester-stack.

class Catalog {
  public void addSelectList(Map);
  public void addEntityDefinition(EntityDefinition);
  public void addAttributeDefinition(AbstractAttributeDefinition);	
  public void putDefinition(Definition definition){
    if(definition instanceof EntityDefinition)
	addEntityDefinition(definition);
    else if(definition instanceof(AbstractAttributeDefinition))
	addAttributeDefinition(definition);	
  }
}

The first subpattern is the map. A map is a list of items to satisfy a 
foreignkey without a target table (will be displayed in a dropdown combo).

digester.addFactoryCreate(MAP_NODE, "MapDefinitionCreateFactory");
digester.addCallMethod(MAP_ENTRY_NODE, "put", 2, 
		new String[] { "java.lang.Integer", "java.lang.String" });
digester.addCallParam(MAP_ENTRY_NODE,0,"value");
digester.addCallParam(MAP_ENTRY_NODE,1,"lable");																																	
digester.addSetNext(MAP_NODE, "addSelectList", MAP_CLASS);

Next subpattern is the attribute-section. (In my model, an attribute 
definition does not depend on a surrounding entity-definition.)
Each (supported) attribute-type has a different pattern and creates another 
AttributeDefinitionClass - Subclass of AbstractAttributeDefinition.

digester.addObjectCreate(BOOLEAN_NODE, BOOLEAN_CLASS);
digester.addSetProperties(BOOLEAN_NODE);
digester.addSetNext(BOOLEAN_NODE, "addAttributeDefinition", ATTRIBUTE_CLASS);

The AttributeDefinition is quite a fat class, with all properties, that could 
be used in certain situation. As each type needs different information to 
build an entry on a dynabean, a select- or an insert-statement or on the 
UI-side, each AttributeDefinition-subclass holds the needed information.
All AttributeDefinitions are just beans.

At least the entity-definitions are processed. The entity just contains 
references to the real attribute-definition and - for me - the 
index-information is no property of the attribute, but of the entity. For me 
the same attribute may be part of different entities and in one entity this 
attribute is part on an index, but in the other entities it is not.
The rules for the entity-processing are as follows (with CallAncestorParamRule 
being my own written rule-class):

digester.addFactoryCreate(ENTITY_NODE,"EntityDefinitionCreateFactory");
digester.addSetProperties(ENTITY_NODE);
digester.addCallMethod(ADD_ATTRIBUTE_NODE, "addAttribute", 1
		, new String[] { "java.lang.String" });
digester.addCallParam(ADD_ATTRIBUTE_NODE,0,"name");
digester.addCallMethod(UINDEX_NODE, "putUniqueIndex", 3
	, new String[] { "java.lang.Integer"
		, "java.lang.Integer"
		, "java.lang.String"});
digester.addCallParam(UINDEX_NODE, 0, "idx_number");
digester.addCallParam(UINDEX_NODE, 1, "idx_order");
digester.addRule(UINDEX_NODE, new CallAncestorParamRule(2, 1, 0));
digester.addSetNext(ENTITY_NODE, "putDefinition", ENTITY_CLASS);

With the EntityDefinitionCreateFactory I create an Entity with the parent 
(Catalog) already set before any other processing takes place.

class EntityDefinition {
  public void addAttribute(String attributeName) throws DefinitionException;
  public void putUniqueIndex(Integer idxNr, Integer idxOrder, String
		 attributeName);
}

The addAttribute-method of the Entity queries the AttributeDefinition from the 
Catalog. If found, the attribute is added to the entity, otherwise an 
Exception is thrown. 
The benefit of checking the existence of the attribute-definition at addition 
and not with a separate function-call at the end of the entity-processing is, 
that I get a line-number of the error-attribute with the digester-exception.

Finally the EntityDefinition is added to the Catalog with a call to 
putDefinition(EntityDefinition)

Hope, I could clarify, what "my" model is and also hope, that the size of the 
mail is not a problem.

regards Gero

Re: [Digester] question about parent-parameter-access

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
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
build.

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
  digester.addCallMethod(
     "entity/addAttribute/unique-index", 
     "setUniqueIndex", 2);
  digester.addCallParam(
     "entity/addAttribute/unique-index", 0, "idx_number");
  digester.addCallParam(
     "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...

Regards,

Simon

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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


Re: [Digester] question about parent-parameter-access

Posted by "Geronimo Ma. Hernandez" <ge...@gmx.com>.
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

Re: [Digester] question about parent-parameter-access

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
Hi,

I'd like to offer some suggestions, but unfortunately I just don't
understand your question. Perhaps if you could include the actual code
you have so far, that would help clarify what you are trying to achieve.
A DTD/schema or simple description of the input xml would also be
useful. And is this XML "fixed", or do you have the option of changing
this schema if it would make it easier to parse?


Regards,

Simon

On Mon, 2003-09-01 at 21:24, Geronimo Ma. Hernandez wrote:
> Hello,
> 
> I try to transform this XML-content:
> 
> <entity name="anEntity">
> 	<addAttribute	name="rowid"/>
> 	<addAttribute	name="dbid">
> 		<unique-index	idx_number="1" idx_order="1"/>
> 	</addAttribute>
> </entity>
> 
> with a definition-object for enitity. A CallMethodRule gets rid of the 
> "entity/addAttribute"-pattern, combined with a CallParamRule for the 
> name-attribute. 
> For the "entity/addAttribute/unique-index"-pattern I also added a 
> CallMethodRule, with CallParamRules for idx_number and idx_order.
> But now, I got stuck.
> 
> How could I access the name-attribute of /entity/addAttribute ?
> 
> With the help of a debugger I found the value "dbid" in digester.params as an 
> entry below the parameters for the unique-index method call.
> 
> Is it possible to access this value with the existing *Rules-classes, or do I 
> have to build a new one? The digester.peekParams(n) is classified as "package 
> private" ...
> Could anyone shine me a light on how to do it the right way?
> 
> Many thanks for your attention.
> 
> Gero
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


Re: [Digester] question about parent-parameter-access

Posted by "Geronimo Ma. Hernandez" <ge...@gmx.com>.
Sorry, I forgot to mention, that I would like to add the "dbid"-value as  
parameter for the "unique-index"-method.