You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Patrick Diviacco <pa...@gmail.com> on 2011/05/13 18:48:02 UTC

[digester] how can I print children tags instead of only tag content ?

I need to print the content of <categ> in my XML file (including children
tags).

For example, if I have <categ><child></child></categ>, I want to print
"<child></child>"

I'm currently parsing the xml file with:
digester.addCallMethod("collection/doc/categ",
 "checkCateg", 0);

and this is the checkCateg function:
public void checkCateg(String categ) {
System.out.println(categ);
}

It doesn't work. The string categ is always empty because it only contains
text content in <categ> but not its children tags.

thanks,
Patrick

Re: [digester] how can I print children tags instead of only tag content ?

Posted by Simone Tripodi <si...@apache.org>.
nice!!! di nulla, è un piacere ;)
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sun, May 15, 2011 at 12:24 PM, Patrick Diviacco
<pa...@gmail.com> wrote:
> OK. Solved, thanks - grazie mille
>
> On 15 May 2011 11:28, Simone Tripodi <si...@apache.org> wrote:
>
>> IIUC = if I understand correctly ;)
>>
>> A quick hint: why don't you manage the logic inside your business
>> logic? I mean, you configure the digester:
>>
>>    Digester digester = new Digester();
>>    digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>>
>>    digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>>
>> then check the 'myMethod' has already been invoked:
>>
>>    boolean check = false;
>>
>>    public void myMethod( String arg )
>>    {
>>        if ( !check )
>>        {
>>            System.out.println( arg );
>>            check = true;
>>        }
>>    }
>>
>> HTH, let me know your progress!
>> Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Sun, May 15, 2011 at 8:58 AM, Patrick Diviacco
>> <pa...@gmail.com> wrote:
>> > what does IIUC mean ?
>> >
>> > Yeah. I mean, more exactly, I just need to know if the element has at
>> least
>> > a child:
>> >
>> > bool = hasChild(myPattern)
>> >
>> > thanks
>> >
>> > On 15 May 2011 02:09, Simone Tripodi <si...@apache.org> wrote:
>> >
>> >> IIUC, no matters which kind of children your node has, you're
>> >> interested only on the first child, right?
>> >>
>> >> http://people.apache.org/~simonetripodi/
>> >> http://www.99soft.org/
>> >>
>> >>
>> >>
>> >> On Sat, May 14, 2011 at 10:51 PM, Patrick Diviacco
>> >> <pa...@gmail.com> wrote:
>> >> > ps. the children names are completely different, there is no way to
>> use a
>> >> > regex to discriminate between them.
>> >> >
>> >> >
>> >> >
>> >> > On 14 May 2011 22:50, Patrick Diviacco <pa...@gmail.com>
>> >> wrote:
>> >> >
>> >> >> hi Simone,
>> >> >>
>> >> >> ok, it was just matter of adding one line :)
>> >> >>
>> >> >> By the way I still have an issue in the case of multiple children and
>> I
>> >> >> don't know how to solve it. If I have a document containing:
>> >> >>
>> >> >> <parent>
>> >> >> <child1></child1>
>> >> >> <child2></child2>
>> >> >> </parent>
>> >> >>
>> >> >> I don't want to  trigger the method twice, but just once... in other
>> >> terms
>> >> >> I want to trigger the method only once per document and only if the
>> >> <parent>
>> >> >> tag has at least 1 child.
>> >> >>
>> >> >> I copy my code again:
>> >> >>
>> >> >> Digester digester = new Digester();
>> >> >> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>> >> >>
>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>> >> >>
>> >> >> thanks
>> >> >> Patrick
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> On 14 May 2011 21:54, Simone Tripodi <si...@apache.org>
>> wrote:
>> >> >>
>> >> >>> Hi Patrick,
>> >> >>> I thought it was more intuitive, sounds we have to update de doc.
>> >> >>> Anyway, to reply to your questions:
>> >> >>>
>> >> >>> 1) just create the Digester instance, set the RegexRules and start
>> >> >>> binding your rules:
>> >> >>>
>> >> >>> Digester digester = new Digester();
>> >> >>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>> >> >>> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>> >> >>>
>> >> >>> 2) yes, as reported in the javadoc I pointed: "* matches any
>> sequence
>> >> >>> of none, one or more characters" like in the bash syntax; if you
>> want
>> >> >>> to apply kind of filters, bind the rules with restrictive patterns
>> >> >>> (prefixes/postfixes); ie. given the rule:
>> >> >>>
>> >> >>> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0
>> );
>> >> >>>
>> >> >>> collection/doc/categ/patt -> matches
>> >> >>> collection/doc/categ/pattern -> matches
>> >> >>> collection/doc/categ/patteRn -> matches
>> >> >>> collection/doc/categ/pattern -> matches
>> >> >>> collection/doc/categ/paBtern -> does not match
>> >> >>>
>> >> >>> HTH, have a nice weekend,
>> >> >>> Simo
>> >> >>>
>> >> >>> http://people.apache.org/~simonetripodi/
>> >> >>> http://www.99soft.org/
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
>> >> >>> <pa...@gmail.com> wrote:
>> >> >>> > Thanks,
>> >> >>> >
>> >> >>> > 1) Is there any tutorial explaining how to use it ?
>> >> >>> >
>> >> >>> > 2) In my case, if I have more than one child, is the pattern
>> detected
>> >> >>> > multiple times ?
>> >> >>> >
>> >> >>> > help is very appreciated!
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org>
>> >> wrote:
>> >> >>> >
>> >> >>> >> Hi Patrick,
>> >> >>> >> follow the Konstantin's suggestion, that's the way to achieve it.
>> >> Have
>> >> >>> >> a read also to
>> >> >>> >>
>> >> >>>
>> >>
>> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
>> >> >>> >>
>> >> >>> >> HTH,
>> >> >>> >> Simo
>> >> >>> >>
>> >> >>> >> http://people.apache.org/~simonetripodi/
>> >> >>> >> http://www.99soft.org/
>> >> >>> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
>> >> >>> >> <kn...@gmail.com> wrote:
>> >> >>> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
>> >> >>> >> >> mhm, sorry.. just to be more clear.
>> >> >>> >> >>
>> >> >>> >> >> Is there a way in Commons Digester to trigger a method only if
>> a
>> >> xml
>> >> >>> >> element
>> >> >>> >> >> has a child ?
>> >> >>> >> >>
>> >> >>> >> >> i.e.
>> >> >>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod",
>> 0);
>> >> >>> >> >>
>> >> >>> >> >> This doesn't work.
>> >> >>> >> >
>> >> >>> >> > The "*" is allowed in the prefix only, as documented in
>> >> >>> >> >
>> >> >>> >> >
>> >> >>> >>
>> >> >>>
>> >>
>> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
>> >> >>> >> >
>> >> >>> >> > You may try to use a different rules matcher. See
>> "RegexMatchers"
>> >> >>> chapter
>> >> >>> >> here:
>> >> >>> >> >
>> http://commons.apache.org/digester/commons-digester-2.1/core.html
>> >> >>> >> >
>> >> >>> >> >
>> >> >>> >> >> But it is actually what I need. If element <categ> has at
>> >> >>> >> >> least a child, then trigger myMethod
>> >> >>> >> >
>> >> >>> >> > Best regards,
>> >> >>> >> > Konstantin Kolinko
>> >> >>> >> >
>> >> >>> >> >
>> >> ---------------------------------------------------------------------
>> >> >>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> >>> >> > For additional commands, e-mail: user-help@commons.apache.org
>> >> >>> >> >
>> >> >>> >> >
>> >> >>> >>
>> >> >>> >>
>> >> ---------------------------------------------------------------------
>> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> >>> >> For additional commands, e-mail: user-help@commons.apache.org
>> >> >>> >>
>> >> >>> >>
>> >> >>> >
>> >> >>>
>> >> >>>
>> ---------------------------------------------------------------------
>> >> >>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> >>> For additional commands, e-mail: user-help@commons.apache.org
>> >> >>>
>> >> >>>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> For additional commands, e-mail: user-help@commons.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

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


