You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Veerasamy, Thirumalai (Cognizant)" <VT...@chn.cognizant.com> on 2004/01/22 15:26:11 UTC

[Digester] Recursive nodes - One to many

Hi,

  I have a requirement where the node names could be unknown but the their properties or known. Again its child could again be unknown. See the example below.

<contexts>
 <context>
  <id>1</id>
  <description>About our beloved anna</description>
 </context>
 <context>
  <id>5</id>
  <description>Paranur Utsavam</description>
  <year>
   <id>51</id>
   <description>Paranur Utsavam 1999</description>
   <day>
    <id>511</id>
    <description>Paranur Utsavam 1999 Day 01</description>
   </day>
  </year>
 </context>
</contexts>

  Here every node will have two properties id and description. Context is a known node, but the year, day or unknown node. It could be year, month and day or year, month, week and day, etc., Each node can repeat again (eg., all months under year, which in turn will have weeks, etc.,)

  How do a write a rule for that (/contexts/context/*/id???). It doesn't work. If I am missing something let me know. 

  In case this is difficult of impossible, then I will make the node name as known (<entry>) instead of generic (year, month, day, xyz).

<contexts>
 <context>
  <id>1</id>
  <description>About our beloved anna</description>
 </context>
 <context>
  <id>5</id>
  <description>Paranur Utsavam</description>
  <entry>
   <id>51</id>
   <description>Paranur Utsavam 1999</description>
   <entry>
    <id>511</id>
    <description>Paranur Utsavam 1999 Day 01</description>
   </entry >
  </entry >
 </context>
</contexts>

  How do I recursively add the entries. Hope I explained the situation clearly.

Regards,
Thiru



Re: [Digester] Recursive nodes - One to many

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Fri, 2004-01-23 at 03:26, Veerasamy, Thirumalai (Cognizant) wrote:
> Hi,
> 
>   I have a requirement where the node names could be unknown but the
> their properties or known. Again its child could again be unknown. See
> the example below.

The standard pattern-matching engine (RulesBase) doesn't support
patterns like:
  /contexts/context/*/id
It supports leading wildcards, and that's it (as described in the
javadoc).

You might be able to get this effect via the RegexRules or
ExtendedBaseRules. See the javadoc for these classes.

Regards,

Simon


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