hi partha

there is (limited) support for true regular expressions provided by RegexRules. you may need to do some work programmatically to create an adapter for your favourite java regex engine (if you go down this route). i think that there are alternatives.

ExtendedBaseRule's does not support true regular expressions but it does provide extended patterns similar to BaseRules. it supports parent matches (where you match every child of a parent pattern). i think that you should be able to make use of the longest match to ensure that one rule matches everything but specialElem and another matches just specialElem. so i'd suggest that you switch to using the ExtendedBaseRule pattern matching implementation.

of course, another alternative would be to create a custom rule...

- robert

On Sunday, September 28, 2003, at 09:00 PM, Partha wrote:

I am having trouble matching a digester pattern.. Here is my input xml file..
<catalog>
<book>
<name>Design Patterns in Digester</name>
<isbn>342342234</isbn>
<author>xxx</author>
<specialElem>xxxx <specialElem>
</book>
<catalog>


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


<digester-rules>
   <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" />
             </pattern>
      <set-next-rule methodname="addBook" />
   </pattern>
</digester-rules>

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to