Re: [digester] how can I print children tags instead of only tag content ?

Posted by Patrick Diviacco <pa...@gmail.com>.
OK. Solved, thanks - grazie mille

On 15 May 2011 11:28, Simone Tripodi <si...@apache.org> wrote:

> IIUC = if I understand correctly ;)
>
> A quick hint: why don't you manage the logic inside your business
> logic? I mean, you configure the digester:
>
>    Digester digester = new Digester();
>    digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>
>    digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>
> then check the 'myMethod' has already been invoked:
>
>    boolean check = false;
>
>    public void myMethod( String arg )
>    {
>        if ( !check )
>        {
>            System.out.println( arg );
>            check = true;
>        }
>    }
>
> HTH, let me know your progress!
> Simo
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Sun, May 15, 2011 at 8:58 AM, Patrick Diviacco
> <pa...@gmail.com> wrote:
> > what does IIUC mean ?
> >
> > Yeah. I mean, more exactly, I just need to know if the element has at
> least
> > a child:
> >
> > bool = hasChild(myPattern)
> >
> > thanks
> >
> > On 15 May 2011 02:09, Simone Tripodi <si...@apache.org> wrote:
> >
> >> IIUC, no matters which kind of children your node has, you're
> >> interested only on the first child, right?
> >>
> >> http://people.apache.org/~simonetripodi/
> >> http://www.99soft.org/
> >>
> >>
> >>
> >> On Sat, May 14, 2011 at 10:51 PM, Patrick Diviacco
> >> <pa...@gmail.com> wrote:
> >> > ps. the children names are completely different, there is no way to
> use a
> >> > regex to discriminate between them.
> >> >
> >> >
> >> >
> >> > On 14 May 2011 22:50, Patrick Diviacco <pa...@gmail.com>
> >> wrote:
> >> >
> >> >> hi Simone,
> >> >>
> >> >> ok, it was just matter of adding one line :)
> >> >>
> >> >> By the way I still have an issue in the case of multiple children and
> I
> >> >> don't know how to solve it. If I have a document containing:
> >> >>
> >> >> <parent>
> >> >> <child1></child1>
> >> >> <child2></child2>
> >> >> </parent>
> >> >>
> >> >> I don't want to  trigger the method twice, but just once... in other
> >> terms
> >> >> I want to trigger the method only once per document and only if the
> >> <parent>
> >> >> tag has at least 1 child.
> >> >>
> >> >> I copy my code again:
> >> >>
> >> >> Digester digester = new Digester();
> >> >> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
> >> >>
> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
> >> >>
> >> >> thanks
> >> >> Patrick
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> On 14 May 2011 21:54, Simone Tripodi <si...@apache.org>
> wrote:
> >> >>
> >> >>> Hi Patrick,
> >> >>> I thought it was more intuitive, sounds we have to update de doc.
> >> >>> Anyway, to reply to your questions:
> >> >>>
> >> >>> 1) just create the Digester instance, set the RegexRules and start
> >> >>> binding your rules:
> >> >>>
> >> >>> Digester digester = new Digester();
> >> >>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
> >> >>> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
> >> >>>
> >> >>> 2) yes, as reported in the javadoc I pointed: "* matches any
> sequence
> >> >>> of none, one or more characters" like in the bash syntax; if you
> want
> >> >>> to apply kind of filters, bind the rules with restrictive patterns
> >> >>> (prefixes/postfixes); ie. given the rule:
> >> >>>
> >> >>> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0
> );
> >> >>>
> >> >>> collection/doc/categ/patt -> matches
> >> >>> collection/doc/categ/pattern -> matches
> >> >>> collection/doc/categ/patteRn -> matches
> >> >>> collection/doc/categ/pattern -> matches
> >> >>> collection/doc/categ/paBtern -> does not match
> >> >>>
> >> >>> HTH, have a nice weekend,
> >> >>> Simo
> >> >>>
> >> >>> http://people.apache.org/~simonetripodi/
> >> >>> http://www.99soft.org/
> >> >>>
> >> >>>
> >> >>>
> >> >>> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
> >> >>> <pa...@gmail.com> wrote:
> >> >>> > Thanks,
> >> >>> >
> >> >>> > 1) Is there any tutorial explaining how to use it ?
> >> >>> >
> >> >>> > 2) In my case, if I have more than one child, is the pattern
> detected
> >> >>> > multiple times ?
> >> >>> >
> >> >>> > help is very appreciated!
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org>
> >> wrote:
> >> >>> >
> >> >>> >> Hi Patrick,
> >> >>> >> follow the Konstantin's suggestion, that's the way to achieve it.
> >> Have
> >> >>> >> a read also to
> >> >>> >>
> >> >>>
> >>
> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
> >> >>> >>
> >> >>> >> HTH,
> >> >>> >> Simo
> >> >>> >>
> >> >>> >> http://people.apache.org/~simonetripodi/
> >> >>> >> http://www.99soft.org/
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
> >> >>> >> <kn...@gmail.com> wrote:
> >> >>> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
> >> >>> >> >> mhm, sorry.. just to be more clear.
> >> >>> >> >>
> >> >>> >> >> Is there a way in Commons Digester to trigger a method only if
> a
> >> xml
> >> >>> >> element
> >> >>> >> >> has a child ?
> >> >>> >> >>
> >> >>> >> >> i.e.
> >> >>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod",
> 0);
> >> >>> >> >>
> >> >>> >> >> This doesn't work.
> >> >>> >> >
> >> >>> >> > The "*" is allowed in the prefix only, as documented in
> >> >>> >> >
> >> >>> >> >
> >> >>> >>
> >> >>>
> >>
> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
> >> >>> >> >
> >> >>> >> > You may try to use a different rules matcher. See
> "RegexMatchers"
> >> >>> chapter
> >> >>> >> here:
> >> >>> >> >
> http://commons.apache.org/digester/commons-digester-2.1/core.html
> >> >>> >> >
> >> >>> >> >
> >> >>> >> >> But it is actually what I need. If element <categ> has at
> >> >>> >> >> least a child, then trigger myMethod
> >> >>> >> >
> >> >>> >> > Best regards,
> >> >>> >> > Konstantin Kolinko
> >> >>> >> >
> >> >>> >> >
> >> ---------------------------------------------------------------------
> >> >>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> >>> >> > For additional commands, e-mail: user-help@commons.apache.org
> >> >>> >> >
> >> >>> >> >
> >> >>> >>
> >> >>> >>
> >> ---------------------------------------------------------------------
> >> >>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> >>> >> For additional commands, e-mail: user-help@commons.apache.org
> >> >>> >>
> >> >>> >>
> >> >>> >
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> >>> For additional commands, e-mail: user-help@commons.apache.org
> >> >>>
> >> >>>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: user-help@commons.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [digester] how can I print children tags instead of only tag content ?

