[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Late requirement for uniform wrapping of differently generated elements

Subject: [xsl] Late requirement for uniform wrapping of differently generated elements
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Sat, 11 Feb 2012 16:22:47 +0100

My XSLT generates a HTML document containing (almost) nothing except
<h*> and <table>. I wrote it as a template reflecting the <html>
structure, with called templates pulling in the data from the XML
source. It is within these called templates that the various <table>
elements (of differing structure) are generated.

An new requirement demands that all the various <table> elements are
to be wrapped with another <table> (with a single <tr>) for layout
purposes, adding one <td> with uniform contents to the <td> containing
the original table.

I cannot insert two different template calls producing the outer
table's introduction and completion, respectively: they each would
contain unbalanced data.

I know it can be done by adding the new HTML stuff to all the called
templates, which isn't nice as it duplicates code, in many different

If I had realized this new requirement earlier - would there be a good
solution while still retaining the "pull" structure? How do I handle
the generation of different tables from within a single "wrapper"
table template? One big <choose> driven by a parameter seems to be the
only option. (Something like a "function reference" for callable
templates would enable me to write what I'd consider a "clean" program

I wouldn't be surprised if there is there anything I've overlooked.


Current Thread