add template file to further modify formatted xml.

converts the <episode-num system=onscreen> element to work with SxxEyy format
This commit is contained in:
Nic D 2026-02-12 13:20:32 -05:00
parent bd5ad07529
commit ca23ded3dc

44
tmpl.xsl Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- identity copy -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- modify programme/episode-num -->
<xsl:template match="programme[season-num and episode-num]/episode-num">
<xsl:variable name="s" select="../season-num"/>
<xsl:variable name="e" select="."/>
<xsl:variable name="s2">
<xsl:choose>
<xsl:when test="string-length($s) = 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:choose>
<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:value-of select="concat('S',$s2,'E',$e2)"/>
</episode-num>
</xsl:template>
</xsl:stylesheet>