Hi Jan

I agree - I think the custom location step idea is just a way of reordering
an XPath statement as you say from

/ 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


Indeed the latter notation is more flexible as it can take an arbitrary
number of different expressions as parameters, each of which could combine
location paths and functions etc.

Does the custom location step offer any other benefits other than reordering
of the XPath expression?

BTW the XML & JavaScript & XPath calling the JavaScript stuff sounds cool
;-)

James
----- Original Message -----
From: "Jan Dvorak" <[EMAIL PROTECTED]>
To: "Hallvard Trćtteberg" <[EMAIL PROTECTED]>; "James Strachan"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, April 19, 2002 9:04 AM
Subject: Re: [Jaxen] Custom location step functions


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



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to