Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52E304CC1 for ; Sun, 15 May 2011 06:59:13 +0000 (UTC) Received: (qmail 22228 invoked by uid 500); 15 May 2011 06:59:12 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 21881 invoked by uid 500); 15 May 2011 06:59:12 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 21796 invoked by uid 99); 15 May 2011 06:59:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 May 2011 06:59:10 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of patrick.diviacco@gmail.com designates 209.85.161.43 as permitted sender) Received: from [209.85.161.43] (HELO mail-fx0-f43.google.com) (209.85.161.43) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 May 2011 06:59:02 +0000 Received: by fxm3 with SMTP id 3so2813427fxm.30 for ; Sat, 14 May 2011 23:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZTvyC8AcBNtMROf2haQdx+irJOKCm4LGubEcPy/nzEw=; b=p/jVtQ3qwqGdwCpBpa/t1c6kUUF1CArq84VmvxD7U6eB0ZVwB93EIzk7RCEEQfTkbe lEis7YVjkCXFk3nGFYOy1JIwifdS52YZb4yn4Gl7i2guS9He/oqi0v8sdm92OZWC7OCQ b9rrjeX5xxF4SHa2MBRlgLsPN4uuKfb1p7Ne8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=SRImb03D5K1Ixaqd8mzo0aQomecUE28aONK9YUC5P71NDW0WeygC9Kqt7gNDd4kV+S DVXYsrwWhM7TIyqoz+5MbM4ogI6nBBu2xkn9zFR+oLECsZdvAVH8SBjRMPqBk+rZIF/j amVlMT8Ar7rK1q1JK5bRDTPe0enbLoFtzV1UU= MIME-Version: 1.0 Received: by 10.223.43.145 with SMTP id w17mr3801247fae.12.1305442722363; Sat, 14 May 2011 23:58:42 -0700 (PDT) Received: by 10.223.159.131 with HTTP; Sat, 14 May 2011 23:58:42 -0700 (PDT) In-Reply-To: References: Date: Sun, 15 May 2011 08:58:42 +0200 Message-ID: Subject: Re: [digester] how can I print children tags instead of only tag content ? From: Patrick Diviacco To: Commons Users List Content-Type: multipart/alternative; boundary=001517440fd0bdbba504a34b110e X-Virus-Checked: Checked by ClamAV on apache.org --001517440fd0bdbba504a34b110e Content-Type: text/plain; charset=ISO-8859-1 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 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 > 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 > 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: > >> > >> > >> > >> > >> > >> > >> 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 > > >> 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 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 > >>> 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 > 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 > >>> >> wrote: > >>> >> > 2011/5/13 Patrick Diviacco : > >>> >> >> 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 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 > > --001517440fd0bdbba504a34b110e--