Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 20534 invoked from network); 31 Oct 2007 08:22:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Oct 2007 08:22:55 -0000 Received: (qmail 62261 invoked by uid 500); 31 Oct 2007 08:22:39 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 62215 invoked by uid 500); 31 Oct 2007 08:22:39 -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 62206 invoked by uid 99); 31 Oct 2007 08:22:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2007 01:22:39 -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 viefep18-int.chello.at) (213.46.255.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2007 08:22:41 +0000 Received: from viefep18 ([192.168.13.147]) by viefep18-int.chello.at (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20071031082219.DJAP12374.viefep18-int.chello.at@viefep18>; Wed, 31 Oct 2007 09:22:19 +0100 Message-ID: <29674590.1193818939405.JavaMail.root@viefep18> Date: Wed, 31 Oct 2007 9:22:19 +0100 From: Simon Kitching To: Jakarta Commons Users List Subject: Re: JAKARTA COMMONS DIGESTER RULES XML PROBLEM Cc: Kapil Pruthi MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) Sensitivity: Normal X-Originating-IP: from 62.116.38.218 by web-edge.chello.com; Wed, 31 Oct 2007 9:22:19 +0100 X-Virus-Checked: Checked by ClamAV on apache.org ---- Kapil Pruthi schrieb: > Hi Guys, > > > > > I have gone through Jakarta digester project and found it too good but > > there is small info i need for sure to start using this. > > > > How do i create XML rules? Don't tell me manually as my data xml is huge. > > Also i want to use digester for many different cases so obviously i don't > > prefer to write digester-rules.xml for every case manually. > > > > but i want this file to be created somehow...how ??? > > my data xml and java objects are identical in terms of > > xml tag name <-> Java bean (one to one mapping) > > > > so basically i want to avoid specifying any rules (xml or programmatic) , > > how do i do that? > > Ok lets say i am suppose to use xml rule, then how do i create this huge > > digester-rules.xml ? any tool to do that ? > > > > Any other way to do it >? > > I have data xml's and corresponding java objects (java field names word to > > word same as xml tag name)... Possibly in your case you could define a FactoryCreateRule that is mapped using the pattern "*", and the corresponding ObjectFactory would just use the tagname as the name of the class to instantiate. A SetPropertiesRule mapped using the pattern "*" would also handle all the xml attributes. Whether adding child nodes to the parent can be done with a wildcard rule depends upon your format; you haven't given an example. but if it can, then that means you could configure digester with just three rules. However digester was never really designed for processing input files which have a complete 1:1 mapping to java beans. The strongest feature of Digester is the huge flexibility it offers when mapping xml to java - which you obviously do not need. And digester is not terribly fast as it uses a lot of reflection in order to be so flexible. As your code is so regular, it might be better to just write your own sax-handler to create and build the appropriate objects. You could possibly use the existing Digester code as inspiration, but a custom solution would likely be 10 times faster and 10 times smaller as you do not need a lot of the flexibility that Digester offers. NB: personally I dislike the xml-rules module. Using the java API to define rules is much easier. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org