Re: Managing XSLTS for XSLFO - Shared templates and a
I have a number of XSLTs for our clients that produce XSL FO. Right now, I make extensive use of attribute sets. I basically setup all my attribute sets at the start of the file and call them as I need them. This works great, just as long as you don't want to share templates. Unfortunately, I am going to need to share some of those templates in the future, but the attributes used may be different (obviously, these attributes are defining styling).
Have a stylesheet fragment defining common sets and common behaviours, then have different stylesheet fragments for each distinct environment import the common fragment. Each environment will then have their own distinct amalgam of their specific styles and the common styles.
To see an example of this, there is a free stylesheet library in the developer resources section of our web site (linked below) for presenting instances of the Universal Business Language (UBL) to both HTML and PDF. This library illustrates the importation of common fragments, including a common fragment between both HTML and XSL-FO stylesheets implementing the access to the UBL instances. This common bit is at the bottom of each import hierarchy. A number of the stylesheet fragments in this library are synthesized using another resource we make available that is a stylesheet that writes stylesheets ... so designed precisely to allow different environments to import common behaviours.
It happens that those import trees in my UBL example don't take advantage of <xsl:attribute-set>, but they do show what happens with the overriding of template rules and mode matches.
Note a difference between the importation of attribute sets and other named top-level constructs is that an importing attribute set doesn't supplant the imported attribute set, it augments the imported attribute set. For other named top-level constructs the importing construct supplants the imported construct. Because of this distinction, it is not possible through importation to prevent an attribute from an imported attribute set to be processed, thus, to "undo" a property such as font-weight="bold" it would be necessary to say font-weight="normal".
I hope this helps.
. . . . . . . . . . . . . Ken
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format