Hi all,
I’ve probably already shared this, but I thought that I’d share it again anyways.
Here’s a neat way you can create functions in your Koha XSLTs:
<xsl:stylesheet version="1.0"
xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:common="http://exslt.org/common"
xmlns:str="http://exslt.org/strings"
xmlns:func="http://exslt.org/functions"
xmlns:my="http://prosentient.com.au/xsltfunctions"
extension-element-prefixes="func"
exclude-result-prefixes="marc str my common">
<func:function name = "my:strToLower">
<xsl:param name="string" />
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="translated" select="translate($string, $uppercase, $lowercase)" />
<func:result select="$translated"/>
</func:function>
Most of the time you can probably just use templates with call-template and a parameter, but I find functions can just be really handy.
David Cook
Senior Software Engineer
Prosentient Systems
Suite 7.03
6a Glen St
Milsons Point NSW 2061
Australia
Office: 02 9212 0899
Online: 02 8005 0595