fix: correct xsl template to remove any existing onscreen episode-num before replacing it with new one
This commit is contained in:
parent
ca23ded3dc
commit
65da0ab778
82
tmpl.xsl
82
tmpl.xsl
|
|
@ -2,43 +2,69 @@
|
||||||
<xsl:stylesheet version="1.0"
|
<xsl:stylesheet version="1.0"
|
||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
<!-- identity copy -->
|
<!-- identity -->
|
||||||
<xsl:template match="@*|node()">
|
<xsl:template match="@*|node()">
|
||||||
<xsl:copy>
|
<xsl:copy>
|
||||||
<xsl:apply-templates select="@*|node()" />
|
<xsl:apply-templates select="@*|node()" />
|
||||||
</xsl:copy>
|
</xsl:copy>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<!-- modify programme/episode-num -->
|
<!-- Special handling for programme -->
|
||||||
<xsl:template match="programme[season-num and episode-num]/episode-num">
|
<xsl:template match="programme">
|
||||||
<xsl:variable name="s" select="../season-num"/>
|
<xsl:copy>
|
||||||
<xsl:variable name="e" select="."/>
|
<xsl:apply-templates select="@*"/>
|
||||||
|
|
||||||
<xsl:variable name="s2">
|
<!-- Grab xmltv_ns once -->
|
||||||
<xsl:choose>
|
<xsl:variable name="raw"
|
||||||
<xsl:when test="string-length($s) = 1">
|
select="normalize-space(episode-num[@system='xmltv_ns'][1])"/>
|
||||||
<xsl:value-of select="concat('0',$s)"/>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="$s"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:variable>
|
|
||||||
|
|
||||||
<xsl:variable name="e2">
|
<xsl:variable name="season0"
|
||||||
<xsl:choose>
|
select="number(substring-before($raw, '.'))"/>
|
||||||
<xsl:when test="string-length($e) = 1">
|
|
||||||
<xsl:value-of select="concat('0',$e)"/>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="$e"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:variable>
|
|
||||||
|
|
||||||
<episode-num>
|
<xsl:variable name="rest"
|
||||||
<xsl:value-of select="concat('S',$s2,'E',$e2)"/>
|
select="substring-after($raw, '.')"/>
|
||||||
</episode-num>
|
|
||||||
|
<xsl:variable name="episode"
|
||||||
|
select="number(normalize-space(substring-before($rest, '.')))"/>
|
||||||
|
|
||||||
|
<xsl:variable name="season" select="$season0 + 1"/>
|
||||||
|
|
||||||
|
<!-- zero pad -->
|
||||||
|
<xsl:variable name="s2">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$season < 10">
|
||||||
|
<xsl:value-of select="concat('0',$season)"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$season"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:variable name="e2">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$episode < 10">
|
||||||
|
<xsl:value-of select="concat('0',$episode)"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$episode"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:variable name="onscreenValue"
|
||||||
|
select="concat('S',$s2,'E',$e2)"/>
|
||||||
|
|
||||||
|
<!-- Copy all children EXCEPT existing onscreen -->
|
||||||
|
<xsl:apply-templates
|
||||||
|
select="node()[not(self::episode-num[@system='onscreen'])]" />
|
||||||
|
|
||||||
|
<!-- Add the onscreen one at the end -->
|
||||||
|
<episode-num system="onscreen">
|
||||||
|
<xsl:value-of select="$onscreenValue"/>
|
||||||
|
</episode-num>
|
||||||
|
|
||||||
|
</xsl:copy>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
Loading…
Reference in New Issue
Block a user