⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tv.xsl

📁 xml good example for tv guide.
💻 XSL
📖 第 1 页 / 共 3 页
字号:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:variable name="DescriptionBR">0</xsl:variable>

<xsl:param name="FixGaps" /> <!--use ONLY if xml has been sorted WITH by-channel -->

<xsl:param name="DisplayLength" />

<xsl:param name="CurrentYear"/>
<xsl:param name="CurrentMonth"/>
<xsl:param name="CurrentDay"/>
<xsl:param name="CurrentHour"/>

<xsl:param name="StopYear"/>
<xsl:param name="StopMonth"/>
<xsl:param name="StopDay"/>
<xsl:param name="StopHour"/>

<xsl:param name="PrevYear"/>
<xsl:param name="PrevMonth"/>
<xsl:param name="PrevDay"/>
<xsl:param name="PrevHour"/>

<xsl:param name="PopupDelay"/>
<xsl:param name="DescriptionPopups"/>
<xsl:param name="ChannelPopups"/>
<xsl:param name="PopupTimes"/>
<xsl:param name="PopupRating"/>
<xsl:param name="PopupSubtitle"/>
<xsl:param name="PopupDescription"/>
<xsl:param name="PopupDate"/>
<xsl:param name="PopupCategories"/>
<xsl:param name="PopupStarRating"/>
<xsl:param name="Categories"/>
<xsl:param name="AbsoluteIcons"/>
<xsl:param name="Grabber"/>
<xsl:param name="DayFirst"/>
<xsl:param name="EarlierText"/>
<xsl:param name="LaterText"/>

<xsl:param name="OnClick"/>
<xsl:param name="ClickTarget" select="'_blank'"/>
<xsl:param name="HighlightClickable" />
<xsl:param name="HighlightMovies" />
<xsl:param name="HighlightNew"/>
<xsl:param name="PrintDates" />
<xsl:param name="TimeBarFrequency" />

<xsl:template match="/">
<div class="xsldiv">
<xsl:variable name="ExtendLeftText">&lt;&lt;</xsl:variable>
<xsl:variable name="ExtendRightText">&gt;&gt;</xsl:variable>

<xsl:variable name="StartDisplayCode" select="number($CurrentHour)*60" /> <!-- These are for rendering the table -->
<xsl:variable name="StopDisplayCode" select="(number($CurrentHour)+number($DisplayLength))*60" />

<xsl:variable name="StartTimeString" select="number(concat($CurrentYear, format-number($CurrentMonth,'00'), format-number($CurrentDay,'00'), format-number($CurrentHour,'00'), '00'))" /> <!-- These are for selecting the appropriate programmes -->
<xsl:variable name="StopTimeString" select="number(concat($StopYear, format-number($StopMonth,'00'), format-number($StopDay,'00'), format-number($StopHour,'00'), '00'))" /> <!-- These are for selecting the appropriate programmes -->
<xsl:variable name="programmes" select="/tv/programme[((substring(@stop,1,12) &gt; $StartTimeString and substring(@stop,1,12) &lt;= $StopTimeString) or (substring(@start,1,12) &gt;= $StartTimeString and substring(@start,1,12) &lt; $StopTimeString) or (substring(@start,1,12) &lt;= $StartTimeString and substring(@stop,1,12) &gt;= $StopTimeString))]"/>

<table id="listings">

<xsl:for-each select="/tv/channel">
<xsl:sort select="display-name[3]" data-type="number"></xsl:sort>