Posted by Simone Tripodi <si...@apache.org>.
IIUC = if I understand correctly ;)

A quick hint: why don't you manage the logic inside your business
logic? I mean, you configure the digester:

    Digester digester = new Digester();
    digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );

    digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );

then check the 'myMethod' has already been invoked:

    boolean check = false;

    public void myMethod( String arg )
    {
        if ( !check )
        {
            System.out.println( arg );
            check = true;
        }
    }

HTH, let me know your progress!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sun, May 15, 2011 at 8:58 AM, Patrick Diviacco
<pa...@gmail.com> wrote:
> what does IIUC mean ?
>
> Yeah. I mean, more exactly, I just need to know if the element has at least
> a child:
>
> bool = hasChild(myPattern)
>
> thanks
>
> On 15 May 2011 02:09, Simone Tripodi <si...@apache.org> wrote:
>
>> IIUC, no matters which kind of children your node has, you're
>> interested only on the first child, right?
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Sat, May 14, 2011 at 10:51 PM, Patrick Diviacco
>> <pa...@gmail.com> wrote:
>> > ps. the children names are completely different, there is no way to use a
>> > regex to discriminate between them.
>> >
>> >
>> >
>> > On 14 May 2011 22:50, Patrick Diviacco <pa...@gmail.com>
>> wrote:
>> >
>> >> hi Simone,
>> >>
>> >> ok, it was just matter of adding one line :)
>> >>
>> >> By the way I still have an issue in the case of multiple children and I
>> >> don't know how to solve it. If I have a document containing:
>> >>
>> >> <parent>
>> >> <child1></child1>
>> >> <child2></child2>
>> >> </parent>
>> >>
>> >> I don't want to  trigger the method twice, but just once... in other
>> terms
>> >> I want to trigger the method only once per document and only if the
>> <parent>
>> >> tag has at least 1 child.
>> >>
>> >> I copy my code again:
>> >>
>> >> Digester digester = new Digester();
>> >> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>> >>
>> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>> >>
>> >> thanks
>> >> Patrick
>> >>
>> >>
>> >>
>> >>
>> >> On 14 May 2011 21:54, Simone Tripodi <si...@apache.org> wrote:
>> >>
>> >>> Hi Patrick,
>> >>> I thought it was more intuitive, sounds we have to update de doc.
>> >>> Anyway, to reply to your questions:
>> >>>
>> >>> 1) just create the Digester instance, set the RegexRules and start
>> >>> binding your rules:
>> >>>
>> >>> Digester digester = new Digester();
>> >>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>> >>> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>> >>>
>> >>> 2) yes, as reported in the javadoc I pointed: "* matches any sequence
>> >>> of none, one or more characters" like in the bash syntax; if you want
>> >>> to apply kind of filters, bind the rules with restrictive patterns
>> >>> (prefixes/postfixes); ie. given the rule:
>> >>>
>> >>> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0 );
>> >>>
>> >>> collection/doc/categ/patt -> matches
>> >>> collection/doc/categ/pattern -> matches
>> >>> collection/doc/categ/patteRn -> matches
>> >>> collection/doc/categ/pattern -> matches
>> >>> collection/doc/categ/paBtern -> does not match
>> >>>
>> >>> HTH, have a nice weekend,
>> >>> Simo
>> >>>
>> >>> http://people.apache.org/~simonetripodi/
>> >>> http://www.99soft.org/
>> >>>
>> >>>
>> >>>
>> >>> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
>> >>> <pa...@gmail.com> wrote:
>> >>> > Thanks,
>> >>> >
>> >>> > 1) Is there any tutorial explaining how to use it ?
>> >>> >
>> >>> > 2) In my case, if I have more than one child, is the pattern detected
>> >>> > multiple times ?
>> >>> >
>> >>> > help is very appreciated!
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org>
>> wrote:
>> >>> >
>> >>> >> Hi Patrick,
>> >>> >> follow the Konstantin's suggestion, that's the way to achieve it.
>> Have
>> >>> >> a read also to
>> >>> >>
>> >>>
>> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
>> >>> >>
>> >>> >> HTH,
>> >>> >> Simo
>> >>> >>
>> >>> >> http://people.apache.org/~simonetripodi/
>> >>> >> http://www.99soft.org/
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
>> >>> >> <kn...@gmail.com> wrote:
>> >>> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
>> >>> >> >> mhm, sorry.. just to be more clear.
>> >>> >> >>
>> >>> >> >> Is there a way in Commons Digester to trigger a method only if a
>> xml
>> >>> >> element
>> >>> >> >> has a child ?
>> >>> >> >>
>> >>> >> >> i.e.
>> >>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>> >>> >> >>
>> >>> >> >> This doesn't work.
>> >>> >> >
>> >>> >> > The "*" is allowed in the prefix only, as documented in
>> >>> >> >
>> >>> >> >
>> >>> >>
>> >>>
>> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
>> >>> >> >
>> >>> >> > You may try to use a different rules matcher. See "RegexMatchers"
>> >>> chapter
>> >>> >> here:
>> >>> >> > http://commons.apache.org/digester/commons-digester-2.1/core.html
>> >>> >> >
>> >>> >> >
>> >>> >> >> But it is actually what I need. If element <categ> has at
>> >>> >> >> least a child, then trigger myMethod
>> >>> >> >
>> >>> >> > Best regards,
>> >>> >> > Konstantin Kolinko
>> >>> >> >
>> >>> >> >
>> ---------------------------------------------------------------------
>> >>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >>> >> > For additional commands, e-mail: user-help@commons.apache.org
>> >>> >> >
>> >>> >> >
>> >>> >>
>> >>> >>
>> ---------------------------------------------------------------------
>> >>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >>> >> For additional commands, e-mail: user-help@commons.apache.org
>> >>> >>
>> >>> >>
>> >>> >
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >>> For additional commands, e-mail: user-help@commons.apache.org
>> >>>
>> >>>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

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


