Bug #2170

Passing down object reference to extension function not available

Added by O'Neil Delpratt over 5 years ago. Updated about 4 years ago.

s9api API
Start date:
Due date:
% Done:


Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


Bug issue initially reported by Gunther Rademacher:

Reports a migration problem between 9.5 and 9.6.

What I would like to do is pass down some object reference into an

XQueryEvaluator, and retrieve it from within an extension function used

by the query. The following worked with 9.5:

...when evaluating an XQuery:

     XQueryEvaluator evaluator = executable.load();


       new QName("data"),

       XdmValue.wrap(new ObjectValue("hello world")));

...and in an extension function used by the query:

    public Sequence call(XPathContext context, Sequence[] 

arguments) throws XPathException


      ObjectValue parameter = (ObjectValue) 


      return new StringValue((String) parameter.getObject());

With 9.6, the getParameter method has disappeared, and it is unclear to

me how to properly adapt the above code. Some debugging shows that my

external variable shows up in


We need to think of a way of providing access to the global parameters including the defaulted values. (2.66 KB) Example of workaround invoking reflection O'Neil Delpratt, 2014-10-08 17:13


#1 Updated by Michael Kay over 5 years ago

  • Status changed from New to Resolved
  • Assignee set to Michael Kay

I have added the following method to the Controller class (on the 9.6 and 9.7 branches)


 * Get the value of a supplied parameter (XSLT) or external variable (XQuery)

 * @param name the QName of the parameter

 * @return the supplied value of the parameter, if such a parameter exists, and if a value

 * was supplied. Returns null if the parameter is not declared or if no value was supplied,

 * even if there is a default defined in the stylesheet or query.


public Sequence getParameter(StructuredQName name);

#2 Updated by Michael Kay over 5 years ago

The JUnit test case is jaxptest.ExtensionTest.testParameterAccess()

#3 Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to

Bug fix applied to the maintenance release Saxon

#4 Updated by O'Neil Delpratt about 4 years ago

  • Sprint/Milestone set to
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release added

Please register to edit this issue

Also available in: Atom PDF