Phase Two: Writing Out the CSS

Again there are multiple approaches to finding all of the CSS elements and writing out the stylesheets. It is important that all of the styles are written, even if they are inside templates that were not matched, as they might be styles for dynamically generated content. However, because a stylesheet can be compiled, saved in compiled form, and executed at a later time, we cannot write a Java extension that saves all of the css:rule and css:media at compile-time in a singleton object that can then be returned by a css:stream instruction.

Currently, extraction of CSS styles is done with XSLT, and does not work with dynamic import or package selection. So far this has not been a problem in practice, and ongoing experiments with package conventions may in time provide a solution.

An approach using a template in each separate file or package that matches css:gather elements and then calls xsl:next-match seems very promising.