How to make headings in the bibliography

Nov 10, 2009 at 3:55 PM

Hey,

 

my Professor is using his own very complex citation style. With Bibword i was able to make all the things he wants possible(expect one)..

First I want to thank you for this!!!

My Last topic is that he wan'ts differnet headings/groups in the bibliography.

 

example:

BOOKS:

author1, year 1 ...

author2, year 2 ...

 

NEWSPAPERS:

blabla

 

INTERNET SOURCES:

author3 , www......

author4, year, wwww..

 

 

I was able to sort in the right way. Same sources are grouped together in the moment. I'm also able to output the sourcetype with every author:

 

 <xsl:if test="$sourcetype='Book'">
                <!--<xsl:text>&lt;b&gt; </xsl:text> -->
                <xsl:text> Buch </xsl:text>
            </xsl:if>

 <xsl:if test="$sourcetype='Book'"

                <xsl:text> BOOKS </xsl:text>

            </xsl:if>

 

 

But i don't need it with EVERY author, only once. 

Is this possible? How?

 

Thanks Joe

 

Coordinator
Nov 10, 2009 at 5:55 PM

BibWord does not provide support for headings at the moment.

But it is pretty easy to adjust the stylesheet to support your specific case. I'm assuming that you are not using a table layout but rather a simple paragraph layout. Look for the template "format-bibliography-as-paragraphs". The template looks like this:

  <!-- Formats a bibliography as a series of paragraphs. -->
  <xsl:template name="format-bibliography-as-paragraphs">
    <xsl:param name="bibNodeSet"/>

    <xsl:for-each select="$bibNodeSet/b:Bibliography/b:Source">
      <xsl:sort select="b:SortKey" data-type="text"/>
   
      <p class="MsoBibliography">
        <!-- A bunch of code. -->
      </p>

    </xsl:for-each>

  </xsl:template>

What you can do is replace the top of this code with the following code (everything above the "p" element):

  <xsl:template name="format-bibliography-as-paragraphs">
    <xsl:param name="bibNodeSet"></xsl:param>

    <!-- pre-sort the entries to allow preceding-sibling lookup. -->
    <xsl:variable name="presorted">
      <b:Bibliography>
        <xsl:for-each select="$bibNodeSet/b:Bibliography/b:Source">
          <xsl:sort select="b:SortKey" data-type="text"/>

          <b:Source>
            <xsl:copy-of select="./*"></xsl:copy-of>
          </b:Source>
        </xsl:for-each>
      </b:Bibliography>
    </xsl:variable>
    
    <xsl:for-each select="msxsl:node-set($presorted)/b:Bibliography/b:Source">
      <!--<xsl:sort select="b:SortKey" data-type="text"></xsl:sort>-->

      <xsl:if test="not(./b:SourceType = preceding-sibling::b:Source[1]/b:SourceType)">
        <h4>
          <xsl:value-of select="./b:SourceType"/>
        </h4>
      </xsl:if>
      
      <p class="MsoBibliography">
        <!-- A bunch of code. -->
      </p>

    </xsl:for-each>

  </xsl:template>

The above code assumes that you already sort by SourceType (something you do according to your message). It presorts your entries so that SourceTypes of successive entries can be compared to decide when a new SourceType comes up. The code:

  <h4>
    <xsl:value-of select="./b:SourceType"/>
  </h4>

is what is shown on top of each category. If you don't like the strings, you can replace them with your own. The quickest way would be:

  <h4>
    <xsl:choose>
      <xsl:when test="./b:SourceType = 'BookSection'">
        <xsl:text>Book Section</xsl:text>
      </xsl:when>
      <xsl:when test="./b:SourceType = 'JournalArticle'">
        <xsl:text>Journal Paper</xsl:text>
      </xsl:when>
      <!-- ... and so on ... -->
      <xsl:otherwise>
        <xsl:value-of select="./b:SourceType"/>
      </xsl:otherwise>
    </xsl:choose>
  </h4>

The otherwise is a fallback mechanism in case you didn't provide a string for a specific type. (Note that in the latest version of BibWord, you could query that string from the data element).

The "h4" element is only there as an example. You can add any p or hX element you want.

Dec 7, 2009 at 1:26 PM
Edited Dec 7, 2009 at 1:27 PM

this is great! but how do I sort by SourceType? i modified <xsl:variable name="extendedBib"> with a <xsl:sort select="./b:SourceType"/> but maybe it's the <b:SortKey> i should modify?

<!-- Extends the b:Source elements of the b:Bibliography element with a b:SortKey. -->
    <xsl:variable name="extendedBib">
      <!-- Create a b:Bibliography element. -->
      <b:Bibliography>
        <!-- Extend all the b:Source elements with a sortkey. -->
        <xsl:for-each select="/b:Bibliography/b:Source">
            <xsl:sort select="./b:SourceType"/>

 

Coordinator
Dec 7, 2009 at 2:12 PM

Yes, each <b:SortKey> element should start with {%SourceType% } to ensure initial sorting on type.