Extensions to our MODS32 stylesheet to capture all possible NFI in fields
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 13 May 2013 20:14:37 +0000 (16:14 -0400)
committerBen Shum <bshum@biblio.org>
Mon, 15 Jul 2013 15:45:23 +0000 (11:45 -0400)
MODS 3 reacts to non-filing indicators only in the 245 field.  This
gives us extra output nodes from which we can get better-sorted headings
from fields 130, 242, 440, 630, 730, 740, and 830.

We also update the index definitions for seriestitle, alternative title,
transalted title, and uniform title to use the
leading-articles-stripped-by-NFI versions of the headings for browse.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/953.data.MODS32-xsl.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib-auth-browse.sql

index 94b4b52..5b9f1a3 100644 (file)
@@ -110,17 +110,17 @@ INSERT INTO config.xml_transform VALUES ( 'mods33', 'http://www.loc.gov/mods/v3'
 INSERT INTO config.xml_transform VALUES ( 'marc21expand880', 'http://www.loc.gov/MARC21/slim', 'marc', '' );
 
 -- Index Definitions
-INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_field, authority_xpath ) VALUES 
-    (1, 'series', 'seriestitle', oils_i18n_gettext(1, 'Series Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:relatedItem[@type="series"]/mods32:titleInfo$$, TRUE, '//@xlink:href' );
+INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_field, authority_xpath, browse_xpath ) VALUES 
+    (1, 'series', 'seriestitle', oils_i18n_gettext(1, 'Series Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:relatedItem[@type="series"]/mods32:titleInfo[@type="nfi"]$$, TRUE, '//@xlink:href', $$//*/*[local-name() != "nonSort"]$$ ); -- vim */
 
 INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath ) VALUES 
     (2, 'title', 'abbreviated', oils_i18n_gettext(2, 'Abbreviated Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='abbreviated')]$$, '//@xlink:href' );
-INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath ) VALUES 
-    (3, 'title', 'translated', oils_i18n_gettext(3, 'Translated Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='translated')]$$, '//@xlink:href' );
-INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath ) VALUES 
-    (4, 'title', 'alternative', oils_i18n_gettext(4, 'Alternate Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='alternative')]$$, '//@xlink:href' );
-INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath ) VALUES 
-    (5, 'title', 'uniform', oils_i18n_gettext(5, 'Uniform Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform')]$$, '//@xlink:href' );
+INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_xpath ) VALUES 
+    (3, 'title', 'translated', oils_i18n_gettext(3, 'Translated Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='translated-nfi')]$$, '//@xlink:href', $$//*/*[local-name() != "nonSort"]$$ ); -- vim */
+INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_xpath ) VALUES 
+    (4, 'title', 'alternative', oils_i18n_gettext(4, 'Alternate Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='alternative-nfi')]$$, '//@xlink:href', $$//*/*[local-name() != "nonSort"]$$ ); -- vim */
+INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_xpath ) VALUES 
+    (5, 'title', 'uniform', oils_i18n_gettext(5, 'Uniform Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform-nfi')]$$, '//@xlink:href', $$//*/*[local-name() != "nonSort"]$$ ); -- vim */
 INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_field ) VALUES 
     (6, 'title', 'proper', oils_i18n_gettext(6, 'Title Proper', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$, '//@xlink:href', FALSE );
 
index 542440a..d5486c5 100644 (file)
@@ -182,6 +182,16 @@ Added Log Comment
                        </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='242']">
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <!-- 1/04 removed $h, b -->
+                                                       <xsl:with-param name="codes">a</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo type="translated">
                                <!--09/01/04 Added subfield $y-->
                                <xsl:for-each select="marc:subfield[@code='y']">
@@ -190,19 +200,36 @@ Added Log Comment
                                        </xsl:attribute>
                                </xsl:for-each>
                                <title>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:call-template name="subfieldSelect">
-                                                               <!-- 1/04 removed $h, b -->
-                                                               <xsl:with-param name="codes">a</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
+                                       <xsl:value-of select="$titleChop" />
                                </title>
                                <!-- 1/04 fix -->
                                <xsl:call-template name="subtitle"/>
                                <xsl:call-template name="part"/>
                        </titleInfo>
+                       <titleInfo type="translated-nfi">
+                               <xsl:for-each select="marc:subfield[@code='y']">
+                                       <xsl:attribute name="lang">
+                                               <xsl:value-of select="text()"/>
+                                       </xsl:attribute>
+                               </xsl:for-each>
+                               <xsl:choose>
+                                       <xsl:when test="@ind2>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop" />
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="subtitle"/>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='246']">
                        <titleInfo type="alternative">
@@ -226,39 +253,91 @@ Added Log Comment
                        </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
+                       <xsl:variable name="nfi">
+                               <xsl:choose>
+                                       <xsl:when test="@tag='240'">
+                                               <xsl:value-of select="@ind2"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of select="@ind1"/>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </xsl:variable>
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="uri" />
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield">
+                                               <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
+                                                       <xsl:value-of select="text()"/>
+                                                       <xsl:text> </xsl:text>
+                                               </xsl:if>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo type="uniform">
                                <title>
-                                       <xsl:call-template name="uri" />
-                                       <xsl:variable name="str">
-                                               <xsl:for-each select="marc:subfield">
-                                                       <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
-                                                               <xsl:value-of select="text()"/>
-                                                               <xsl:text> </xsl:text>
-                                                       </xsl:if>
-                                               </xsl:for-each>
-                                       </xsl:variable>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
+                                       <xsl:value-of select="$titleChop"/>
                                </title>
                                <xsl:call-template name="part"/>
                        </titleInfo>
+                       <titleInfo type="uniform-nfi">
+                               <xsl:choose>
+                                       <xsl:when test="$nfi>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,$nfi)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,$nfi+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop"/>
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">ah</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo type="alternative">
                                <title>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:call-template name="subfieldSelect">
-                                                               <xsl:with-param name="codes">ah</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
+                                       <xsl:value-of select="$titleChop" />
                                </title>
                                <xsl:call-template name="part"/>
                        </titleInfo>
+                       <titleInfo type="alternative-nfi">
+                               <xsl:choose>
+                                       <xsl:when test="@ind1>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind1)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind1+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop" />
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='100']">
                        <name type="personal">
@@ -1591,18 +1670,40 @@ Added Log Comment
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag=440]">
                        <relatedItem type="series">
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">av</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
                                <titleInfo>
                                        <title>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:call-template name="subfieldSelect">
-                                                                       <xsl:with-param name="codes">av</xsl:with-param>
-                                                               </xsl:call-template>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
+                                               <xsl:value-of select="$titleChop" />
                                        </title>
                                        <xsl:call-template name="part"></xsl:call-template>
                                </titleInfo>
+                               <titleInfo type="nfi">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind2>0">
+                                                       <nonSort>
+                                                               <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                                       </nonSort>
+                                                       <title>
+                                                               <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                                       </title>
+                                                       <xsl:call-template name="part"/>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <title>
+                                                               <xsl:value-of select="$titleChop" />
+                                                       </title>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
                        </relatedItem>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
@@ -1788,16 +1889,37 @@ Added Log Comment
                <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
                        <relatedItem>
                                <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
                                <titleInfo>
                                        <title>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
+                                               <xsl:value-of select="$titleChop" />
                                        </title>
                                        <xsl:call-template name="part"></xsl:call-template>
                                </titleInfo>
+                               <titleInfo type="nfi">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind1>0">
+                                                       <nonSort>
+                                                               <xsl:value-of select="substring($titleChop,1,@ind1)"/>
+                                                       </nonSort>
+                                                       <title>
+                                                               <xsl:value-of select="substring($titleChop,@ind1+1)"/>
+                                                       </title>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <title>
+                                                               <xsl:value-of select="$titleChop" />
+                                                       </title>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
                                <xsl:call-template name="relatedForm"></xsl:call-template>
                        </relatedItem>
                </xsl:for-each>
@@ -1951,18 +2073,39 @@ Added Log Comment
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='830']">
                        <relatedItem type="series">
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
                                <titleInfo>
                                        <title>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:call-template name="subfieldSelect">
