Stylesheet support in XSLT for DITA specializations can be applied using the same principles as for the DTDs or Schemas, resulting in stylesheets that are easy to maintain and that will support any subsequent specialization with a minimum of effort.
A specialization-aware template for XSLT has this form of match pattern:
<xsl:template match="*[contains(@class,' topic/section ')]"> <div> <xsl:apply-templates/> </div> </xsl:template>
The XSLT match statement that associates the style to the element does not use a literal match to the element name. Instead, based on an element having the defaulted value class="- topic/section reference/refsyn " (for example) this rule will trigger on the " topic/section " value (note the required space delimiters in the match string) and perform the associated template actions, regardless of what the actual element name is.
The XPath pattern in this example effectively reads, "Selects any element whose class attribute contains the space-delimited substring "topic/section"."
XSLT pattern matching is the basis for DITA's specialization-aware processing. As such, the base XSLT stylesheet for a DITA topic should minimally support any specialization, no matter how far removed in generations from the archetype topic.
To support a newly-specialized DITA DTD or Schema that has been specialization-enabled with unique class attribute values, create a module that will contain ONLY the templates required for the uniquely new elements in the specialization. This is similar to the mod files that declare the unique elements in the specialization. The name of this module should be the same as the root name for the specialization module. In the case of DITA's reference DTD, the element declarations are in reference.mod and the corresponding delta rules for XSLT are in reference.xsl.
Next, create an "override"XSLT stylesheet that starts off with the xsl:import instruction, naming the XSLT file used by this specialization's parent DTD. This import picks up support for all elements that are common with the parent DTD. Then add another xsl:import instruction in sequence, naming the XSLT delta module that you created previously. Additionally you can add imports for any domain-specific templates that need to be applied with this shell. Then copy in the XSLT templates for any previously defined support that needs to be associated uniquely to the new element names, and rename the match pattern strings as needed to the new specialized values for each new element. These added XSLT templates are deltas for the new stylesheet, much as specialized DTDs build on previous DTDs by adding delta element definitions. For XSLT support, you only need to define templates if you need new behavior or if you need to modify the behavior of an ancestor element's processing.
Because this process reuses a great deal of previous behaviors, the time spent supporting the delta changes is minimal.
To use a specialization-enabled XSLT stylesheet with a specialized DITA topic, simply associate it to the topic using either the W3C defined stylesheet link processing instruction or by following configuration rules for your processing tools (usually an XSLT processing utility such as saxon or xsltproc).
OASIS DITA Architectural Specification v1.0 -- 09 May 2005
Copyright (c) OASIS Open 2005. All Rights Reserved.