Abbreviation dependent on the number of authors

Jun 19, 2011 at 2:21 PM
Edited Jun 19, 2011 at 2:35 PM

Hello everyone. I am new in using BinWord but even so I find it a very useful tool for changing the way you bibliography looks. I have a problem regarding the abrreviation, and I could not find a soution in the previous discussions. So what I would like to do is the following: if there is only one author I would like to have the abrreviation showing the first 3 letters of his name + last 2 digits of the publication year (this I have done succesfully following the instructions from some older post); if there are 2 or more authors I want only the first letter of the name + last 2 digit of publication year.

E.g: 1 person (Mark Musterman - "Title" - 2011) -> [Mus11]

      2 or more persons (Mark Musterman, Susan Hamil, Erik Kandel - "Title" - 2005) -> [MHK05]

So far I have created a new namelist where the first author is defined as:  <first_person>{%Last:z%}</first_person> (where z is a new case created to substring the Name field to first 3 letters). The other persons field are defined as: <other_persons>{%Last:au%}</other_persons>. My problem in this approach is that the first person will always be shown with 3 letters and I could not find a way to create a dependency between the No. of Authors and how the abbreviation is shown (something like: if NoAuth<2 then ..([Mus11]).. else..[MHK05]..).

King regards

 boga8207

Coordinator
Jun 19, 2011 at 9:59 PM

There is no way to do this directly in BibWord. I would suggest you define a fake list element where the first_person is a predefined string like 'XXXX' and then adjust the template "format-contributors-by-params". For example at the start of the routine you could do something like:

<xsl:choose>
  <xsl:when test="$params/first_person = 'XXXX'">
    <!-- your custom routine -->    
  </xsl:when>
  <xsl:otherwise>
    <!-- original code -->
  </xsl:otherwise>
</xsl:choose> 

 


Jun 20, 2011 at 1:53 PM

Thank you very much for the quick reply Yves and for the advices. The problem is solved but I have done it in another way (I post this for other that might want the above described functionality). After reading your post I have seen the template "format-contributors-by-params" where the variable "numPersons" is defined. I have used this variable to in call the template "format-person" 2 times with a new created parameter ("singleAuth") which is 1 when we have a single author and 0 otherwise- the code looks like:

          <!-- Handle all the b:Person elements. -->
          <xsl:for-each select="$contributors/b:NameList/b:Person">
            <!-- The position of the current b:Person element. -->
            <xsl:variable name="pos" select="position()" />

            <xsl:choose>
              <xsl:when test="position() > $numDisplay"/>
              <xsl:when test="position() = 1">
               <xsl:choose>
               <xsl:when test="$numPersons = 1">
                 <!--<xsl:value-of select="substring($contributors/b:NameList/b:Person,1,3)"/>-->
                  <xsl:call-template name="format-person">
                  <xsl:with-param name="person" select="." />
                  <xsl:with-param name="format" select="$params/first_person" />
                  <xsl:with-param name="singleAuth">
                    <xsl:text>1</xsl:text>
                  </xsl:with-param>
                </xsl:call-template>
               </xsl:when>
               <xsl:otherwise>
                <xsl:call-template name="format-person">
                  <xsl:with-param name="person" select="." />
                  <xsl:with-param name="format" select="$params/first_person" />
                  <xsl:with-param name="singleAuth">
                    <xsl:text>0</xsl:text>
                  </xsl:with-param>                    
                </xsl:call-template>
               </xsl:otherwise>
              </xsl:choose> 
              </xsl:when>


In the functions "format-person", "format-person-part-2" and "format-person-part-3" I have defined the new parameter "singleAuth" and the value of the parameter I have just sendit from one function to the other:

  <xsl:template name="format-person">
    ...
    <xsl:param name="singleAuth"/>
    <xsl:call-template name="format-person-part-2">
      ...
      <xsl:with-param name="singleAuth" select="$singleAuth"/> 
  </xsl:call-template>

 ...
  <xsl:template name="format-person-part-2">
    ...
    <xsl:param name="singleAuth"/>
    ...
        <xsl:variable name="current">
          <xsl:call-template name="format-person-part-3">
            ...
            <xsl:with-param name="singleAuth" select="$singleAuth"/>
          </xsl:call-template>
        </xsl:variable>
 
 ...
  <xsl:template name="format-person-part-3">
    ...    
    <xsl:param name="singleAuth"/>
 ...

In the template "format-person-part-3" I have used this parameter n the definition of athe new option ("z") that makes in this case the substring for the first name (as shown in the initial post):

  ...
                <!-- Handle abbreviation. -->
                <xsl:choose>
                
                 <!--Option introduces by user to substring the Name of the Author -->
                 <xsl:when test="contains($options, 'z')">
                    <xsl:if test="$singleAuth = 1">
                       <xsl:value-of select="substring($person/*[local-name() = $name],1,3)"/>
                    </xsl:if>
                    <xsl:if test="$singleAuth = 0">
                    <xsl:value-of select="substring($person/*[local-name() = $name],1,1)"/>
                    </xsl:if>
                 </xsl:when> 

                <xsl:when test="contains($options, 'a')">
                   ....

This works well for me and I hope that there are no big problem with this approach (I am no expert in xml).

Thanks again for the help and for the nice tool that you have build.

Kind regards

Jun 22, 2011 at 4:25 PM

Hi boga8207,

could share the whole template. I'm looking for such citation style recently for my thesis and I think if your writing thesis in Germany :) in word such style is very nice to have:).

I can do it myself, but it is in fact a lot of effort and generally reinventing the wheel is bad principle :)


Cheers,
prodanoff

Jun 22, 2011 at 4:49 PM

No problem. send me your email please and I will send you the template.  I tried  to test it and for me worked with all the document types (book, article and so on) ... but if you find some mistakes/bugs  then let me know also please :).

 

King regards

  boga8207

Jul 11, 2014 at 3:07 PM
is it already such a template created and shared? i need it also..