<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:tv="http://xmlns.com/2003/rdftv/tv#">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <rdf:RDF>
            <xsl:apply-templates select="tv/channel" />
            <xsl:apply-templates select="tv/programme" />
        </rdf:RDF>
    </xsl:template>

    <xsl:template match="channel">
        <tv:channel rdf:about="http://xmlns.com/2003/rdftv/channel#{@id}">
            <xsl:apply-templates select="*" />
        </tv:channel>
    </xsl:template>

    <xsl:template match="display-name">
        <tv:display-name><xsl:value-of select="." /></tv:display-name>
    </xsl:template>

    <xsl:template match="icon">
        <tv:icon rdf:resource="{@src}" />
    </xsl:template>

    <xsl:template match="programme">
        <tv:programme tv:start="{@start}" tv:stop="{@stop}">
            <tv:channel rdf:resource="http://xmlns.com/2003/rdftv/channel#{@channel}" />
            <xsl:apply-templates select="*" />
        </tv:programme>
    </xsl:template>

    <xsl:template match="title">
        <tv:title><xsl:value-of select="." /></tv:title>
    </xsl:template>

    <xsl:template match="date">
        <tv:date><xsl:value-of select="." /></tv:date>
    </xsl:template>

    <xsl:template match="previously-shown">
        <tv:previously-shown>yes</tv:previously-shown>
    </xsl:template>

    <xsl:template match="episode-num">
        <tv:episode-num><xsl:value-of select="." /></tv:episode-num>
    </xsl:template>

    <xsl:template match="desc">
        <tv:desc><xsl:value-of select="." /></tv:desc>
    </xsl:template>

    <xsl:template match="category">
        <tv:category rdf:resource="http://xmlns.com/2003/rdftv/category/ananova#{translate(.,' ','')}" />
    </xsl:template>

    <xsl:template match="video">
        <tv:video tv:present="{present}" tv:aspect="{aspect}" />
    </xsl:template>

    <xsl:template match="audio">
        <tv:audio tv:present="{present}" tv:stereo="{stereo}" />
    </xsl:template>

    <xsl:template match="subtitles">
        <tv:subtitles tv:type="{@type}" />
    </xsl:template>

    <xsl:template match="*" />
</xsl:stylesheet>
