Java Extension for Saxon

CSS Within currently includes a Java definition of XSLT extension elements for css:rule and css:media that simply return an empty sequence at compile time. When the stylesheet runs, the CSS Within elements are gone, so there is no need for a clean-up phase.

In development is an extension element for css:gather which at stylesheet compilation builds the CSS stylesheet so that when run, the css:gather element is replaced by an xsl:text element containing the text of the stylesheet. In order that the CSS fragments are collected from included and imported stylesheets and packages, apply-templates must be called in css:gather mode; the CSS Within stylesheet which can be imported contains a template that uses xsl:next-match to fetch the css:gather fragments from every other stylesheet module. Since all of this is arranged when the stylesheet is compiled, run-time support for the extension elements is not required. Each module must either include the CSS Within stylesheet, or must define a suitable css:gather template.

This css:gather implementation is then used by the public css:stream element to produce the text of the CSS stylesheet.

The complexities of configuring Saxon to run an extension, and of supporting separate compilation where the runtime engine is not necessarily in the same Java instance as the execution, or even in Java at all, mean that at the time of writing this paper the implementation is not stable enough to redistribute, but the author expects that to change.