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 <p:xslt> step.

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

Caveats:

Share and enjoy.

There are no comments on this essay.
Comments on this essay are closed. Thank you, spammers.
  翻译: