<?xml version=
"1.0"
?>
<!-- Generate a list of epsisodes for one season.
parameters:
"seasonid" the season we're going to process
"source" the source of the synopsis -->
<xsl:stylesheet
version="
1.0
"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform
"
>
<xsl:output
encoding="
ISO-8859-1
"
method="
html
"
/>
<!-- generate the main framework for the page -->
<xsl:template
match="
/series
"
>
<html
>
<head
>
<title
>
<xsl:value-of
select="
title
"
/>
,
Season <xsl:value-of
select="
$seasonid
"
/>
</title>
<link
href="
series.css
"
rel="
stylesheet
"
/>
</head>
<body
>
<h1
align="
center
"
>
<xsl:value-of
select="
title
"
/>
,
Season <xsl:value-of
select="
$seasonid
"
/>
</h1>
<hr
/>
<!-- generate a quick link list to each episode -->
<table
width="
100%
"
>
<tr
>
<xsl:for-each
select="
episodes/season[@id=$seasonid]/episode
"
>
<td
align="
center
"
>
<a
href="
#{@id}
"
>
<xsl:value-of
select="
@id
"
/>
</a>
</td>
</xsl:for-each>
</tr>
</table>
<hr
/>
<!-- process all episodes for the requested season -->
<xsl:apply-templates
select="
episodes/season[@id=$seasonid]/episode
"
/>
</body>
</html>
</xsl:template>
<!-- generate a single episode -->
<xsl:template
match="
episode
"
>
<xsl:apply-templates
/>
</xsl:template>
<xsl:template
match="
title
"
>
<xsl:variable
name="
episodeid
"
>
<xsl:value-of
select="
../@id
"
/>
</xsl:variable>
<h2
>
<a
name="
{$episodeid}
"
>
<xsl:value-of
select="
$episodeid
"
/>
.
<xsl:value-of
select="
.
"
/>
</a>
</h2>
</xsl:template>
<!-- generate the cast list
depending if it is a recurring role or a guest, process either the
child member element or the corresponding one from the recurring
list, identified by the ID -->
<xsl:template
match="
cast
"
>
<table
width="
100%
"
>
<tr
>
<td
valign="
top
"
width="
10%
"
>
with:
</td>
<td
>
<xsl:for-each
select="
member
"
>
<xsl:choose
>
<xsl:when
test="
@ref
"
>
<xsl:apply-templates
select="
id(@ref)
"
/>
</xsl:when>
<xsl:otherwise
>
<xsl:apply-templates
select="
.
"
/>
</xsl:otherwise>
</xsl:choose>
<xsl:if
test="
position()!=last()
"
>
<br
/>
</xsl:if>
</xsl:for-each>
</td>
</tr>
</table>
</xsl:template>
<!-- generate one single cast member
if a ref attribute is present, it is a recurring role, so create
a link to the actors' page -->
<xsl:template
match="
member
"
>
<xsl:choose
>
<xsl:when
test="
@id
"
>
<a
href="
actors.html#{@id}
"
>
<xsl:value-of
select="
actor
"
/>
</a>
</xsl:when>
<xsl:otherwise
>
<xsl:value-of
select="
actor
"
/>
</xsl:otherwise>
</xsl:choose>
<xsl:if
test="
role
"
>
as <i
>
<xsl:value-of
select="
role
"
/>
</i>
</xsl:if>
</xsl:template>
<!-- generate the synopsis -->
<xsl:template
match="
synopsis
"
>
<xsl:if
test="
@source=$source
"
>
<p
>
<xsl:value-of
select="
.
"
/>
</p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>