I can answer that myself - yes it is in HE and it looks great! I like the improved security it offers over reflexive functions which always concerned me.

I got a basic demo going pretty easily, however now I have 2 questions.

1) Can I register a function that uses no namespace? I tried both "" and null as in the function def but neither worked, whereas if I added a namespace it does work. I need to support xforms functions which have no namespace as I understand it.

2) What Value subclass should you use for a long type? I got it working using Double but could not find anything that in that hierarchy bound explicitly to long.

I have pasted my demo class below (adapted from IsWholeNumber in saxon) and will now deal with build issues etc. to start the upgrade. Thanks for the pointer to this great new feature!!

public class Now extends ExtensionFunctionDefinition {

    private static final StructuredQName qName = new StructuredQName("", "", "now");
    public StructuredQName getFunctionQName() {
        return qName;
    public int getMinimumNumberOfArguments() {
        return 0;
    public int getMaximumNumberOfArguments() {
        return 0;
    public SequenceType[] getArgumentTypes() {
        return new SequenceType[]{};
    public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
        return SequenceType.SINGLE_DOUBLE;
    public ExtensionFunctionCall makeCallExpression() {
        return new NowCall();
    public Object getCompilerForJava() {
        return null;

    private static class NowCall extends ExtensionFunctionCall {
        public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
            return SingletonIterator.makeIterator(new DoubleValue(new Date().getTime()));

On Fri, Apr 30, 2010 at 5:35 PM, Rob Brown <rlb.south@gmail.com> wrote:
Sounds promising - is that available in the HE edition?

On Fri, Apr 30, 2010 at 4:45 PM, Michael Kay <mike@saxonica.com> wrote:
Let's try to answer your question "is there another way to do this?", and ignore the curious problem of the Xalan xpath class in which the failure occurred.
The new "integrated extension function" mechanism in 9.2 is ideally suited to this kind of situation. It gives you much better capability to design extension functions that look exactly like built-in functions as far as the stylesheet/query/xpath author is concerned.
With 9.1 you could do this by writing your own extension function binder, but this would be far more complicated.

From: Rob Brown [mailto:rlb.south@gmail.com]
Sent: 30 April 2010 19:50
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Alternative to java extension functions?


I'm hoping there is another design idea I can use for this problem. I have to implement xpath functions that map to various xforms functions for our users. My solution was to use java extension functions and do some mapping between my own java namespace and what the users see (i.e. the users see xforms functions but I map these before evaluation to my own java namespace).

The main problem is that I cannot change the function signature. This means I cannot use java extension functions that access instance methods (which require an extra parameter) and I have to use an awful hack that uses static methods. Basically I store an instance of my value resolver in a synchronized static field and map static java extension functions to this object. Ugly, but at least it worked until now.

Now I find this is failing when I try to run the app in Amazon's cloud environment. Somewhere inside jaxp classes as called by saxon (com.sun.org.apache.xpath.internal.functions.FuncExtFunction.execute(FuncExtFunction.java:206)) I'm getting a NullPointerException. Just to be clear, this app runs fine outside of the virtualized Amazon environment. I suspect the root cause is how jaxp classes are being loaded because I've seen that happen with jaxp in other VPS enviornments.

Whatever the cause, I'm hoping that if I redesign this hack I can clean up my code and hopefully make this bug disappear.

Is there another design alternative to implementing xforms (or similar) functions in xpath? I'm ok using s9 exclusively if that will help - jaxp causes me nothing but trouble so I'm ready to toss it out the window anyway. The function signatures (now(), index(), instance(), etc.) cannot be changed, require object instances to resolve, and I need to evaluate them within xpath alone (i.e. not within xslt or xquery).

I hope there is an answer because it looks like we can't host our application in Amazon if this doesn't get resolved.



saxon-help mailing list archived at http://saxon.markmail.org/