[xsl] structuring for multiple output formats

Subject: [xsl] structuring for multiple output formats
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Sat, 25 Sep 2004 15:05:11 -0400
Since I'm closer to getting what I'm working on into suitable shape for distributing more widely, I'm now back to rethinking how to structure the files.

Currently, I only have one set of input formats (docbook-ng/mods), and one output format (xhtml).

However, I want what I've done to be easily extensible to other formats. I think the input format issue is pretty easy: I have a directory called "drivers" that contains files like "document-driver-db.xsl".

Possible future export options are latex, openoffice, tei, fo, and maybe wordml.

Currently, I have a structure like this (directories in brackets):

[doc]
[styles]
mla.cls
apa.cls
...
[xsl]
[core]
format-style.xsl
functions.xsl
core.xsl (includes files from the core directory)
[drivers]
drivers.xsl (includes files from the drivers directory)
[xhtml]
dbng.xsl (main document xsl, which includes xbiblio.xsl)
[render-classes]
[author-year]
biblio-out.xsl
citation-out.xsl
render.xsl (includes two above)
[key]
[footnote]
[number]
render-mods.xsl (generic renderer)
render-class.xsl (includes contents of render-classes directory)
xbiblio.xsl (main xsl file, which includes other .xsl files above, and reads content of style file)


The advantage of this is that everything is pretty well-modularized.

If I need a new output format, though, it means adding a new subdirectory to the xsl directory, and then adding a bunch of further subdirectories and files (this is the approach with the standards docbook stylesheets).

Does this make sense, or is their a better way to think of dealing with handling the different output formats?

Some of the templates -- in for example the render-mods.xsl files) -- are output-agnostic, though I do have a lot of templates that look like:

<xsl:template match="mods:titleInfo[not(@type='abbreviated')]"
	      mode="full">
  <xsl:param name="prefix"/>
  <xsl:param name="suffix"/>
  <xsl:param name="font-style"/>
  <xsl:param name="font-weight"/>
  <xsl:value-of select="$prefix"/>
  <span class="title {$font-style} {$font-weight}">
    <xsl:apply-templates select="mods:title"/>
    <xsl:apply-templates select="mods:subTitle"/>
  </span>
  <xsl:value-of select="$suffix"/>
</xsl:template>

Bruce

Current Thread