At 2007-03-22 19:19 +0100, Thomas Zastrow wrote:
I'm not so familiar with XSL, please be patient ;-)
I think you will find people on this list very patient for those who
are eager to learn.
I have a XML-document (not HTML) with tables like this:
<table>
<tr>
<td></td><td></td>
</tr>
</table>
So, I have three templates for them:
<xsl:template match="table">
<xsl:template match="tr">
<xsl:template match="td">
Now, I want to use different kinds of tables in my XML-doc like
<table style="simple">
<table style="xyz">
Depending on the style-attribut, I can change the template-code for
<table> with xsl:choose.
I would not recommend using <xsl:choose> unless the differences are
very small and most of the template would be the same for both cases.
But, the <tr>- and <td>-tags are still the same code, so, they will
always use the same templates. But I also want to change the code
for tr and td, depending on the style of the complete table.
Is this possible or have I to write the xsl:choose - statement again
in the tr- and in the td-templates?
Without more detail of your problem, my hunch is that you would just
do something like this:
<xsl:template match="table[(_at_)style='simple']">
<xsl:template match="table[(_at_)style='xyz']">
<xsl:template match="table[(_at_)style='simple']/tr">
<xsl:template match="table[(_at_)style='xyz']/tr">
<xsl:template match="table[(_at_)style='simple']/tr/td">
<xsl:template match="table[(_at_)style='xyz']/tr/td">
In this fashion you are allowing the processor to optimize the
matching. My XSLT students who come to class with a programming
background tend to latch onto those facilities they are used to using
as programmers without realizing there are built-in facilities that
declare what they need done so that the processor can choose to do
them as best as it sees fit.
Note that in a match pattern the right-most node test identifies the
node being matched and the detail in the steps to the left qualify
the ancestry (typically) of the focus node test.
I hope this helps.
. . . . . . . . . . . . Ken
--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--