Project

Profile

Help

Overloading an ExtensionFunctionDefinition

Added by Bas Philippus almost 9 years ago

Hi,

I'm trying to overload an ExtensionFunctionDefinition to accept both a Date and a DateTime. Is this possible using the same method name?

Thanks in advance, Bas Philippus


Replies (1)

RE: Overloading an ExtensionFunctionDefinition - Added by Michael Kay almost 9 years ago

Sorry for the lack of response. We've been working hard to clear the bug list and the forums have been a bit neglected.

There are two approaches: you can define the signature to accept xs:anyAtomicType (and then do run-time type checking of what you have actually been supplied with). Or in recent releases, more ambitiously, you can create a union type in a schema and refer to this in your function signature. I have to say I haven't tried this and I don't know whether you would have to be running schema-aware for it to work.

Take a look at the source code for net.sf.saxon.type.NumericType (which defines a union of decimal, double, and float) and mimic it to create a union of date and dateTime. Then use this type in your extension function signature. Alternatively, define the union type in a schema and import it.

    (1-1/1)

    Please register to reply