how do I provide a one-template solution to all elements
which have the
same requirements as caption?
For instance, there are more of these...
<xsl:template match="/album/photos/photo/description">
<tr valign="top">
<td class="label" align="right">description:</td>
<td class="caption"><xsl:value-of select="." /></td>
</tr>
</xsl:template>
<xsl:template match="/album/photos/photo/location">
<tr valign="top">
<td class="label" align="right">location:</td>
<td class="caption"><xsl:value-of select="." /></td>
</tr>
</xsl:template>
You could write
<xsl:template match="/album/photos/photo/*">
<tr valign="top">
<td class="label" align="right"><xsl:value-of
select="name()"/>:</td>
<td class="caption"><xsl:value-of select="." /></td>
</tr>
</xsl:template>
</xsl:template>
or more specifically
<xsl:template match="/album/photos/photo/description |
/album/photos/photo/location">
Do your match patterns really need to be so detailed? Are there other
contexts where "description" and "location" can appear? Because if not,
you are just wasting cycles testing the ancestory of the elements
unnecessarily, and you are also making it harder to change your
stylesheet if the schema changes.
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list