Sorting Numerical References

Feb 12, 2010 at 4:26 PM

Firstly, I'd like to say a big 'thank you' for all the information and work that's been put into this site.  I would not have got anywhere without the information and examples here.

I've created a simple style which uses numerical references.  When I insert the bibliography, the entries are sorted by type (e.g Report, Book etc), then by reference number.  I'd like to be able to insert / sort the bibliography by reference order.  Can anyone (Yves?!) give me a hint on how to go about figuring this out?

Many thanks in advance.

Coordinator
Feb 12, 2010 at 7:42 PM

The sorting depends on the value of the sortkey element. If you want a bibliography to be sorted by reference order, you should just leave the element blank (or even remove it).

Feb 15, 2010 at 9:19 AM

Thank you for your very quick reply.  I've seen your templates etc and they are superb - I've developed a couple of styles using them, and they work perfectly (thank you again!). I'm now trying to write styles myself, without the template, and I was wondering if it was possible to get a bit more info on the process for sorting the references?

 

Coordinator
Feb 15, 2010 at 10:50 AM

In case of bibliographies, Word 2007 sends an xml looking like the following to the stylesheet:

<b:Bibliography>
  <!-- Some localization information with language specific strings -->
  <b:Source>
    <!-- A source. -->
  </b:Source>
  <b:Source>
    <!-- A source. -->
  </b:Source>
  <b:Source>
    <!-- A source. -->
  </b:Source>
  <b:Source>
    <!-- A source. -->
  </b:Source>
</b:Bibliography>

There is no specific order in them, so it is up to you to sort them. If your sorting mechanism is simple, for example reference order, you can do it in one go:

<xsl:for-each select="/b:Bibliography/b:Source">
  <xsl:sort select="b:RefOrder" data-type="number"/>

  <!-- Handle the displaying of each source. -->
</xsl:for-each>

If you want to make something more complex, like BibWord allows, you will have to create some type of 2 pass filtering. First you copy each Source but add an extra element (BibWord uses SortKey) where you provide a sorting string. Then you can do the same as above and use the sorting string in your select.

To see this at work in BibWord, check out the templates format-bibliography which adds the sortkey element and then format-bibliography-as-paragraphs which actually sorts the items according to the sortkey.

Note that a third reordering might be required if you intend to take a look at the previous source in a sorted sequence.

Feb 15, 2010 at 12:02 PM

Thank you :)