-                                                                       <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
-                                                               </xsl:call-template>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
+                                               <xsl:value-of select="$titleChop" />
                                        </title>
                                        <xsl:call-template name="part"/>
                                </titleInfo>
+                               <titleInfo type="nfi">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind2>0">
+                                                       <nonSort>
+                                                               <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                                       </nonSort>
+                                                       <title>
+                                                               <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                                       </title>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <title>
+                                                               <xsl:value-of select="$titleChop" />
+                                                       </title>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
                                <xsl:call-template name="relatedForm"/>
                        </relatedItem>
                </xsl:for-each>
@@ -2695,17 +2838,39 @@ Added Log Comment
        <xsl:template match="marc:datafield[@tag=630]">
                <subject>
                        <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">adfhklor</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo>
                                <title>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:call-template name="subfieldSelect">
-                                                               <xsl:with-param name="codes">adfhklor</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
-                                       <xsl:call-template name="part"></xsl:call-template>
+                                       <xsl:value-of select="$titleChop" />
                                </title>
+                               <xsl:call-template name="part"></xsl:call-template>
+                       </titleInfo>
+                       <titleInfo type="nfi">
+                               <xsl:choose>
+                                       <xsl:when test="@ind1>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind1)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind1+1)"/>
+                                               </title>
+                                               <xsl:call-template name="part"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop" />
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"></xsl:call-template>
                        </titleInfo>
                        <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
                </subject>
