# contributor role function

**URL:** <https://discourse.citationstyles.org/t/contributor-role-function/60>\
**Category:** CSL Development\
**Created:** [April 18, 2005, 1:47am UTC](https://discourse.citationstyles.org/t/contributor-role-function/60 "2005-04-18T01:47:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruce\_D\_Arcus](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@Bruce\_D\_Arcus](https://discourse.citationstyles.org/u/Bruce_D_Arcus)\
**Post date:** [April 18, 2005, 1:47am UTC](https://discourse.citationstyles.org/t/contributor-role-function/60/1 "2005-04-18T01:47:14Z")

</div>

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
