Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:param name="break" select="'&#xA;'" />
<xsl:template match="/">
<xsl:value-of select="'&#35;EXTM3U'" />
<xsl:value-of select="$break" />
<xsl:apply-templates select="setupResponse/services/service-list/service/dvb-ip" />
</xsl:template>
<xsl:template match="dvb-ip">
<xsl:variable name="id">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="../@id" />
<xsl:with-param name="replace" select="'NEUF_'" />
<xsl:with-param name="by" select="''" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="'&#35;EXTINF:0 tvg-id=&#34;'" />
<xsl:value-of select="$id" />
<xsl:value-of select="'.tv.sfr.fr&#34; tvg-logo=&#34;'" />
<xsl:value-of select="$id" />
<xsl:value-of select="'.png&#34; group-title=&#34;SFR&#34;,'" />
<xsl:value-of select="parent::*/name" />
<xsl:value-of select="' - '" />
<xsl:value-of select="label" />
<xsl:value-of select="$break" />
<xsl:variable name="urlRtp">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="url" />
<xsl:with-param name="replace" select="'igmp://'" />
<xsl:with-param name="by" select="'rtp://'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$urlRtp" />
<xsl:value-of select="$break" />
</xsl:template>
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment