James,

> > No. There is a difference between iterating over a set and
> > being called as a method on each object in turn. Each object
> > may have it's own method, like the javascript function attached to
> > each Element node, as in my case.
>
> But this is an implementation detail of your model.

Well, I would instead say it's a different model, that happens to suits my
needs and ease my implementation.

> Then the global XPath function foo() could iterate over the nodeset of
> /some/thing and call the foo() method on each Element node and return a
> result set.
>
> If you're Element.foo() method took parameters then these could follow in
> the global foo() XPath function. e.g.

I believe you're right in that it could be handled by using global xpath
functions, in the manner you describe, each doing the job of iterating and
generating a new node set. Instead I think it is more natural to think of
each function mapping from an object to a set of others, and the xpath
machinery performing the iteration (which is what xpath location paths and
steps are about). I don't really see the problem of allowing a more natural
syntax (which I believe is part of XPath 2.0), complementing the node set
oriented functions that are already supported.

> So I think you can do exactly what you want - its just that you need to
> create a global XPath function to call the instance method on the Element.
> Indeed you could just write a generic XPath function and NamespaceContext
> that attempts to use reflection to call all available methods on your
> Element class automatically, so you only need to write one XPath function
if
> you see what I mean.

Well, that's in a nutshell what I have done, but in a way that IMO maps
better to object-orientation in general and javascript in particular.

> Does that help?

I think we understand each other and that we disagree, that's all :-)

> we could use this technique to allow arbitrary java method calls on
objects
> while maintaining XPath syntax.

We should let the java method signature decide if the it should be called
once for the whole node set or once for each node in the set. E.g. a
function call like foo(a/b, 1) would call a method
public static List foo(List, int) once for the whole set, while it would
call a method
public Object foo(int) once for each node in the set and collect the
results.

For me it is less of a point to disallow the function step syntax, though,
so the choice would be left to the xpath programmer/user.

Hallvard


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to