[libxml-devel] Why XML::Node::Set?

Dan Janowski danj at 3skel.com
Mon Jul 14 08:32:23 EDT 2008


I did this for compatibility. Set is clearly just a pass through to  
Object. I cannot recall if there is something that expects identity in  
is_a?.

Dan


On Jul 13, 2008, at 22:09, Charlie Savage wrote:
> Looking through the xpath code, there is a class XML::Node::Set that  
> seems fairly pointless. It duplicates the functionality already  
> provided in the XPath::Object class.
>
> nodes = document.find('/header')
> nodes.class == XPath::Object
> nodes.first
> nodes.length
> nodes.each do |node|
> ..
> end
>
> And then...
>
> node_set = nodes.set
> node_set.class == XML::Node::Set
> node.first
> node.length
> node.each do |node|
> ..
> end
>
>
> Seems better to re-purpose the XML::Node::Set to be used to return a  
> node set when a user calls node.children (which now returns a node,  
> which is fairly weird, although that is how libxml works).
>
> If that doesn't make sense, then it should just be removed.  
> XPath::Object#set could just return itself, calling code would be  
> none the wiser since the API's are identical.
>
> Charlie
>
> _______________________________________________
> libxml-devel mailing list
> libxml-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/libxml-devel



More information about the libxml-devel mailing list