Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] adding an iterator() method to nodes

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Steve Loughran" <steve.loughran AT gmail.com>
  • To: "Elliotte Harold" <elharo AT metalab.unc.edu>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] adding an iterator() method to nodes
  • Date: Tue, 31 Oct 2006 14:32:16 +0000

On 31/10/06, Elliotte Harold <elharo AT metalab.unc.edu> wrote:
Steve Loughran wrote:
> Given that Nodes is implemented by a List internally, the cost of
> adding a method to access it is pretty low:
>
> public iterator() { return nodes.iterator();}
>
> This would make it trivial to bridge over into java 5 iterators,
> instead of trying to re-implement a list iterator, which is the sole
> option today.
>
> Thoughts?
>

That either requires Java 5 or violates type-safety. And it violates the
"there's exactly one way to do it" principle.


I wasnt pushing for xom to move to j5; I dont advocate that one-way
transition unless all your users are clamouring for it. Its just I
have added some j5 support on the side, and it was more tricky than it
should be, just because the iterator() method wasnt there.

Being able to iterate over things does make working with XML easier:

for(Node n:message.xpath("muws-p2-xs:StateTransition/*", catalog)) {
SoapElement e=(SoapElement) n;
//act on the element
}
-steve




Archive powered by MHonArc 2.6.24.

Top of Page