Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 11271 invoked from network); 27 Mar 2008 16:05:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Mar 2008 16:05:28 -0000 Received: (qmail 29722 invoked by uid 500); 27 Mar 2008 16:05:23 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 29654 invoked by uid 500); 27 Mar 2008 16:05:23 -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 29645 invoked by uid 99); 27 Mar 2008 16:05:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Mar 2008 09:05:23 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [69.64.172.34] (HELO imap.meltmedia.com) (69.64.172.34) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Mar 2008 16:04:32 +0000 Received: from [192.168.1.4] (smtp.meltmedia.com [69.64.172.37]) by imap.meltmedia.com (Postfix) with ESMTP id 4158916F570 for ; Thu, 27 Mar 2008 09:04:46 -0700 (MST) Message-Id: <272DC0BB-B492-4469-B913-08B192E16C39@meltmedia.com> From: Christian T Trimble To: "Jakarta Commons Users List" In-Reply-To: <9E24FE73B6CFAC4592582CA1A18643DC1D35F9@OAEXCH2SERVER.oa.oclc.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: [Digester] Can digester match an unknown element? Date: Thu, 27 Mar 2008 09:04:42 -0700 References: <9E24FE73B6CFAC4592582CA1A18643DC1D35F9@OAEXCH2SERVER.oa.oclc.org> X-Mailer: Apple Mail (2.919.2) X-meltmedia-MailScanner-Information: Please contact your provider for further information X-meltmedia-MailScanner: Found to be clean X-meltmedia-MailScanner-From: christian@meltmedia.com X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No On Mar 27, 2008, at 2:29 AM, Allen,Eva wrote: > We are working with an entity which sometimes adds new xml elements > without remembering to tell us about them. We would like to be able > to > log a warning whenever we encounter an element that we don't know > about. > > Is there any way to do this with digester? > > Specifically, we have really simple xml files that in essence, look > like > > this: > > acceptedValue1< /good> > acceptedValue2 > rejectedValue1< /bad> > . > . > . > > > and the digester rules file looks like this: > > > do some stuff > > do more stuff > > > do even more stuff > > > > > All of a sudden one day, we got an "xmlrecord" with an "unworthy" > element (names have been changed here to protect the innocent). We > would have liked to log a warning that we didn't know what to do > with an > > unworthy element, but I can find no way to tell digester how to parse > that. I've tried patterns "xmlrecord/*" and "*/*" but neither one of > those works. I've looked at the digester documentation including the > wiki page. Everybody talks about generalized pattern matching but > nobody talks about unknown elements. Is there any way to do this with > digester? > > > -- > Eva Allen > Consulting Software Engineer, OCLC, Inc. > 6565 Kilgour Pl., Dublin, OH 43017 > 614.764.6009 | allene@oclc.org > Views contained herein are my own; they do not necessarily reflect > those > > of my employer > > > --------------------------------------------------------------------- > 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 > Eva, I am not sure how to do this with the xml based rules configuration, but you can create a default rule using the digester directly. To do this, you need to replace the Rules instance on your digester with a WithDefaultRulesWrapper and set the default rule to do your logging. Something like: Digester digester = new Digester(); // Configure your rules. ... WithDefaultRulesWrapper defaultRules = new WithDefaultRulesWrapper(digester.getRules()); defaultRules.add(new LogUnknownElementRule()); digester.setRules(defaultRules); Now, the LogUnknownElementRule will be called when an element does not match any of the rules in your rules configuration. --Christian Trimble --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org