Re: [digester] how can I print children tags instead of only tag content ?

Posted by Patrick Diviacco <pa...@gmail.com>.
what does IIUC mean ?

Yeah. I mean, more exactly, I just need to know if the element has at least
a child:

bool = hasChild(myPattern)

thanks

On 15 May 2011 02:09, Simone Tripodi <si...@apache.org> wrote:

> IIUC, no matters which kind of children your node has, you're
> interested only on the first child, right?
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Sat, May 14, 2011 at 10:51 PM, Patrick Diviacco
> <pa...@gmail.com> wrote:
> > ps. the children names are completely different, there is no way to use a
> > regex to discriminate between them.
> >
> >
> >
> > On 14 May 2011 22:50, Patrick Diviacco <pa...@gmail.com>
> wrote:
> >
> >> hi Simone,
> >>
> >> ok, it was just matter of adding one line :)
> >>
> >> By the way I still have an issue in the case of multiple children and I
> >> don't know how to solve it. If I have a document containing:
> >>
> >> <parent>
> >> <child1></child1>
> >> <child2></child2>
> >> </parent>
> >>
> >> I don't want to  trigger the method twice, but just once... in other
> terms
> >> I want to trigger the method only once per document and only if the
> <parent>
> >> tag has at least 1 child.
> >>
> >> I copy my code again:
> >>
> >> Digester digester = new Digester();
> >> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
> >>
> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
> >>
> >> thanks
> >> Patrick
> >>
> >>
> >>
> >>
> >> On 14 May 2011 21:54, Simone Tripodi <si...@apache.org> wrote:
> >>
> >>> Hi Patrick,
> >>> I thought it was more intuitive, sounds we have to update de doc.
> >>> Anyway, to reply to your questions:
> >>>
> >>> 1) just create the Digester instance, set the RegexRules and start
> >>> binding your rules:
> >>>
> >>> Digester digester = new Digester();
> >>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
> >>> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
> >>>
> >>> 2) yes, as reported in the javadoc I pointed: "* matches any sequence
> >>> of none, one or more characters" like in the bash syntax; if you want
> >>> to apply kind of filters, bind the rules with restrictive patterns
> >>> (prefixes/postfixes); ie. given the rule:
> >>>
> >>> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0 );
> >>>
> >>> collection/doc/categ/patt -> matches
> >>> collection/doc/categ/pattern -> matches
> >>> collection/doc/categ/patteRn -> matches
> >>> collection/doc/categ/pattern -> matches
> >>> collection/doc/categ/paBtern -> does not match
> >>>
> >>> HTH, have a nice weekend,
> >>> Simo
> >>>
> >>> http://people.apache.org/~simonetripodi/
> >>> http://www.99soft.org/
> >>>
> >>>
> >>>
> >>> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
> >>> <pa...@gmail.com> wrote:
> >>> > Thanks,
> >>> >
> >>> > 1) Is there any tutorial explaining how to use it ?
> >>> >
> >>> > 2) In my case, if I have more than one child, is the pattern detected
> >>> > multiple times ?
> >>> >
> >>> > help is very appreciated!
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org>
> wrote:
> >>> >
> >>> >> Hi Patrick,
> >>> >> follow the Konstantin's suggestion, that's the way to achieve it.
> Have
> >>> >> a read also to
> >>> >>
> >>>
> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
> >>> >>
> >>> >> HTH,
> >>> >> Simo
> >>> >>
> >>> >> http://people.apache.org/~simonetripodi/
> >>> >> http://www.99soft.org/
> >>> >>
> >>> >>
> >>> >>
> >>> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
> >>> >> <kn...@gmail.com> wrote:
> >>> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
> >>> >> >> mhm, sorry.. just to be more clear.
> >>> >> >>
> >>> >> >> Is there a way in Commons Digester to trigger a method only if a
> xml
> >>> >> element
> >>> >> >> has a child ?
> >>> >> >>
> >>> >> >> i.e.
> >>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
> >>> >> >>
> >>> >> >> This doesn't work.
> >>> >> >
> >>> >> > The "*" is allowed in the prefix only, as documented in
> >>> >> >
> >>> >> >
> >>> >>
> >>>
> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
> >>> >> >
> >>> >> > You may try to use a different rules matcher. See "RegexMatchers"
> >>> chapter
> >>> >> here:
> >>> >> > http://commons.apache.org/digester/commons-digester-2.1/core.html
> >>> >> >
> >>> >> >
> >>> >> >> But it is actually what I need. If element <categ> has at
> >>> >> >> least a child, then trigger myMethod
> >>> >> >
> >>> >> > Best regards,
> >>> >> > Konstantin Kolinko
> >>> >> >
> >>> >> >
> ---------------------------------------------------------------------
> >>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >>> >> > For additional commands, e-mail: user-help@commons.apache.org
> >>> >> >
> >>> >> >
> >>> >>
> >>> >>
> ---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >>> >> For additional commands, e-mail: user-help@commons.apache.org
> >>> >>
> >>> >>
> >>> >
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >>> For additional commands, e-mail: user-help@commons.apache.org
> >>>
> >>>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [digester] how can I print children tags instead of only tag content ?

