commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Partha <>
Subject Digester Pattern Matching
Date Sun, 28 Sep 2003 20:00:59 GMT
I am having trouble matching a digester pattern.. Here is my input xml file..
       <name>Design Patterns in Digester</name>
       <specialElem>xxxx <specialElem>

My object structure has 

1) Element class which is basically a name value pair.. So the above xml will create an element
instance when it encounters "Name","ISBN" and "Author".. (I know its a bad way to represent
input xml but I am stuck with this format:()..

2) SpecialElement class which holds the attributes for specialElem

3) Book class which contains a list of elements.. 

4) Catalog class which holds a list of books.

Here's what I need to do, 
1) for every catalog create a catalog
2) for every catalog/book create a new book 
3) for every catalog/book/specialElem -> create a new SpecialElement object and add it
to the book
4) for every catalog/book/*-> (elements other than special element) -> create a new
Element object with the name & value of the tag, and add it to the book

Steps 1, 2 and 3 are trivial to do with digester using the following rules.xml

   <object-create-rule pattern="catalog" classname="Catalog" />

   <pattern value="catalog/book">
      <object-create-rule classname="Book" />
            <pattern value="specialElem">   
                <object-create-rule classname="SpecialElement" />
                 <call-method-rule methodname="setSpecial" paramcount="0"/>
                 <set-next-rule methodname="addSpecialElement" />       
      <set-next-rule methodname="addBook" />

However I donot know how to match wild cards like catalog/book/* .. Does the  '<pattern
value="%pattern%">' take regular expressions? What is a good way of solving this problem
(other than fixing the xml :()? Should I create a new rule? 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message