Project

Profile

Help

Bug #2170

closed

Passing down object reference to extension function not available

Added by O'Neil Delpratt about 10 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
s9api API
Sprint/Milestone:
Start date:
2014-10-08
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

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();

     evaluator.setExternalVariable(

       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) 

context.getController().getParameter("data");

      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

    context.getController().getBindery().globalParameters

We need to think of a way of providing access to the global parameters including the defaulted values.


Files

ExternalVar.java (2.66 KB) ExternalVar.java Example of workaround invoking reflection O'Neil Delpratt, 2014-10-08 17:13
Actions #1

Updated by Michael Kay about 10 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);
Actions #2

Updated by Michael Kay about 10 years ago

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

Actions #3

Updated by O'Neil Delpratt about 10 years ago

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

Bug fix applied to the maintenance release Saxon 9.6.0.2

Actions #4

Updated by O'Neil Delpratt almost 9 years ago

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

Please register to edit this issue

Also available in: Atom PDF