index 5e6379b..3ecf6b2 100644 (file)
@@ -23,15 +23,15 @@ UPDATE config.metabib_field
         field_class IN ('subject','series','title','author') AND
         browse_field IS TRUE;
 
-INSERT INTO config.metabib_field (
-    id, field_class, name, label, xpath, format,
-    search_field, facet_field, browse_field
-) VALUES (
-    31, 'title', 'browse',
-    oils_i18n_gettext(31, 'Title Proper (Browse)', 'cmf', 'label'),
-    $$//mods32:mods/mods32:titleInfo[not (@type)]/mods32:title$$,
-    'mods32', FALSE, FALSE, TRUE
-);
+-- INSERT INTO config.metabib_field (
+--     id, field_class, name, label, xpath, format,
+--     search_field, facet_field, browse_field
+-- ) VALUES (
+--     31, 'title', 'browse',
+--     oils_i18n_gettext(31, 'Title Proper (Browse)', 'cmf', 'label'),
+--     $$//mods32:mods/mods32:titleInfo[not (@type)]/mods32:title$$,
+--     'mods32', FALSE, FALSE, TRUE
+-- );
 
 ALTER TYPE metabib.field_entry_template ADD ATTRIBUTE authority BIGINT;
 
@@ -454,6 +454,16 @@ Added Log Comment
                        </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='242']">
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <!-- 1/04 removed $h, b -->
+                                                       <xsl:with-param name="codes">a</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo type="translated">
                                <!--09/01/04 Added subfield $y-->
                                <xsl:for-each select="marc:subfield[@code='y']">
@@ -462,19 +472,36 @@ Added Log Comment
                                        </xsl:attribute>
                                </xsl:for-each>
                                <title>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:call-template name="subfieldSelect">
-                                                               <!-- 1/04 removed $h, b -->
-                                                               <xsl:with-param name="codes">a</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
+                                       <xsl:value-of select="$titleChop" />
                                </title>
                                <!-- 1/04 fix -->
                                <xsl:call-template name="subtitle"/>
                                <xsl:call-template name="part"/>
                        </titleInfo>
+                       <titleInfo type="translated-nfi">
+                               <xsl:for-each select="marc:subfield[@code='y']">
+                                       <xsl:attribute name="lang">
+                                               <xsl:value-of select="text()"/>
+                                       </xsl:attribute>
+                               </xsl:for-each>
+                               <xsl:choose>
+                                       <xsl:when test="@ind2>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop" />
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="subtitle"/>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='246']">
                        <titleInfo type="alternative">
@@ -498,39 +525,91 @@ Added Log Comment
                        </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
+                       <xsl:variable name="nfi">
+                               <xsl:choose>
+                                       <xsl:when test="@tag='240'">
+                                               <xsl:value-of select="@ind2"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of select="@ind1"/>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </xsl:variable>
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="uri" />
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield">
+                                               <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
+                                                       <xsl:value-of select="text()"/>
+                                                       <xsl:text> </xsl:text>
+                                               </xsl:if>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo type="uniform">
                                <title>
-                                       <xsl:call-template name="uri" />
-                                       <xsl:variable name="str">
-                                               <xsl:for-each select="marc:subfield">
-                                                       <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
-                                                               <xsl:value-of select="text()"/>
-                                                               <xsl:text> </xsl:text>
-                                                       </xsl:if>
-                                               </xsl:for-each>
-                                       </xsl:variable>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
+                                       <xsl:value-of select="$titleChop"/>
                                </title>
                                <xsl:call-template name="part"/>
                        </titleInfo>
+                       <titleInfo type="uniform-nfi">
+                               <xsl:choose>
+                                       <xsl:when test="$nfi>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,$nfi)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,$nfi+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop"/>
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">ah</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo type="alternative">
                                <title>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:call-template name="subfieldSelect">
-                                                               <xsl:with-param name="codes">ah</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
+                                       <xsl:value-of select="$titleChop" />
                                </title>
                                <xsl:call-template name="part"/>
                        </titleInfo>
+                       <titleInfo type="alternative-nfi">
+                               <xsl:choose>
+                                       <xsl:when test="@ind1>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind1)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind1+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop" />
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='100']">
                        <name type="personal">
@@ -1863,18 +1942,40 @@ Added Log Comment
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag=440]">
                        <relatedItem type="series">
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">av</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
                                <titleInfo>
                                        <title>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:call-template name="subfieldSelect">