<xsl:choose>
	<xsl:when test="(position() mod $TimeBarFrequency = 1) or (position() = 1)">
    <tr class="timebar">
	<th class="topleftcorner">
		<xsl:attribute name="onclick">
			<xsl:value-of select="concat('Init','(',$DisplayLength,',',$PrevHour,',',$PrevDay,',',$PrevMonth,',',$PrevYear,')')" />
		</xsl:attribute>
		<xsl:value-of select="$EarlierText"/>
	</th>
		<xsl:call-template name="for.loop">
			<xsl:with-param name="i"><xsl:value-of select="$CurrentHour"/></xsl:with-param>
			<xsl:with-param name="count"><xsl:value-of select="$DisplayLength + $CurrentHour - 1"/></xsl:with-param>
			<xsl:with-param name="start"><xsl:value-of select="$CurrentHour"/></xsl:with-param>
		</xsl:call-template>
	<th class="toprightcorner">
		<xsl:attribute name="onclick">
			<xsl:value-of select="concat('Init','(',$DisplayLength,',',$StopHour,',',$StopDay,',',$StopMonth,',',$StopYear,')')" />
		</xsl:attribute>
		<xsl:value-of select="$LaterText"/>
	</th>
    </tr>
			</xsl:when>
		</xsl:choose>

<xsl:variable name="channelnumber">
	<xsl:choose>
		<xsl:when test="$Grabber = 'tv_grab_na_dd'">
			<xsl:value-of select="display-name[3]"/>
		</xsl:when>
		<xsl:when test="$Grabber = 'tv_grab_es'">
			<xsl:value-of select="display-name[2]"/>
		</xsl:when>
		<xsl:when test="$Grabber = 'tv_grab_fr'">
			<xsl:value-of select="substring-after(substring-before(./@id,'.'),'C')"/>
		</xsl:when>
		<xsl:when test="$Grabber = 'tv_grab_se' or $Grabber = 'tv_grab_de'"><xsl:text> </xsl:text></xsl:when>
		<xsl:when test="$Grabber = 'tv_grab_huro'">
			<xsl:value-of select="substring(./@id,1,3)"/>
		</xsl:when>
		<xsl:otherwise>
			??
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>

<xsl:variable name="channelshortname">
	<xsl:choose>
		<xsl:when test="$Grabber='tv_grab_na_dd'">
			<xsl:value-of select="normalize-space(substring-after(display-name[1],display-name[3]))"/>
		</xsl:when>
		<xsl:when test="$Grabber='tv_grab_es'">
			<xsl:value-of select="display-name[1]"/>
		</xsl:when>
		<xsl:when test="$Grabber='tv_grab_fr' or $Grabber='tv_grab_se' or $Grabber='tv_grab_de' or $Grabber = 'tv_grab_huro'">
			<xsl:value-of select="display-name"/>
		</xsl:when>
		<xsl:otherwise>
			??
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>

<xsl:variable name="channellongname">
	<xsl:choose>
		<xsl:when test="$Grabber='tv_grab_na_dd'">
			<xsl:value-of select="display-name[5]" />
		</xsl:when>
		<xsl:when test="$Grabber='tv_grab_es'">
			<xsl:value-of select="display-name[1]"/>
		</xsl:when>
		<xsl:when test="$Grabber='tv_grab_fr' or $Grabber='tv_grab_se' or $Grabber='tv_grab_de' or $Grabber = 'tv_grab_huro'">
			<xsl:value-of select="display-name" />
		</xsl:when>
		<xsl:otherwise>
			??
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>

			<xsl:variable name="iconname">
    				<xsl:call-template name="filename">
					<xsl:with-param name="x" select="icon/@src"/>
				</xsl:call-template>
			</xsl:variable>
	<tr>
		<xsl:choose>
			<xsl:when test="(position() mod 2 = 1)">
				<xsl:attribute name="class">
					oddrow
				</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="class">
					evenrow
				</xsl:attribute>
			</xsl:otherwise>
		</xsl:choose>
		<th class="channel">
			<xsl:if test="$ChannelPopups">
				<xsl:attribute name="title">
					<xsl:text>header=[</xsl:text>
					<xsl:if test="string-length($iconname) &gt; 0">
						<xsl:text>&lt;img src="</xsl:text>
						<xsl:choose>
							<xsl:when test="$AbsoluteIcons">
								<xsl:value-of select="icon/@src"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="concat('icons/',$iconname)"/>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text>" alt="" class="popupimage"/></xsl:text>
					</xsl:if>
					<xsl:value-of select="$channellongname" />
					<xsl:text>] body=[</xsl:text>
					<xsl:value-of select="display-name[7]"/>
					<xsl:text>] cssheader=[popupheader] cssbody=[popupbody] delay=[</xsl:text>
					<xsl:value-of select="$PopupDelay"/>
					<xsl:text>]</xsl:text>
				</xsl:attribute>
			</xsl:if>
		<table class="leftchanneltable"><tr><td class="leftlogocell"><xsl:if test="string-length($iconname) &gt; 0"><img><xsl:attribute name="src">
						<xsl:choose>
							<xsl:when test="$AbsoluteIcons">
								<xsl:value-of select="icon/@src"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="concat('icons/',$iconname)"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute><xsl:attribute name="class">channelimage</xsl:attribute></img></xsl:if></td><td class="leftnumbercell"><xsl:value-of select="$channelnumber"/></td><td class="middlecell"><span class="leftnumber"><xsl:value-of select="$channelnumber"/></span><br class="leftchannelbr" /><span class="leftnbsp">&#160;</span><span class="channelname"><xsl:value-of select="$channelshortname"/></span><br class="rightchannelbr" /><span class="rightnbsp">&#160;</span><span class="rightnumber"><xsl:value-of select="$channelnumber"/></span></td><td class="rightnumbercell"><xsl:value-of select="$channelnumber"/></td><td class="rightlogocell"><xsl:if test="string-length($iconname) &gt; 0"><img><xsl:attribute name="src">						<xsl:choose>
							<xsl:when test="$AbsoluteIcons">
								<xsl:value-of select="icon/@src"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="concat('icons/',$iconname)"/>
							</xsl:otherwise>
						</xsl:choose>
