« UK holdings | Main | XML and CSS »

Comments

Ed Summers

Neato, this could come in very handy. I'm kind of an XSLT novice so I had never seen JavaScript being referenced in an external file before. Does this require the user run the transformation in a browser, or are there XSLT libs that bundle JavaScript support. I was curious, so I went digging around for js/viaf.js to see what functions in the XSLT it was using but I couldn't seem to find it.

Andrew Houghton

Here is the information on LC's Web site for handling dates in MARC records that contain 2 digit years.

Here is the XSL I use for creating a variable based upon the 008's date created:

<xsl:variable name="date.created">
  <xsl:for-each
    select="marc:controlfield[@tag = '008'][1]">
    <!-- Break apart date created value -->
    <xsl:variable name="year">
      <!--
        One of these days LC will fix the date to be
        Y2K compliant...
        See: http://www.loc.gov/marc/yr2000.html
        -->
      <xsl:choose>
        <!-- Post Y2K date -->
        <xsl:when
          test="number(substring(.,1,2)) &gt;= 0 and
                number(substring(.,1,2)) &lt; 68">
          <xsl:value-of
            select="concat('20',substring(.,1,2))"/>
        </xsl:when>
        <!-- Pre Y2K date -->
        <xsl:otherwise>
          <xsl:value-of
            select="concat('19',substring(.,1,2))"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="month"
      select="substring(.,3,2)"/>
    <xsl:variable name="day"
      select="substring(.,5,2)"/>
    <!-- Build date created from pieces -->
    <xsl:value-of
      select="concat($year,'-',$month,'-',$day)"/>
  </xsl:for-each>
<xsl:variable>
Thom

Including viaf.js was an oversight--the authorities full display doesn't use it at all. It got cut & pasted from the main XSLT script that controls the interface.

All the Javascript calls in the interface are from the generated HTML to the JavaScript (which may then modify the HTML). It's possible to control XSLT from the JavaScript in some browsers, but I haven't tried it.

Thanks for the pointer and code Andy, I'll update the script.

--Th

The comments to this entry are closed.

My Photo

April 2018

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30