[xslt] extension modules



Hi all,

This is a proposal API to write extension modules. Please comment on so
that we can choose an API and don't modify it afterwards.
Suggestions are welcome, everything has to be discussed: is it necessary,
are there other ways to solve the problem, etc.

Also, please note these proposals do NOT bring into question the actual
extension API, they only extend it.

This version is the most complete one, the one I'd like to have. I'll send
another message for a stripped-down version not including precomputation,
and a third one for an alternative, based on the current extension API.

Each message will consist of an overview of the API followed by some issues
to be discussed.

=====

1. an extension module consists of:
   · module data
   · top-level elements
   · extension elements
   · extension functions

2. there are 2 module data structures:
   · at stylesheet level, registered at stylesheet parsing (precomputation)
     It is used to precompute some data (e.g. a list of functions
     defined by func:function elements). During the transformation, it's
     read-only (as anything in the stylesheet)
   · at transformation level, registered for each transformation
     Used to share data between the module elements and functions (e.g.
     to store a database access descriptor)

   A module registers two couples of functions, one for each data struct.
   Each couple consists of an initialization and shutdown function to
   allocate and free the data.

   Elements and functions can retrieve these data structs with a couple
   of functions: xsltStyleGetExtData and xsltGetExtData.

   If stylesheet data has been registered, transformation data is
   automatically initialized at the beginning of the transformation.
   This is used for example to register func:function functions in the
   XPath context. More generally, it's to perform some action from the
   precomputed data before any transformation has been done.

   Data initialization is done automatically by xslt{,Style}GetExtData if
   data is not yet available (you callback function calls xsltGetExtData
   for example; if data exists for the module, it is returned, otherwise
   it is first initialized by the function you provided).
   Shutdown happens at transformation end for transformation data, and
   stylesheet freeing for stylesheet data.

3. elements and functions are stored application-wide, globally.

   A top-level element is defined by its name, namespace URI and a
   callback function called at stylesheet parsing:
     void (*xsltPreComputeFunction) (xsltStylesheetPtr style,
                                     xmlNodePtr inst);

   An extension element comes with a name, namespace URI and a couple of
   functions: the first one to precompute the element
   (xsltPreComputeFunction), the second one to transform it
   (xsltTransformFunction)

   An extension function is composed of a name, namespace URI and a
   callback function (xmlXPathFunction)

   Top-level elements have access to the stylesheet data through
   xsltStyleGetExtData.
   Extension elements and functions have also access to transformation
   data through xsltGetExtData


Things to be discussed:
 · transformation data initialization is done only when needed (except if
   stylesheet data has been registered for that module).
   Does someone think it could cause problems?
 · most probably other things I've forgotten...

Tom.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]