This is a simple and pure XSLT 1.0 solution, kapanış etiketleri hangi yarısı sadece 47 çizgileri, oluşan. The following transformation,
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:param name="pNewLink"
select="'http://stream001.radio.hu:8000/content/'"/>
<xsl:param name="pNewExt" select="'.mp3'"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="link">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:variable name="vFName">
<xsl:call-template name="GetFileName">
<xsl:with-param name="pFPath" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat($pNewLink,$vFName,$pNewExt)"/>
</xsl:copy>
</xsl:template>
<xsl:template name="GetFileName">
<xsl:param name="pFPath"/>
<xsl:choose>
<xsl:when test="not(contains($pFPath, '/'))">
<xsl:value-of select="substring-before($pFPath, '.')"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="GetFileName">
<xsl:with-param name="pFPath"
select="substring-after($pFPath, '/')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
when applied on the provided source XML document:
<item>
<title>2008. november 23.</title>
<link>http://www.mr1-kossuth.hu/m3u/0039c36f_3003051.m3u</link>
<description>........</description>
<pubDate>Wed, 26 Nov 2008 00:00:00 GMT</pubDate>
</item>
produces the wanted result:
<item>
<title>2008. november 23.</title>
<link>http://stream001.radio.hu:8000/content/0039c36f_3003051.mp3</link>
<description>........</description>
<pubDate>Wed, 26 Nov 2008 00:00:00 GMT</pubDate>
</item>
Bu çözeltinin Do note the following spesifik özellikleri:
Biz identity transformation a> kullanarak ve geçersiz kılma XSLT tasarım deseni kullanın.
, Dosya uzantısı ile sadece dosya (parametre olarak geçildi) tam URL'den The template named "GetFileName "özler çıkardı. Bu is a good example of a named template that calls itself recursively.
- İstenilen yeni URL'lerin bileşenleri küresel
<xsl:param>
s olarak belirtilir