-                                                                       <xsl:with-param name="codes">av</xsl:with-param>
-                                                               </xsl:call-template>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
+                                               <xsl:value-of select="$titleChop" />
                                        </title>
                                        <xsl:call-template name="part"></xsl:call-template>
                                </titleInfo>
+                               <titleInfo type="nfi">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind2>0">
+                                                       <nonSort>
+                                                               <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                                       </nonSort>
+                                                       <title>
+                                                               <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                                       </title>
+                                                       <xsl:call-template name="part"/>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <title>
+                                                               <xsl:value-of select="$titleChop" />
+                                                       </title>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
                        </relatedItem>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
@@ -2060,16 +2161,37 @@ Added Log Comment
                <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
                        <relatedItem>
                                <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
                                <titleInfo>
                                        <title>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
+                                               <xsl:value-of select="$titleChop" />
                                        </title>
                                        <xsl:call-template name="part"></xsl:call-template>
                                </titleInfo>
+                               <titleInfo type="nfi">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind1>0">
+                                                       <nonSort>
+                                                               <xsl:value-of select="substring($titleChop,1,@ind1)"/>
+                                                       </nonSort>
+                                                       <title>
+                                                               <xsl:value-of select="substring($titleChop,@ind1+1)"/>
+                                                       </title>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <title>
+                                                               <xsl:value-of select="$titleChop" />
+                                                       </title>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
                                <xsl:call-template name="relatedForm"></xsl:call-template>
                        </relatedItem>
                </xsl:for-each>
@@ -2223,18 +2345,39 @@ Added Log Comment
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='830']">
                        <relatedItem type="series">
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
                                <titleInfo>
                                        <title>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:call-template name="subfieldSelect">
-                                                                       <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
-                                                               </xsl:call-template>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
+                                               <xsl:value-of select="$titleChop" />
                                        </title>
                                        <xsl:call-template name="part"/>
                                </titleInfo>
+                               <titleInfo type="nfi">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind2>0">
+                                                       <nonSort>
+                                                               <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                                       </nonSort>
+                                                       <title>
+                                                               <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                                       </title>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <title>
+                                                               <xsl:value-of select="$titleChop" />
+                                                       </title>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
                                <xsl:call-template name="relatedForm"/>
                        </relatedItem>
                </xsl:for-each>
@@ -2967,17 +3110,39 @@ Added Log Comment
        <xsl:template match="marc:datafield[@tag=630]">
                <subject>
                        <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <xsl:variable name="titleChop">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">adfhklor</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
                        <titleInfo>
                                <title>
-                                       <xsl:call-template name="chopPunctuation">
-                                               <xsl:with-param name="chopString">
-                                                       <xsl:call-template name="subfieldSelect">
-                                                               <xsl:with-param name="codes">adfhklor</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:with-param>
-                                       </xsl:call-template>
-                                       <xsl:call-template name="part"></xsl:call-template>
+                                       <xsl:value-of select="$titleChop" />
                                </title>
+                               <xsl:call-template name="part"></xsl:call-template>
+                       </titleInfo>
+                       <titleInfo type="nfi">
+                               <xsl:choose>
+                                       <xsl:when test="@ind1>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind1)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind1+1)"/>
+                                               </title>
+                                               <xsl:call-template name="part"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop" />
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"></xsl:call-template>
                        </titleInfo>
                        <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
                </subject>
@@ -7148,4 +7313,32 @@ BEGIN
 END;
 $p$ LANGUAGE PLPGSQL;
 
+UPDATE config.metabib_field
+SET
+    xpath = $$//mods32:mods/mods32:relatedItem[@type="series"]/mods32:titleInfo[@type="nfi"]$$,
+    browse_xpath = $$//*/*[local-name() != "nonSort"]$$   -- vim highlighting */
+WHERE
+    field_class = 'series' AND name = 'seriestitle' ;
+
+UPDATE config.metabib_field
+SET
+    xpath = $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='alternative-nfi')]$$,
+    browse_xpath = $$//*/*[local-name() != "nonSort"]$$   -- vim highlighting */
+WHERE
+    field_class = 'title' AND name = 'alternative' ;
+
+UPDATE config.metabib_field
+SET
+    xpath = $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform-nfi')]$$,
+    browse_xpath = $$//*/*[local-name() != "nonSort"]$$   -- vim highlighting */
+WHERE
+    field_class = 'title' AND name = 'uniform' ;
+
+UPDATE config.metabib_field
+SET
+    xpath = $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='translated-nfi')]$$,
+    browse_xpath = $$//*/*[local-name() != "nonSort"]$$   -- vim highlighting */
+WHERE
+    field_class = 'title' AND name = 'translated' ;
+
 COMMIT;