commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@t-online.de>
Subject Re: [configuration] iterating over structured XML
Date Thu, 22 Dec 2005 19:39:32 GMT
Jacob Kjome wrote:

>I'm wondering if there's a better way to iterate over structured XML?  Here's
>how I'm currently doing it...
>
>int i = 0;
>while (true)
>{
>    String subset = new
>StringBuffer(18).append("tables.table(").append(i++).append(")").toString();
>    SubsetConfiguration sc = (SubsetConfiguration) config.subset(subset);
>    if (sc.isEmpty()) break;
>
>    //do stuff with subset configuration here....
>}
>
>...which works, but it seems like I should be able to just do an iteration over
>the subconfigurations.  Maybe something like this?...
>
>for (Iterator iter = config.getList("tables.table").iterator(); iter.hasNext();)
>{
>    SubsetConfiguration sc = (SubsetConfiguration) iter.next();
>
>    //do stuff with subset configuration here....
>}
>
>However, that doesn't work because config.getList() returns a list of string
>contents of the table elements (which returns a list of size 0, since <table>
>elements are only for structure, not for text content).  That's not what I'm
>aiming for.  Isn't there a way that I can iterate over a list of subset
>configurations so I don't have to resort to generating a dynamic key?  This
>would make my code more clean.  I hope I'm just missing something.
>
>thanks,
>
>Jake
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>
I'm sorry, but there is no integrated, elegant way of iterating over
structured properties ATM. This is something I was already thinking
about, but have not come to a conclusion yet. I am sure this is an often
needed use case.

Maybe something in the line of a functor? I am open to any suggestions...

Oliver

---------------------------------------------------------------------
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