6.2. Extensions: User defined XSLT functions

There are tons of reasons why you might want to write your own XSLT functions that can be used in Paperboy. Maybe you are working with a weird format and a new function would help you extract information easier. Perhaps you want to process information with fewer steps used by the XSLT stylesheet. Whatever the reason, being able to create extension XSLT processing modules can come in very helpful. The basic theory behind adding user defined XSLT functions is that you will compile your extension into a shared object library, and then use the -x flag to load it into paperboy. Before you can use the functions in your template, you must register the namespace and set extension-element-prefixes.

For a good example on how to do all of this tutorial3.xsl/.c is an excellent tutorial that explains this very easily. The paperboy-modules manual page is also a good resource.

When you write your code, be sure to include the register_user_xslt_functions() function (named exactly that way), which accepts the argc, argv, and env arguments that get passed to main(); these arguments are provided if necessary for more complex development, though most extensions won't need them. For more complex documentation, seek out libxslt API documentation from http://www.xmlsoft.org

You will need to compile your code as a shared object library (usually a *.so file). How to do this varies from system to system (and compiler to compiler). If you're using gcc, you will probably want a flag like -shared, -dynamic, or -dynamiclib. These flags may require further flags like -fPIC or -fpic.

This section is still incomplete... If you would like to help complete it, drop us a line on our mailing list