User-defined functions are a valuable extension mechanism. They allow us to modularize, reuse, and generally simplify otherwise complex expressions. Wouldn't they be nice in XProc pipelines?
What happened was, a friend of mine asked if it would be possible
to have some RDFAa-related extension functions in XProc. He'd defined them in XSLT
and devised a clever, if cumbersome, mechanism for invoking them with the
I thought, sure, I could add those as extension functions. Then I saw that they were in a private namespace and weren't general-purpose functions so much as application-specific functions. My enthusiasm for banging them out in Java and putting them in XML Calabash waned quickly.
What I thought would be really cool would be to define them in XQuery (or XSLT) and simply import them into the pipeline. Then you could make up functions at will and use them.
So that's what I did. (Special shout out to Michael Kay for pointing me through the trail of API calls necessary to make this work.)
Using this feature makes XML Calabash non-conformant and, consequently, makes your pipeline processor-dependent. Not ideal, but maybe this is a feature that can be standardized if it's popular.
It requires Saxon EE. Nothing I can do about that.
There's no scoping. All of the loaded functions go into the single
Processorobject. This means you can import them in one pipeline and use them in another which is ugly.
Share and enjoy.