Posted by Simone Tripodi <si...@apache.org>.
IIUC, no matters which kind of children your node has, you're
interested only on the first child, right?

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sat, May 14, 2011 at 10:51 PM, Patrick Diviacco
<pa...@gmail.com> wrote:
> ps. the children names are completely different, there is no way to use a
> regex to discriminate between them.
>
>
>
> On 14 May 2011 22:50, Patrick Diviacco <pa...@gmail.com> wrote:
>
>> hi Simone,
>>
>> ok, it was just matter of adding one line :)
>>
>> By the way I still have an issue in the case of multiple children and I
>> don't know how to solve it. If I have a document containing:
>>
>> <parent>
>> <child1></child1>
>> <child2></child2>
>> </parent>
>>
>> I don't want to  trigger the method twice, but just once... in other terms
>> I want to trigger the method only once per document and only if the <parent>
>> tag has at least 1 child.
>>
>> I copy my code again:
>>
>> Digester digester = new Digester();
>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>>
>> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>>
>> thanks
>> Patrick
>>
>>
>>
>>
>> On 14 May 2011 21:54, Simone Tripodi <si...@apache.org> wrote:
>>
>>> Hi Patrick,
>>> I thought it was more intuitive, sounds we have to update de doc.
>>> Anyway, to reply to your questions:
>>>
>>> 1) just create the Digester instance, set the RegexRules and start
>>> binding your rules:
>>>
>>> Digester digester = new Digester();
>>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>>> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>>>
>>> 2) yes, as reported in the javadoc I pointed: "* matches any sequence
>>> of none, one or more characters" like in the bash syntax; if you want
>>> to apply kind of filters, bind the rules with restrictive patterns
>>> (prefixes/postfixes); ie. given the rule:
>>>
>>> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0 );
>>>
>>> collection/doc/categ/patt -> matches
>>> collection/doc/categ/pattern -> matches
>>> collection/doc/categ/patteRn -> matches
>>> collection/doc/categ/pattern -> matches
>>> collection/doc/categ/paBtern -> does not match
>>>
>>> HTH, have a nice weekend,
>>> Simo
>>>
>>> http://people.apache.org/~simonetripodi/
>>> http://www.99soft.org/
>>>
>>>
>>>
>>> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
>>> <pa...@gmail.com> wrote:
>>> > Thanks,
>>> >
>>> > 1) Is there any tutorial explaining how to use it ?
>>> >
>>> > 2) In my case, if I have more than one child, is the pattern detected
>>> > multiple times ?
>>> >
>>> > help is very appreciated!
>>> >
>>> >
>>> >
>>> >
>>> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org> wrote:
>>> >
>>> >> Hi Patrick,
>>> >> follow the Konstantin's suggestion, that's the way to achieve it. Have
>>> >> a read also to
>>> >>
>>> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
>>> >>
>>> >> HTH,
>>> >> Simo
>>> >>
>>> >> http://people.apache.org/~simonetripodi/
>>> >> http://www.99soft.org/
>>> >>
>>> >>
>>> >>
>>> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
>>> >> <kn...@gmail.com> wrote:
>>> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
>>> >> >> mhm, sorry.. just to be more clear.
>>> >> >>
>>> >> >> Is there a way in Commons Digester to trigger a method only if a xml
>>> >> element
>>> >> >> has a child ?
>>> >> >>
>>> >> >> i.e.
>>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>>> >> >>
>>> >> >> This doesn't work.
>>> >> >
>>> >> > The "*" is allowed in the prefix only, as documented in
>>> >> >
>>> >> >
>>> >>
>>> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
>>> >> >
>>> >> > You may try to use a different rules matcher. See "RegexMatchers"
>>> chapter
>>> >> here:
>>> >> > http://commons.apache.org/digester/commons-digester-2.1/core.html
>>> >> >
>>> >> >
>>> >> >> But it is actually what I need. If element <categ> has at
>>> >> >> least a child, then trigger myMethod
>>> >> >
>>> >> > Best regards,
>>> >> > Konstantin Kolinko
>>> >> >
>>> >> > ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> >> > For additional commands, e-mail: user-help@commons.apache.org
>>> >> >
>>> >> >
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> >> For additional commands, e-mail: user-help@commons.apache.org
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>
>

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


Re: [digester] how can I print children tags instead of only tag content ?

Posted by Patrick Diviacco <pa...@gmail.com>.
ps. the children names are completely different, there is no way to use a
regex to discriminate between them.



On 14 May 2011 22:50, Patrick Diviacco <pa...@gmail.com> wrote:

> hi Simone,
>
> ok, it was just matter of adding one line :)
>
> By the way I still have an issue in the case of multiple children and I
> don't know how to solve it. If I have a document containing:
>
> <parent>
> <child1></child1>
> <child2></child2>
> </parent>
>
> I don't want to  trigger the method twice, but just once... in other terms
> I want to trigger the method only once per document and only if the <parent>
> tag has at least 1 child.
>
> I copy my code again:
>
> Digester digester = new Digester();
> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>
> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>
> thanks
> Patrick
>
>
>
>
> On 14 May 2011 21:54, Simone Tripodi <si...@apache.org> wrote:
>
>> Hi Patrick,
>> I thought it was more intuitive, sounds we have to update de doc.
>> Anyway, to reply to your questions:
>>
>> 1) just create the Digester instance, set the RegexRules and start
>> binding your rules:
>>
>> Digester digester = new Digester();
>> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
>> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>>
>> 2) yes, as reported in the javadoc I pointed: "* matches any sequence
>> of none, one or more characters" like in the bash syntax; if you want
>> to apply kind of filters, bind the rules with restrictive patterns
>> (prefixes/postfixes); ie. given the rule:
>>
>> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0 );
>>
>> collection/doc/categ/patt -> matches
>> collection/doc/categ/pattern -> matches
>> collection/doc/categ/patteRn -> matches
>> collection/doc/categ/pattern -> matches
>> collection/doc/categ/paBtern -> does not match
>>
>> HTH, have a nice weekend,
>> Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
>> <pa...@gmail.com> wrote:
>> > Thanks,
>> >
>> > 1) Is there any tutorial explaining how to use it ?
>> >
>> > 2) In my case, if I have more than one child, is the pattern detected
>> > multiple times ?
>> >
>> > help is very appreciated!
>> >
>> >
>> >
>> >
>> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org> wrote:
>> >
>> >> Hi Patrick,
>> >> follow the Konstantin's suggestion, that's the way to achieve it. Have
>> >> a read also to
>> >>
>> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
>> >>
>> >> HTH,
>> >> Simo
>> >>
>> >> http://people.apache.org/~simonetripodi/
>> >> http://www.99soft.org/
>> >>
>> >>
>> >>
>> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
>> >> <kn...@gmail.com> wrote:
>> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
>> >> >> mhm, sorry.. just to be more clear.
>> >> >>
>> >> >> Is there a way in Commons Digester to trigger a method only if a xml
>> >> element
>> >> >> has a child ?
>> >> >>
>> >> >> i.e.
>> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>> >> >>
>> >> >> This doesn't work.
>> >> >
>> >> > The "*" is allowed in the prefix only, as documented in
>> >> >
>> >> >
>> >>
>> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
>> >> >
>> >> > You may try to use a different rules matcher. See "RegexMatchers"
>> chapter
>> >> here:
>> >> > http://commons.apache.org/digester/commons-digester-2.1/core.html
>> >> >
>> >> >
>> >> >> But it is actually what I need. If element <categ> has at
>> >> >> least a child, then trigger myMethod
>> >> >
>> >> > Best regards,
>> >> > Konstantin Kolinko
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> > For additional commands, e-mail: user-help@commons.apache.org
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> For additional commands, e-mail: user-help@commons.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

