Displaying # of coauthors?

Jan 6, 2010 at 6:38 PM

I'm trying to use the a modification of the CSE Name seq to implement the following:

If more than 10 authors, display first three authors and "et al. (# of co-authors).

 

<separator_before_last>, </separator_before_last>
        <max_number_of_persons_to_display>10</max_number_of_persons_to_display>
        <number_of_persons_to_display_if_more_than_max>3</number_of_persons_to_display_if_more_than_max>
        <overflow>, et al.</overflow>

 

Does almost what I need but I can't figure out how to display the # of co-authors (or number of authors - 1).

 

 

Coordinator
Jan 7, 2010 at 9:26 AM

You can't. The only option that is available for counting authors has nothing to do with how contributor sets are formatted.

What you could do is, if you don't use that option, is replace the count-contributors template with your own version.

So instead of:

  <!-- Counts the number of contributors in a contributors element. -->
  <xsl:template name="count-contributors">
    <!-- A set containing either a b:Corporate or a b:NameList element. -->
    <xsl:param name="contributors" />

    <xsl:choose>
      <!-- b:Corporate contributor. -->
      <xsl:when test="string-length($contributors/b:Corporate) > 0">
        <xsl:text>1</xsl:text>
      </xsl:when>
      <!-- b:NameList contributor(s). -->
      <xsl:when test="string-length($contributors/b:NameList) > 0">
        <xsl:value-of select="count($contributors/b:NameList/b:Person)" />
      </xsl:when>
      <!-- Empty element. -->
      <xsl:otherwise>
        <xsl:text>0</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

You could use something like:

  <xsl:template name="count-contributors">
    <!-- A set containing either a b:Corporate or a b:NameList element. -->
    <xsl:param name="contributors" />

    <!-- Check if this is a non-corporate contributor. -->
    <xsl:if test="string-length($contributors/b:Corporate) = 0">
      <!-- Check if there are actually contributors. -->
      <xsl:if test="string-length($contributors/b:NameList) > 0">
        <!-- Get the number of contributors. -->
        <xsl:variable name="amount">
          <xsl:value-of select="count($contributors/b:NameList/b:Person)" />
        </xsl:variable>

        <!-- If there are more than 10 contributors, display the amount minus 1. -->        
        <xsl:if test="$amount > 10">
          <xsl:text>(</xsl:text>
          <xsl:value-of select="$amount - 1"/>
          <xsl:text>)</xsl:text>
        </xsl:if>        
      </xsl:if>
    </xsl:if>    
  </xsl:template>

And then you could create a format string which looks like:

<format>{%Author:2r%{ %Author:c%.}}{ %Title%}</format>

Important here is the 'r' after the 2. It indicates that the Author variable can be reused once more.

 

 

 

Jan 7, 2010 at 3:40 PM

This worked!

Thanks.