Hook

From Friend2Friend Wiki

Jump to: navigation, search

Hooks are the only resource apart from scripts that apply both clientside and serverside. Like services and displays, they are XSL-based, but they are more perform a different, more extensible function.

Contents

Hooks as Opposed to Services/Displays

While services are general subroutines, which may have any arguments (e.g. Hello World), hooks are functions of their non-empty XML contens. Services or displays are always implemented by the same XSL transform, provided by the module which defines them. Hooks, on the other hand, may use different XSL transforms for different data items; the processing is chosen according to the namespace of the XML elements processed.

Handlers

Soft-system compilation builds a list of alternative transforms, called handlers, that may apply to the contents of a <f2f:hookreq'>. If the namespace of an element has a handler, then this XSL is used. If there is no specific handler, a wildcard XSL transform applies.

This permits modules to define how their own data should be processed. For example, by declaring a handler for the "http://friend2friend.net/modules/icon/hooks/get" icon, modules can define how their datatypes should be displayed. This may be as simple as picking a static SVG image according to the element, but could also be more complex.

Core Hooks

As well as custom hooks, some hooks are provided by F2F core:

References

Personal tools