Phase One: De-cluttering the Output

The first of these two phases can happen in one of there ways:

  1. By pre-processing the stylesheet to make a copy without any css:rule r other CSS Within elements that would cause problems;

  2. By post-processing the generated HTML to remove the css:rule elements that were spuriously generated;

  3. By modifying the XSLT processor so that it ignores the content of css:rule elements.

The first option is easily done using fn:transform() and wrapper XSLT, although care must be taken to pass on any stylesheet parameters. However, it is not possible in general, because of stylesheet imports that might be conditional (depending on use-when expressions or XSLT 3 shadow attributes, for example), and because package import resolution happens dynamically.

The second option can however be done with fn:transform(), since the output documents generated by any xsl:result-document elements in the transform are not written out but are included in the map returned by fn:transform() and can be post-processed.

The author of this paper wrote both XSLT for option (2) and also a Java class that implements XSLT extension elements for Saxon which make css:rule and css:media simply return the empty sequence when the stylesheet is executed.