Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 65603 invoked from network); 6 Sep 2008 12:16:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Sep 2008 12:16:33 -0000 Received: (qmail 54159 invoked by uid 500); 6 Sep 2008 12:16:28 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 54084 invoked by uid 500); 6 Sep 2008 12:16:27 -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 54073 invoked by uid 99); 6 Sep 2008 12:16:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Sep 2008 05:16:27 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG,WHOIS_NETSOLPR X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simone.tripodi@gmail.com designates 209.85.146.180 as permitted sender) Received: from [209.85.146.180] (HELO wa-out-1112.google.com) (209.85.146.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Sep 2008 12:15:35 +0000 Received: by wa-out-1112.google.com with SMTP id m34so600040wag.10 for ; Sat, 06 Sep 2008 05:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=hNMQgWJrzpK+HxYSo1ylepIMeGEjtPJpikWzOQ02p1Q=; b=T4SJsieWdqsRfA2BP8HNyOhsApLkzRhKBz8DrXFk7mr1Y13Mo/qdJgz1r/EZ8NeNd+ OACxE8W6Q5BTfIVJVK+PUhbDEhUCgf/dXkjWgoaSgefivhXiKgM3SVCN3ZPVfbSwG4XE hTczZj2aWLsWrPzr0Hs1M2AnoxMSWrWeO9FHk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=pQSLcnQCC+mLpDfT+Bwcl5s6upIoxL+r81WErLj9lipXJ+w3EH+iuTw6zL6rY7klbv x+psnlgpslAhT+FIq74h+iWEtvyvB5Evqfp+QP7iLRELINbhhshltyX4Ei8uyzkB1cyB QAaGazBr1uCg13/KbkKS+0p3kA+MxRT9gvvPw= Received: by 10.114.195.19 with SMTP id s19mr10940379waf.110.1220703366597; Sat, 06 Sep 2008 05:16:06 -0700 (PDT) Received: by 10.115.33.20 with HTTP; Sat, 6 Sep 2008 05:16:06 -0700 (PDT) Message-ID: <4173dc210809060516w51a6b024w42983e6b55e3119a@mail.gmail.com> Date: Sat, 6 Sep 2008 14:16:06 +0200 From: "Simone Tripodi" To: "Commons Users List" Subject: Re: Commons betwixt 0.8 - reading Map from XML In-Reply-To: <19336473.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <19255879.post@talk.nabble.com> <4173dc210809022325l1b623788m18f7ee9b4c4f087d@mail.gmail.com> <19336473.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Dimitry, my pleasure :) Best regards, Simone 2008/9/5 Dmitriy Kuznetsov : > > > Simone Tripodi wrote: >> >> Hi Dmitriy, >> you don't you use just the commons-digester rules to map the xml to your >> map? >> It's also a betwixt dependency library, and maybe it could be easier. >> Best regards, >> Simone >> > Well, i've made some changes since first time. The XML now looks like > following: > > > > >
...
> ... >
> > ... > ... > >
> > > ... > ... > > >
> > And as Simone suggested, i've used commons Digester instead of Betwixt: > > Digester digester = new Digester(); > > digester.setValidating(false); > > digester.addObjectCreate("metadata", Hashtable.class); > > digester.addObjectCreate("metadata/group", ListOrderedMap.class); > > Rule r = new CallMethodRule(1, "put", 2); > digester.addRule("metadata/group", r); > digester.addCallParam("metadata/group", 0, "name"); > digester.addCallParam("metadata/group", 1, true); > > // MetadataEntry is a simple bean that holds values of section > digester.addObjectCreate("metadata/group/entry", MetadataEntry.class); > > r = new SetNestedPropertiesRule(); > digester.addRule("metadata/group/entry", r); > > r = new CallMethodRule(1, "put", 2); > digester.addRule("metadata/group/entry", r); > digester.addCallParam("metadata/group/entry", 0, "name"); > digester.addCallParam("metadata/group/entry", 1, true); > > // a little later > > InputStream is = > servletContext.getResourceAsStream("WEB-INF/classes/metadata.xml"); > Object result = digester.parse(is); > > And it works. The resulting data structure is: Map MetadataEntry>> > Simone, thanks! =) > -- > View this message in context: http://www.nabble.com/Commons-betwixt-0.8---reading-Map-from-XML-tp19255879p19336473.html > Sent from the Commons - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > -- My LinkedIn profile: http://www.linkedin.com/in/simonetripodi My GoogleCode profile: http://code.google.com/u/simone.tripodi/ My Sourceforge: https://sourceforge.net/users/stripodi My Picasa: http://picasaweb.google.com/simone.tripodi/ My Tube: http://www.youtube.com/user/stripodi My Del.icio.us: http://del.icio.us/simone.tripodi --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org