Hi Hallvard, > > I'm just wondering why you think that a custom location step is requried. > > e.g. your example could be reworked a little as follows... > > > > ext:related-thing(thing)[@color='red'] > > When designing the XML structure you have to anticipate the navigation > pattern, to ensure that everything interesting is underneath in the > hierarchy. This is often not feasible, so I find it useful to have custom > functions for jumping across the XML tree.
I wholeheartedly agree. > Requiring that the function be > the first step is limiting, i.e. cannot be used for just navigating along > an idref and nothing more. So the same function with the same arguments could evaluate to different things in different contexts? > In my particular application, I combine XML and javascripting, so the > custom function can be written in javascript and embedded in the file. Wow! > > Or further location steps can be appended as needed such as > > > > ext:related-thing(thing)[@color='red']/foo/bar > > > > Without having to change the XPath grammar etc. Would that do what you > > need? > > For a specific purpose this is usually possible, but when all navigation > patterns are taken together, it's not always possible to design a tree > where navigation is always downward. Hence, there is a need for custom > "jumps" in the XML tree. In some application, the speed may also improved > this way. Yes, and the question is: Do you really care where you jump from? To me, your idea sounds like invoking a method on an object, whereas the traditional functions are more like stand-alone functions in a programming language. The alternative to a method invocation is to pass the "this" object in an argument (see the Perl and the Python programming languages). So instead of / path / to / somewhere / ext:and-now-something-completely-different( 'zz' ) / here-we-stand You could write ext:and-now-something-completely-different-II( / path / to / somewhere, 'zz' ) / here-we-stand Provided that the /path/to/somewhere is needed for evaluating the function in the first place. > BTW, isn't this part of XPath 2.0, for these purposes? Will have to re-read that spec a few times, I confess. > Hallvard Jan _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest