Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 93302 invoked from network); 25 Sep 2003 20:17:58 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 25 Sep 2003 20:17:58 -0000 Received: (qmail 40112 invoked by uid 500); 25 Sep 2003 20:17:42 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 40087 invoked by uid 500); 25 Sep 2003 20:17:41 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 40074 invoked from network); 25 Sep 2003 20:17:41 -0000 Received: from unknown (HELO smtp-out4.blueyonder.co.uk) (195.188.213.7) by daedalus.apache.org with SMTP; 25 Sep 2003 20:17:41 -0000 Received: from localhost ([82.38.66.131]) by smtp-out4.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5600); Thu, 25 Sep 2003 21:17:46 +0100 Date: Thu, 25 Sep 2003 21:20:02 +0100 Subject: Re: [digester] Rule for processing instruction? Content-Type: text/plain; charset=ISO-8859-2; format=flowed Mime-Version: 1.0 (Apple Message framework v482) From: robert burrell donkin To: "Jakarta Commons Users List" Content-Transfer-Encoding: quoted-printable In-Reply-To: <1064488253.2808.70.camel@localhost.localdomain> Message-Id: X-Mailer: Apple Mail (2.482) X-OriginalArrivalTime: 25 Sep 2003 20:17:46.0180 (UTC) FILETIME=[154CC840:01C383A2] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hi janek i don't see any reason why we shouldn't put something to allow access to=20= processing instructions into digester. this probably means storing the=20= indexed processing instruction (just as your example code does). = probably=20 worth giving a getting for the keys as well as a per-instruction getter.=20= rules would be able to access these properties during their execution by=20= calling the properties on digester. 1. can anyone see any issues with this approach? 2. can anyone think of anything i've forgotten? - robert On Thursday, September 25, 2003, at 12:10 PM, Janek Bogucki wrote: > On Wed, 2003-09-24 at 15:25, Norbert Pabi=B6 wrote: >> Uda=B3o Ci si=EA znale=BC=E6 regu=B3e na processing instruction? >> >> >> -- >> Norbert Pabi=B6 >> >> > > AFAIK there is no rule set for using PIs when building the data. If = you > are happy to obtain the PIs after the parse you could adapt this class > which collects PIs into a Map. Create an instance of this class and = use > it as a normal Digester: > > Digester d =3D new PIDigester () ; > > // set-up > > d.parse () ; > > String myPIvalue =3D (PIDigester)d.getProcessingIntruction ( target = ) ; > > -Janek > > /* > * PIDigester.java > * > * Created on 18 March 2003, 14:34 > */ > > package com.studylink.data.load; > > import java.util.HashMap ; > import java.util.Map ; > > import org.xml.sax.SAXException ; > > import org.apache.commons.digester.Digester ; > > import com.studylink.utility.StringUtilities ; > > /** > * A subclass of org.apache.commons.digester.Digester to collect > processing > * instructions and provide access to these instructions after the > parse. > * > * @author Janek Bogucki > * @version $Id: PIDigester.java,v 1.1 2003/03/18 15:41:00 jdb Exp $ > */ > public class PIDigester extends Digester { > > /** > * Creates new PIDigester > */ > public PIDigester () { > super () ; > } > > > private Map processingInstructions =3D new HashMap () ; > > public String getProcessingIntruction ( String piTarget ) { > > StringUtilities.validateNonZeroLength ( piTarget ) ; > > return ( String ) processingInstructions.get ( piTarget ) ; > } > > /** > * @throws SAXException if the target has already been encountered > */ > public void processingInstruction ( String target, String data) > throws SAXException { > > /* logging */ > super.processingInstruction ( target, data ) ; > > if ( getProcessingIntruction ( target ) !=3D null ) > throw new SAXException ( "target already encountered: " + > target ) ; > > processingInstructions.put ( target, data ) ; > } > > > } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org