</xsl:attribute><xsl:attribute name="class">channelimage</xsl:attribute></img></xsl:if></td></tr></table>
		</th>
		<xsl:variable name="theseprogrammes" select="$programmes[@channel=current()/@id]"/>
		<xsl:for-each select="$theseprogrammes">                                           <!--Program Stop Time is after Display Start   and Program Stop Time is before Display End......or...Program Start Time is after Display Start and Program Start Time is before Display End........or  Program Start Time is before Display Start and Program Stop Time is after Display End. -->
		<xsl:sort select="@start"/>
		<xsl:variable name="StartTime">
			<xsl:choose>
				<xsl:when test="number(substring($StartTimeString,1,8)) &lt; number(substring(@start,1,8))">  <!--it must be starting tomorrow ... Add the number of minutes in a day. -->
					<xsl:value-of select="(number((number(substring(@start,9,2))*60)+number(substring(@start,11,2)))) + 1440"/>
				</xsl:when>
				<xsl:when test="number(substring($StartTimeString,1,8)) &gt; number(substring(@start,1,8))">  <!--it have started yesterday ... Subtract the number of minutes in a day. -->
					<xsl:value-of select="(number((number(substring(@start,9,2))*60)+number(substring(@start,11,2)))) - 1440"/>
				</xsl:when>
				<xsl:otherwise> <!--otherwise it must be starting tomorrow ... Add the number of minutes in a day. -->
					<xsl:value-of select="number((number(substring(@start,9,2))*60)+number(substring(@start,11,2)))"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="NextStartTime">
			<xsl:choose>
				<xsl:when test="$FixGaps">
						<xsl:choose>
							<xsl:when test="number(substring($StartTimeString,1,8)) &lt; number(substring(following::programme[1]/@start,1,8))">
								<xsl:value-of select="(number((number(substring(following::programme[1]/@start,9,2))*60)+number(substring(following::programme[1]/@start,11,2)))) + 1440"/>
							</xsl:when>
							<xsl:when test="number(substring($StartTimeString,1,8)) &gt; number(substring(following::programme[1]/@start,1,8))">
								<xsl:value-of select="(number((number(substring(following::programme[1]/@start,9,2))*60)+number(substring(following::programme[1]/@start,11,2)))) - 1440"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="number((number(substring(following::programme[1]/@start,9,2))*60)+number(substring(following::programme[1]/@start,11,2)))"/>
							</xsl:otherwise>
						</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>0</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="Length">
			<xsl:choose>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -