XSL Template - reducing replication
- by Chris
Hey
Sorry about the extremely vague question title (any suggestions for improvements welcome)
I have an XSL document that, currently, has lots of replication that I want to reduce.
Here is the following XML snippet I am working with
<Unit Status="alive">
I am currently using the following XSL to show images based on the status of the Unit
<xsl:choose>
<xsl:when test="@Status = 'alive'">
<img src="/web/resources/graphics/accept.png" />
</xsl:when>
<xsl:when test="@Status = 'missingUnit'">
<img src="/web/resources/graphics/error.png" />
</xsl:when>
<xsl:when test="@Status = 'missingNode'">
<img src="/web/resources/graphics/exclamation.png" />
</xsl:when>
<xsl:when test="@Status = 'unexpectedUnit'">
<img src="/web/resources/graphics/exclamation_blue.png" />
</xsl:when>
<xsl:otherwise>
<!-- Should never get here -->
<img src="/web/resources/graphics/delete.png" />
</xsl:otherwise>
</xsl:choose>
How do I put this code in a template or stylesheet that will allow me to stop copying / pasting this everywhere.
Thanks