Project

Profile

Help

Patch #1421

closed

miscellaneous improvements to FunctionProxy.java

Added by Anonymous over 21 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Internals
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

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

Description

SourceForge user: gschadow

Michael, please consider the attached patch to

FunctionProxy.java. It does a number of improvements.

  1. The rendition of retrurned java nulls to empty

sequences (as discussed earlier.)

  1. Adding a debug clause in which the actual calling of a

method is announced (with the -TJ flag.) BTW: would be

nice if the TraceListener would handle these XPath

expression-level tracings too.

  1. Nesting exceptions thrown from extension functions

inside the XPathException. Previously the

XPathExceptions came without a trace as to what went

wrong inside the extension funcitons!

  1. Add support for member fields to be accessed. This is

the bulk of the patch and described in detail below.

Problem: Often a class' methods use static final fields as

enumeration values to act as modifiers to a method call.

Even though these are typically int or other values that

could be submitted without reference to the static final

field, it is unsafe to do so because these values may

change with changing (versions of) the class

implementation.

Solution: This solution treats member fields as functions

with no arguments. For example, if class oracle.sql.CLOB

has the static final int DURATION_SESSION, then this

value can be accessed through:

<xsl:sequence xmlns:clob="java:oracle.sql.CLOB"

select="clob:DURATION_SESSION()"/>

I implemented this solution in analogy to the Method

handling, and it works for both static and instance fields

as one would expect (using an argument with the object

whose field is being accessed.)

Clearly this doesn't allow assignments to fields, but such

assignments are exceedingly unneccessary since most

objects (except for some odd java.awt struct-like

objects) will have proper mutator methods.

Alternatives: As an alternative, I would have liked to

implement such static field references as variables, e.g.,

the above example would look like this:

<xsl:sequence xmlns:clob="java:oracle.sql.CLOB"

select="$clob:DURATION_SESSION"/>

however, I still don't quite understand how variables are

implemented in saxon and this wouldn't work for instance

fields anyway. In order to allow setting instance fields

one could imagine a pair of functions getf(object,string)

and setf(object,string,object), but setting instance

fields is not so important.

I'd appreciate if you could accept these patches in

principle.

thank you,

-Gunther


Files

FunctionProxy.diff (9.56 KB) FunctionProxy.diff Anonymous, 2003-06-20 05:23
Actions #1

Updated by Anonymous over 21 years ago

SourceForge user: mhkay

Logged In: YES

user_id=251681

Thanks, I've applied these changes.

I don't think I would want to attempt to bind variables this

way. The XSLT spec requires all variables to be explicitly

declared, unlike functions.

Extension functions with side-effects (including setters)

are going to become increasingly troublesome as the order of

execution in a stylesheet becomes less predictable...

Michael Kay

Actions #2

Updated by Anonymous about 20 years ago

SourceForge user: gschadow

Logged In: YES

user_id=575520

Thanks for integrating this into your code.

Please register to edit this issue

Also available in: Atom PDF