"first-class" XPath functions

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

"first-class" XPath functions

gdub
Good evening-

I am not clear on how to write XPath functions
(in Java, not in XSLT) that depend on the dynamic
context in Saxon. I have successfully implemented
a number of node-related functions that are specific
to my app but because the context node has to be
passed in, the expressions end up looking like:

my:a(my:b(my:c(.,'data')/expr[3],'more','data'),12)


rather than the more readable:

./my:c('data')/expr[3]/my:b('more','data')/my:a(12)


Does Saxon 8.x support passing the dynamic context
into a user function? I know that the saxon: exten-
sion functions must have that capability but are
there hooks in userland? If so, is there an example
somewhere on the list archive or elsewhere?

It would be great if it could be done in 8.1.1 since
I'm using XmlBeans but I can partition into multiple
deployment units if I have to.

TIA-

   -dub



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: "first-class" XPath functions

Michael Kay
>
> Good evening-

Good morning.
>
> I am not clear on how to write XPath functions
> (in Java, not in XSLT) that depend on the dynamic
> context in Saxon.

Declare an additional first argument of type XPathContext. This argument
will be supplied automatically by Saxon, it doesn't need to be supplied by
the caller. See the code in net.sf.saxon.functions.Extensions for examples.
The mechanism is documented in

http://www.saxonica.com/documentation/extensibility/functions/instance-metho
ds.html

Michael Kay
http://www.saxonica.com/




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help