ayerh.art/xslt/mb-collections.xsl

90 lines
3.2 KiB
XML
Raw Permalink Normal View History

2020-11-21 19:39:22 -05:00
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:mb="http://musicbrainz.org/ns/mmd-2.0#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="mb">
<xsl:output method="html" encoding="utf-8" indent="yes"/>
<xsl:variable name="static-bbb-base-url">https://static.bonerbonerboner.com</xsl:variable>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Righteous:100,300,400,500,700,900"/>
<link rel="stylesheet" href="./music.css"/>
<title>Ayerhart Music Collections</title>
</head>
<body>
<div class="collections">
<xsl:apply-templates select="mb:metadata/mb:collection-list"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="mb:collection">
<div>
<xsl:variable name="sans-ayerhart">
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="mb:name"/>
<xsl:with-param name="replace" select="'Ayerhart '"/>
<xsl:with-param name="with" select="''"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="collection-name">
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="$sans-ayerhart"/>
<xsl:with-param name="replace" select="' Collection'"/>
<xsl:with-param name="with" select="''"/>
</xsl:call-template>
</xsl:variable>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$collection-name = 'Vintage Vinyl'">
<xsl:value-of select="'collection-link vintage'"/>
</xsl:when>
<xsl:when test="$collection-name = 'Digital'">
<xsl:value-of select="'collection-link digital'"/>
</xsl:when>
<xsl:when test="$collection-name = 'Vinyl'">
<xsl:value-of select="'collection-link vinyl'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'collection-link'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<a href="/{@id}"><xsl:value-of select="$collection-name"/></a>
</div>
</xsl:template>
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text"
select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>