View Single Post
  #2 (permalink)  
Old July 10th, 2007, 07:16 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Well, there seems to be more than one difference to me: one template is outputting key, apiNode, and apiImport, while the other is outputting key and display. To me, there doesn't seem to be enough commonality to justify making a single template with conditional logic. But you can always do it if you want: create a single template with four parameters and four calls on xsl:attribute, each surrounded by xsl:if:

<xsl:if test="$key != ''">
  <xsl:attribute name="key">
    <xsl:value-of select="$key"/>
  </xsl:attribute>
</xsl:if>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote