> From: Code for Libraries [mailto:[log in to unmask]] On
> Behalf Of Hickey,Thom
> Sent: 10 February, 2006 14:19
> To: [log in to unmask]
> Subject: [CODE4LIB] XSLT for LCCNs
> Anyone have some XSLT that will take arbitrary LCCN's as they
> are stored in MARC and transform them into a nicely
> hyphenated string for display (like in the errol in my signature)?
> --

How about:

<xsl:transform version="2.0"
  exclude-result-prefixes="marc xsl"

    <xsl:output method="text" version="1.0"
      media-type="text/plain" encoding="utf-8"
      omit-xml-declaration="yes" indent="no"

    <xsl:strip-space elements="*"/>

    <xsl:template name="Root" match="/">

      <xsl:for-each select="//marc:record">

        <xsl:variable name="LCCN.record" select="marc:datafield[@tag = '010']/marc:subfield[@code = 'a']"/>

        <xsl:variable name="LCCN.nospace" select="translate($LCCN.record, ' ', '')"/>
        <xsl:variable name="LCCN.length" select="string-length($LCCN.nospace)"/>

        <xsl:variable name="LCCN.display" select="concat(substring($LCCN.nospace, 1, $LCCN.length - 6), '-', substring($LCCN.nospace, $LCCN.length - 5))"/>

        <xsl:value-of select="concat('&#10;', $LCCN.display)"/>


      <xsl:value-of select="string('&#10;')"/>



With the XML:

<?xml version="1.0" encoding="utf-8"?>

<collection xmlns="" xmlns:xsi="" xsi:schemaLocation="">

    <datafield tag="010" ind1=" " ind2=" ">
      <subfield code="a">sj 00001253 </subfield>

    <datafield tag="010" ind1=" " ind2=" ">
      <subfield code="a">sj2005001188</subfield>