Re: [digester] how can I print children tags instead of only tag content ?

Posted by Patrick Diviacco <pa...@gmail.com>.
hi Simone,

ok, it was just matter of adding one line :)

By the way I still have an issue in the case of multiple children and I
don't know how to solve it. If I have a document containing:

<parent>
<child1></child1>
<child2></child2>
</parent>

I don't want to  trigger the method twice, but just once... in other terms I
want to trigger the method only once per document and only if the <parent>
tag has at least 1 child.

I copy my code again:

Digester digester = new Digester();
digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );

digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);

thanks
Patrick




On 14 May 2011 21:54, Simone Tripodi <si...@apache.org> wrote:

> Hi Patrick,
> I thought it was more intuitive, sounds we have to update de doc.
> Anyway, to reply to your questions:
>
> 1) just create the Digester instance, set the RegexRules and start
> binding your rules:
>
> Digester digester = new Digester();
> digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
> digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );
>
> 2) yes, as reported in the javadoc I pointed: "* matches any sequence
> of none, one or more characters" like in the bash syntax; if you want
> to apply kind of filters, bind the rules with restrictive patterns
> (prefixes/postfixes); ie. given the rule:
>
> digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0 );
>
> collection/doc/categ/patt -> matches
> collection/doc/categ/pattern -> matches
> collection/doc/categ/patteRn -> matches
> collection/doc/categ/pattern -> matches
> collection/doc/categ/paBtern -> does not match
>
> HTH, have a nice weekend,
> Simo
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
> <pa...@gmail.com> wrote:
> > Thanks,
> >
> > 1) Is there any tutorial explaining how to use it ?
> >
> > 2) In my case, if I have more than one child, is the pattern detected
> > multiple times ?
> >
> > help is very appreciated!
> >
> >
> >
> >
> > On 14 May 2011 01:36, Simone Tripodi <si...@apache.org> wrote:
> >
> >> Hi Patrick,
> >> follow the Konstantin's suggestion, that's the way to achieve it. Have
> >> a read also to
> >>
> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
> >>
> >> HTH,
> >> Simo
> >>
> >> http://people.apache.org/~simonetripodi/
> >> http://www.99soft.org/
> >>
> >>
> >>
> >> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
> >> <kn...@gmail.com> wrote:
> >> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
> >> >> mhm, sorry.. just to be more clear.
> >> >>
> >> >> Is there a way in Commons Digester to trigger a method only if a xml
> >> element
> >> >> has a child ?
> >> >>
> >> >> i.e.
> >> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
> >> >>
> >> >> This doesn't work.
> >> >
> >> > The "*" is allowed in the prefix only, as documented in
> >> >
> >> >
> >>
> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
> >> >
> >> > You may try to use a different rules matcher. See "RegexMatchers"
> chapter
> >> here:
> >> > http://commons.apache.org/digester/commons-digester-2.1/core.html
> >> >
> >> >
> >> >> But it is actually what I need. If element <categ> has at
> >> >> least a child, then trigger myMethod
> >> >
> >> > Best regards,
> >> > Konstantin Kolinko
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> > For additional commands, e-mail: user-help@commons.apache.org
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: user-help@commons.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [digester] how can I print children tags instead of only tag content ?

Posted by Simone Tripodi <si...@apache.org>.
Hi Patrick,
I thought it was more intuitive, sounds we have to update de doc.
Anyway, to reply to your questions:

1) just create the Digester instance, set the RegexRules and start
binding your rules:

Digester digester = new Digester();
digester.setRules( new RegexRules( new SimpleRegexMatcher() ) );
digester.addCallMethod( "collection/doc/categ/*",  "myMethod", 0 );

2) yes, as reported in the javadoc I pointed: "* matches any sequence
of none, one or more characters" like in the bash syntax; if you want
to apply kind of filters, bind the rules with restrictive patterns
(prefixes/postfixes); ie. given the rule:

digester.addCallMethod( "collection/doc/categ/patt*",  "myMethod", 0 );

collection/doc/categ/patt -> matches
collection/doc/categ/pattern -> matches
collection/doc/categ/patteRn -> matches
collection/doc/categ/pattern -> matches
collection/doc/categ/paBtern -> does not match

HTH, have a nice weekend,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sat, May 14, 2011 at 8:58 PM, Patrick Diviacco
<pa...@gmail.com> wrote:
> Thanks,
>
> 1) Is there any tutorial explaining how to use it ?
>
> 2) In my case, if I have more than one child, is the pattern detected
> multiple times ?
>
> help is very appreciated!
>
>
>
>
> On 14 May 2011 01:36, Simone Tripodi <si...@apache.org> wrote:
>
>> Hi Patrick,
>> follow the Konstantin's suggestion, that's the way to achieve it. Have
>> a read also to
>> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
>>
>> HTH,
>> Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
>> <kn...@gmail.com> wrote:
>> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
>> >> mhm, sorry.. just to be more clear.
>> >>
>> >> Is there a way in Commons Digester to trigger a method only if a xml
>> element
>> >> has a child ?
>> >>
>> >> i.e.
>> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>> >>
>> >> This doesn't work.
>> >
>> > The "*" is allowed in the prefix only, as documented in
>> >
>> >
>> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
>> >
>> > You may try to use a different rules matcher. See "RegexMatchers" chapter
>> here:
>> > http://commons.apache.org/digester/commons-digester-2.1/core.html
>> >
>> >
>> >> But it is actually what I need. If element <categ> has at
>> >> least a child, then trigger myMethod
>> >
>> > Best regards,
>> > Konstantin Kolinko
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: user-help@commons.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

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


Re: [digester] how can I print children tags instead of only tag content ?

Posted by Patrick Diviacco <pa...@gmail.com>.
Thanks,

1) Is there any tutorial explaining how to use it ?

2) In my case, if I have more than one child, is the pattern detected
multiple times ?

help is very appreciated!




On 14 May 2011 01:36, Simone Tripodi <si...@apache.org> wrote:

> Hi Patrick,
> follow the Konstantin's suggestion, that's the way to achieve it. Have
> a read also to
> http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html
>
> HTH,
> Simo
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
> <kn...@gmail.com> wrote:
> > 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
> >> mhm, sorry.. just to be more clear.
> >>
> >> Is there a way in Commons Digester to trigger a method only if a xml
> element
> >> has a child ?
> >>
> >> i.e.
> >> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
> >>
> >> This doesn't work.
> >
> > The "*" is allowed in the prefix only, as documented in
> >
> >
> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
> >
> > You may try to use a different rules matcher. See "RegexMatchers" chapter
> here:
> > http://commons.apache.org/digester/commons-digester-2.1/core.html
> >
> >
> >> But it is actually what I need. If element <categ> has at
> >> least a child, then trigger myMethod
> >
> > Best regards,
> > Konstantin Kolinko
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [digester] how can I print children tags instead of only tag content ?

Posted by Simone Tripodi <si...@apache.org>.
Hi Patrick,
follow the Konstantin's suggestion, that's the way to achieve it. Have
a read also to http://commons.apache.org/digester/apidocs/index.html?org/apache/commons/digester/SimpleRegexMatcher.html

HTH,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Fri, May 13, 2011 at 8:28 PM, Konstantin Kolinko
<kn...@gmail.com> wrote:
> 2011/5/13 Patrick Diviacco <pa...@gmail.com>:
>> mhm, sorry.. just to be more clear.
>>
>> Is there a way in Commons Digester to trigger a method only if a xml element
>> has a child ?
>>
>> i.e.
>> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>>
>> This doesn't work.
>
> The "*" is allowed in the prefix only, as documented in
>
> http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html
>
> You may try to use a different rules matcher. See "RegexMatchers" chapter here:
> http://commons.apache.org/digester/commons-digester-2.1/core.html
>
>
>> But it is actually what I need. If element <categ> has at
>> least a child, then trigger myMethod
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [digester] how can I print children tags instead of only tag content ?

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/5/13 Patrick Diviacco <pa...@gmail.com>:
> mhm, sorry.. just to be more clear.
>
> Is there a way in Commons Digester to trigger a method only if a xml element
> has a child ?
>
> i.e.
> digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);
>
> This doesn't work.

The "*" is allowed in the prefix only, as documented in

http://commons.apache.org/digester/commons-digester-2.1/docs/api/org/apache/commons/digester/RulesBase.html

You may try to use a different rules matcher. See "RegexMatchers" chapter here:
http://commons.apache.org/digester/commons-digester-2.1/core.html


> But it is actually what I need. If element <categ> has at
> least a child, then trigger myMethod

Best regards,
Konstantin Kolinko

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


Re: [digester] how can I print children tags instead of only tag content ?

Posted by Patrick Diviacco <pa...@gmail.com>.
mhm, sorry.. just to be more clear.

Is there a way in Commons Digester to trigger a method only if a xml element
has a child ?

i.e.
digester.addCallMethod("collection/doc/categ/*",  "myMethod", 0);

This doesn't work. But it is actually what I need. If element <categ> has at
least a child, then trigger myMethod

thanks






On 13 May 2011 18:48, Patrick Diviacco <pa...@gmail.com> wrote:

> I need to print the content of <categ> in my XML file (including children
> tags).
>
> For example, if I have <categ><child></child></categ>, I want to print
> "<child></child>"
>
> I'm currently parsing the xml file with: digester.addCallMethod("collection/doc/categ",
>  "checkCateg", 0);
>
> and this is the checkCateg function:
> public void checkCateg(String categ) {
> System.out.println(categ);
> }
>
> It doesn't work. The string categ is always empty because it only contains
> text content in <categ> but not its children tags.
>
> thanks,
> Patrick
>