#1 miscellaneous improvements to FunctionProxy.java


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.)

2) 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.

3) 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!

4) 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

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"

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"

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

thank you,


  • Gunther Schadow

    Gunther Schadow - 2003-06-20

    context diff patch for FunctionProxy.java

  • Michael Kay

    Michael Kay - 2003-06-20

    Logged In: YES

    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

  • Gunther Schadow

    Gunther Schadow - 2004-11-12

    Logged In: YES

    Thanks for integrating this into your code.



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks