contributor role function

I’ve not quite figured out how to get this working, but with respect to
the need to categorize different mods:name elements based on their
roles, I’m thinking of a function something like this:

<xsl:function name=“bib:contributor-role” as=“xs:string”>
<xsl:param name=“name” as=“element(mods:name)?”/>
<xsl:variable name=“primary” select="(‘author’, ‘editor’,
‘creator’)"/>
<xsl:variable name=“secondary” select="(‘translator’)"/>
xsl:value-of
xsl:choose
<xsl:when
test="$name/mods:role/mods:roleTerm[@type=‘text’]=$primary">
xsl:textprimary</xsl:text>
</xsl:when>
<xsl:when
test="$name/mods:role/mods:roleTerm[@type=‘text’]=$secondary">
xsl:textsecondary</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:value-of>
</xsl:function>

I suppose this raises the question of whether these roles ought to be
configured in CSL though.

Bruce