commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Kersten" <Martin.Kers...@Student.Uni-Magdeburg.DE>
Subject [Digester 1.5] Pattern matching screwed me up
Date Sun, 29 Feb 2004 00:11:10 GMT
Hi maillist,

  after I've tried for hours to get my simple XML shema working 
(due to bad documentation if you ask me). I nearly give up.

My problem? Well I want to use selfcontainment. Given you 
an example: 

<a><a>
    <b></b>
</a></a>

So whats the problem?

First of all this wont work:

digester.addObjectCreate("a",A.class);
digester.addObjectCreate("b",B.class);  
digester.addSetNext("a/a","add");
digester.addSetNext("a/b","addB");

Why does this wont work? Well took me an hour
to figure it out (thanks for the hidden java doc documentation
-why not pointing it out in a seperate documentation file? Like
everyone does?)

Ok here you go, just add an */ to match everything...

digester.addObjectCreate("*/a",A.class);
digester.addObjectCreate("*/b",B.class);  
digester.addSetNext("*/a/a","add");
digester.addSetNext("*/a/b","addB");

Looks right, doesn't it? Well not for digester, it seams! Since 
*/a/a is a closer pattern match it seams, adding it is just more 
important then creating the object first (who cares null pointer?!).

Ok therefore lets add a hack:
 
digester.addObjectCreate("*/a",A.class);
digester.addObjectCreate("*/b",B.class);  

digester.addObjectCreate("*/a/a",A.class);
digester.addObjectCreate("*/b/a",B.class);  
digester.addSetNext("*/a/a","add");
digester.addSetNext("*/a/b","addB");

Works! But halt, bad karma... . If you have something
like setProperties("*/a","id","id"); You can collapse right
now. Since */a is not as exact as */a/a it would not be called
right out of the box (setNext will be called first). So what to do? 
Adding another setProperties("*/a/a","id","id")? 

Would fix it!

Crazy. It seams I've missed an important information. Can someone 
shade some light? I dont want to blaim digester but I am trying 
for hours. I wanted to save time but who could know that 
digester hates tags containing itself. (anyone like trees?). 
I can not imagen that simple trees are beyond the caps of digester.
 So I am thinking the fault is just on my side. 

So please, tell me what am I doing wrong?!


Thanks 

Martin (Kersten)

PS: Tried for more then four hours fooling around with test cases, looking 
for the internet and debugging the digester api. I am just a little, well lets 
call it disapointed... .
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message