commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zsolt Koppany" <zkoppanyl...@intland.com>
Subject AW: How to parse this configuration?
Date Tue, 15 Mar 2005 13:05:27 GMT
Thank you Oliver,

I investigated several hours until I found out that it doesn't work with 1.0
final but 1.1-RC2.

Zsolt

> -----Ursprüngliche Nachricht-----
> Von: Oliver Heger [mailto:hegero@med.uni-marburg.de]
> Gesendet: Dienstag, 15. März 2005 07:56
> An: Jakarta Commons Users List
> Betreff: Re: How to parse this configuration?
> 
> The following code should solve your problem (not really tested):
> 
> String desc;
> int idx = 0;
> 
> do {
>    desc = config.getString("file.group(" + idx + ")[@description]");
>    if(desc != null) {
>      String ext = config.getString("file.group(" + idx +
> ")[@extensions]");
>      ...
>      idx++;
>    }  // if
> }while(desc != null);
> 
> Basically you use keys of the form
> file.group(<index>)[@<attributeName>]
> where index is a numeric index starting from 0. If you reach the end of
> the list, null will be returned.
> 
> Note: I don't know if <file> is the top level element of your XML file.
> If this is the case, you must strip the file prefix from your keys
> (because the top level element's name is not evaluated), your keys then
> may look like
> group(0)[@description]
> 
> HTH
> Oliver
> 
> Zsolt Koppany wrote:
> > Hi,
> >
> > how can I parse the following configuration?
> >
> > <file>
> > 	<group description="Web" extensions="asp,aspx,phtml,shtml,php"
> > 		parser="-" type="w"/>
> >
> >       <group description="XML" extensions="xml,tld" parser="-"
> type="x"/>
> > </file>
> >
> > My code is:
> >
> > 	XMLConfiguration config = new XMLConfiguration(configFile);
> >
> > I would like to get the "file.group" tags as a list or as an array but I
> > need the corresponding "description", "parser" etc.
> >
> > I had no success with config.getList().
> >
> > I use common-configuration-1.0 with jdk-1.4.2-07
> >
> > Zsolt
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> 
> 
> --
> Dipl.-Inform. Oliver Heger
> Zentrale Informationsverarbeitung (ZIV) / Bereich Anwenderverfahren
> Klinikum der Philipps-Universität Marburg
> Baldingerstraße,
> D-35037 Marburg
> Tel: +49 6421 28-66923
> mailto:oliver.heger@med.uni-marburg.de
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message