[xsl] testing attributes

Subject: [xsl] testing attributes
From: Aaron Johnson <Aaron2.Johnson@xxxxxxxxx>
Date: Thu, 19 May 2005 10:11:56 +0100
Hi...

I have a template that matches any course element in my xml. Each
element has a different role attribute. I can output the information
from the course node, I would like to test for which attribute it is and
apply a different message template accordingly.


Is it best to have separate templates for each type of attribute, or is
there a way to check what the attribute is and output as appropriate.

<xsl:choose>
<xsl:when test="count(//course) &gt; 0">
<h2>Courses</h2>
<xsl:apply-templates select="//courses"/>
</xsl:when>
<xsl:otherwise>
<h2>You are not currently participating in any any courses</h2>
</xsl:otherwise>
</xsl:choose>

<xsl:template match="courses">
<xsl:apply-templates select="course"/>
</xsl:template>

<xsl:template match="course">
<li>
<a href="{$host}{url}amp;useCas=1" target="_blank"><xsl:value-of
select="title"/></a>
</li>
</xsl:template>

xml:

<course role="instructor">
 ....blah

Thanks for any help...

..................................................................
Aaron Johnson
GUI / XSLT development
Academic Technologies Group [ATG]
University of the West of England
ext: 81051
t: 0117 3281051
www: http://atg.uwe.ac.uk/aaron
e: aaron2.johnson@xxxxxxxxx
SECURITY POLICY:
Please note that ATG will only accept
e-mail attachments in the following
formats:
.asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png,
.psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip,
..................................................................
This communication is intended solely
for the use of the individual(s) to whom
it is addressed. Any opinions presented
are those of the author and do not
necessarily represent the University of
the West of England, Bristol.
..................................................................



This email has been independently scanned for viruses and any virus software
has been removed using McAfee anti-virus software

Current Thread