From user-return-19723-apmail-commons-user-archive=commons.apache.org@commons.apache.org Fri Aug 10 15:20:28 2007 Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 60985 invoked from network); 10 Aug 2007 15:20:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Aug 2007 15:20:22 -0000 Received: (qmail 32540 invoked by uid 500); 10 Aug 2007 15:20:16 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 32487 invoked by uid 500); 10 Aug 2007 15:20:16 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 32478 invoked by uid 99); 10 Aug 2007 15:20:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 08:20:16 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [213.46.255.22] (HELO viefep16-int.chello.at) (213.46.255.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2007 15:20:11 +0000 Received: from [192.168.0.4] (really [84.113.196.60]) by viefep16-int.chello.at (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070810151948.JMMU1686.viefep16-int.chello.at@[192.168.0.4]> for ; Fri, 10 Aug 2007 17:19:48 +0200 Subject: Re: Apache Digester SetNestedPropertiesRule From: simon To: Jakarta Commons Users List In-Reply-To: <983251.31441.qm@web32010.mail.mud.yahoo.com> References: <983251.31441.qm@web32010.mail.mud.yahoo.com> Content-Type: text/plain Date: Fri, 10 Aug 2007 17:19:20 +0200 Message-Id: <1186759160.6088.6.camel@simon-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Fri, 2007-08-10 at 07:04 -0700, DM wrote: > Hi, > > I'm writing my own subclass of SetNestedPropertiesRule. Within the body of the overriden begin method > > begin(java.lang.String namespace, java.lang.String name, org.xml.sax.Attributes attributes) { > // my implementation here > } > > I'd like to access the text of the nested elements. So, if the rule fires for the element shown below: > > > sub-nick3 > 2000000003 > > > > Then I need to be able to read "sub-nick3" and "200000003" within the begin() method. Any idea how I can do this? You can't. Not in the begin method. Digester uses SAX, ie event-driven xml parsing. In other words, the xml input goes into a standard xml parser that then emits SAX parsing events that digester catches and handles. SAX is very efficient, but there is no way to "look ahead" in the file. In particular when a "start element" event is sent by the parser the xml attributes are available, but the nested elements have not yet been read from the input so cannot be accessed. That's why the SetNestedPropertiesRule class is complex... Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org