Part of PAZ-996.
[pazpar2-moved-to-github.git] / etc / xsl / solr-pz2.xsl
index f6fa5dd..9c8bed5 100644 (file)
   </xsl:template>
 
   <xsl:template name="string">
-      <pz:metadata>
-       <xsl:attribute  name="type">
-         <xsl:value-of select="../@name"/>
-       </xsl:attribute>
-       <xsl:choose>
-         <xsl:when test="../@name = 'medium' and string-length($medium) = 0">
-         </xsl:when>
-         <xsl:otherwise>
-           <xsl:value-of select="."/>
-         </xsl:otherwise>
-       </xsl:choose>
-      </pz:metadata>
+    <xsl:choose>
+      <xsl:when test="../@name = 'medium' and string-length($medium) &gt; 0">
+      </xsl:when>
+      <xsl:otherwise>
+       <pz:metadata>
+         <xsl:attribute  name="type">
+           <xsl:value-of select="../@name"/>
+         </xsl:attribute>
+         <xsl:value-of select="."/>
+       </pz:metadata>
+       <xsl:if test="../@name='license_url'">
+        <pz:metadata type="license_name">
+         <xsl:choose>
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by/')">
+           CC By
+          </xsl:when>
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by-sa/')">
+           CC By-SA
+          </xsl:when>
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by-nd/')">
+           CC By-ND
+          </xsl:when>
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by-nc/')">
+           CC By-NC
+          </xsl:when>
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by-nc-sa/')">
+           CC By-NC-SA
+          </xsl:when>
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by-nc-nd/')">
+           CC By-NC-ND
+          </xsl:when>
+          <!-- There is actually no such licence as this, but East London uses it anyway! -->
+          <xsl:when test="starts-with(., 'http://creativecommons.org/licenses/by-nd-sa/')">
+           CC By-ND-SA
+          </xsl:when>
+          <xsl:otherwise>
+           [unknown]
+          </xsl:otherwise>
+         </xsl:choose>
+        </pz:metadata>
+       </xsl:if>
+      </xsl:otherwise>
+    </xsl:choose>
   </xsl:template>
 
 </xsl:stylesheet>