EPrints Technical Mailing List Archive

Message: #07130


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Citation file refactor part 2.


So to make our citation files easier to edit and debug, first of all I split citation/eprint/default.xml into a bunch of files, and cut it down to:

<?xml version="1.0" ?>
<cite:citation xmlns="http://www.w3.org/1999/xhtml"; xmlns:epc="http://eprints.org/ep3/control"; xmlns:cite="http://eprints.org/ep3/citation"; >
<span class="citation">
<epc:choose>

  <!--  Article -->
  <epc:when test="type = 'article' or type = 'letter' or type = 'review' or type = 'meeting_abstract' or type = 'special_issue' or type = 'editorial'">
      <epc:print expr="$item.citation('type_article')" />
  </epc:when>

  <!--  Book -->
  <epc:when test="type = 'book'">
      <epc:print expr="$item.citation('type_book')" />
  </epc:when>

etc...

Then make files for each variation, eg. type_article.xml:

<?xml version="1.0" ?>
<cite:citation xmlns="http://www.w3.org/1999/xhtml"; xmlns:epc="http://eprints.org/ep3/control"; xmlns:cite="http://eprints.org/ep3/citation"; >
  <epc:comment>
ARTICLE, LETTER, REVIEW, MEETING ABSTRACT, SPECIAL ISSUE, EDITORIAL
  </epc:comment>
  <epc:print expr="$item.citation('field_creators_editors_corp')" />

  <epc:print expr="$item.citation('field_date')" />

  <epc:print expr="$item.citation('field_title_stop')" />

  <epc:print expr="$item.citation('field_special')" />

  <epc:if test="is_set(publication)">
    <epc:list join=", " suffix=".">
      <epc:item><span class="publication"><em><epc:print expr="publication"/></em></span></epc:item>
      <epc:item><epc:list join=" ">
          <epc:item><epc:if test="is_set(volume)"><span class="volume"><epc:print expr="volume"/></span></epc:if></epc:item>
          <epc:item><epc:if test="is_set(number)"><span class="number">(<epc:print expr="number"/>)</span></epc:if></epc:item>
      </epc:list></epc:item>
      <epc:item><epc:if test="is_set(supplement)"><span class="part">supplement <epc:print expr="supplement"/></span></epc:if></epc:item>
      <epc:item><epc:if test="is_set(part)"><span class="part">part <epc:print expr="part"/></span></epc:if></epc:item>
      <epc:item><epc:if test="is_set(season)"><span class="season"><epc:print expr="season"/></span> Issue</epc:if></epc:item>
      <epc:item><epc:if test="is_set(pagerange)"><span class="pagerange"><epc:print expr="pagerange"/></span></epc:if></epc:item>
    </epc:list>
  </epc:if>

  <epc:if test="is_set(doi)"><span class="doi"> (<epc:print expr="doi"/>).</span></epc:if>

  <epc:print expr="$item.citation('field_pubmed')" />

  <epc:print expr="$item.citation('field_ispub')" />

</cite:citation>

and then a citation field for each complicated section which is used in multiple files. Turns out we had the same thing done slightly differently in different places, for no good reason. This let me sane-ify it all a bit.

Here's the title field renderer. It detects if the last character isn't ! ? or . and if it's not, adds a full stop.

<?xml version="1.0" ?>
<cite:citation xmlns="http://www.w3.org/1999/xhtml"; xmlns:epc="http://eprints.org/ep3/control"; xmlns:cite="http://eprints.org/ep3/citation"; >
    <epc:comment>
TITLE FIELD WITH FULLSTOP
    </epc:comment>
    <span class="title"><cite:linkhere><epc:print expr="title" /><epc:if test="substr(title,-1,1) != '.' and substr(title,-1,1) != '?' and substr(title,-1,1) != '!'">.</epc:if></cite:linkhere></span>
</cite:citation>

And this one is fun, a comma separated list of three comma separated lists! (using the epc:list feature I described in the last email)

<?xml version="1.0" ?>
<cite:citation xmlns="http://www.w3.org/1999/xhtml"; xmlns:epc="http://eprints.org/ep3/control"; xmlns:cite="http://eprints.org/ep3/citation"; >
  <epc:comment>
COMMA SEPARATED LIST OF CREATORS, EDITORS and CORP_CREATORS
  </epc:comment>

  <epc:list join=", ">
    <epc:item><epc:print expr="$item.citation('field_creators')" /></epc:item>
    <epc:item><epc:print expr="$item.citation('field_editors')" /></epc:item>
    <epc:item><epc:print expr="$item.citation('field_corp')" /></epc:item>
  </epc:list>

</cite:citation>

Hopefully this might be useful to some other sites. Tell us if it is.

--
Christopher Gutteridge -- http://users.ecs.soton.ac.uk/cjg

University of Southampton Open Data Service: http://data.southampton.ac.uk/
You should read our Web & Data Innovation blog: http://blogs.ecs.soton.ac.uk/webteam/