API for XPath 1.0

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

API for XPath 1.0

Erik Bruchez-2
All,

Is there a way, with the Saxon XPath API, to force the use of XPath 1.0?
In particular, I would like in XPath 1.0 mode to implement the XForms
if() functions, which in XPath 2.0 clearly interferes with XPath 2.0's
if() construct.

-Erik


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: API for XPath 1.0

Michael Kay
>
> Is there a way, with the Saxon XPath API, to force the use of
> XPath 1.0?

You presumably mean with the Saxon 8.x product. Sorry, the answer is no. It
could obviously be done as an enhancement, but it's a non-trivial amount of
work, especially if you want all the corner cases to be right (such as
re-allowing a<b<c, which XPath 2.0 has dropped)

> In particular, I would like in XPath 1.0 mode to implement the XForms
> if() functions, which in XPath 2.0 clearly interferes with
> XPath 2.0's
> if() construct.

This reminded me to take a look at the way XForms has extended XPath. It's a
shame they put these functions in the same namespace as the core XPath
functions - that's going to create difficulties when XForms moves forwards
to XPath 2.0. (It also creates difficulties because Saxon doesn't provide
any mechanism for adding functions to the core namespace.)

I think the answer here is that there's development work needed.

Michael Kay
Saxonica




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: API for XPath 1.0

Erik Bruchez-2
Michael Kay wrote:
>>Is there a way, with the Saxon XPath API, to force the use of
>>XPath 1.0?
>
> You presumably mean with the Saxon 8.x product. Sorry, the answer is no. It
> could obviously be done as an enhancement, but it's a non-trivial amount of
> work, especially if you want all the corner cases to be right (such as
> re-allowing a<b<c, which XPath 2.0 has dropped)

>>In particular, I would like in XPath 1.0 mode to implement the XForms
>>if() functions, which in XPath 2.0 clearly interferes with
>>XPath 2.0's
>>if() construct.
>
>
> This reminded me to take a look at the way XForms has extended XPath. It's a
> shame they put these functions in the same namespace as the core XPath
> functions - that's going to create difficulties when XForms moves forwards
> to XPath 2.0. (It also creates difficulties because Saxon doesn't provide
> any mechanism for adding functions to the core namespace.)

I wholeheartedly agree: that was a mistake, and the choice of if() in
particular was unfortunate.

> I think the answer here is that there's development work needed.

Does Saxon 6 have an XPath 1.0 API which could be used instead? Given
that the two processors can coexist, one or the other XPath
implementation could be chosen by our XForms engine (with 2.0 as an
extension).

-Erik


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: API for XPath 1.0

Michael Kay
> Does Saxon 6 have an XPath 1.0 API which could be used instead?

Yes, it does, though it's a bit "internal".

It's roughly like this:

    Expression exp = Expression.make(path, new StandaloneContext(namePool));
    Context c = controller.makeContext(doc);
    NodeEnumeration enm = exp.enumerate(c, false);
    while (enm.hasMoreElements()) {
        NodeInfo n = enm.nextElement();
        ....
    }

Michael Kay




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help