Tweak MODS32 stylesheet for titles
authorDan Wells <dbw2@calvin.edu>
Mon, 7 Oct 2013 21:22:42 +0000 (17:22 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 10 Oct 2013 21:11:07 +0000 (17:11 -0400)
<titleNonfiling> was added to help certain search cases, but trailing
punctuation makes it unsuitable for display.  <titleInfo>, on the other
hand, chops all trailing punctuation out, which helps the trailing case
but actually makes display of subtitle information worse.  Let's split
the difference and simplify at the same time by building the whole
title, then trimming extra punctuation.

While the above was done to help in browse display, it turns out that
<titleNonfiling> is not able to generate correct browse data.  We want
the display as corrected above, but we also need to preserve the
<nonSort> tag for proper browse sorting.

Rather than complicate the metabib logic, we'll add another special-
purpose field to the MODS called <titleBrowse>. This field is a hybrid
of <titleInfo> and <titleNonfiling>, which will give us a preformatted
string (for preserving needed punctuation) but also keep the <nonSort>
stuff in a separate field (for sorting).

NOTE: We are purposely ignoring similar changes to MODS33, pending
a discussion of how best to handle EG specific MODS changes overall.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/sql/Pg/953.data.MODS32-xsl.sql
Open-ILS/xsl/MARC21slim2MODS32.xsl

index f615039..69b4ce6 100644 (file)
@@ -133,39 +133,46 @@ Added Log Comment
                        <!-- A form of title that ignores non-filing characters; useful
                                 for not converting "L'Oreal" into "L' Oreal" at index time -->
                        <titleNonfiling>
-                               <xsl:variable name="title">
-                                       <xsl:choose>
-                                               <xsl:when test="marc:subfield[@code='b']">
-                                                       <xsl:call-template name="specialSubfieldSelect">
-                                                               <xsl:with-param name="axis">b</xsl:with-param>
-                                                               <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:when>
-                                               <xsl:otherwise>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
                                                        <xsl:call-template name="subfieldSelect">
                                                                <xsl:with-param name="codes">abfgk</xsl:with-param>
                                                        </xsl:call-template>
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                               </xsl:variable>
-                               <title>
-                                       <xsl:value-of select="$title"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
                                </title>
-                               <xsl:if test="marc:subfield[@code='b']">
-                                       <subTitle>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:call-template name="specialSubfieldSelect">
-                                                                       <xsl:with-param name="axis">b</xsl:with-param>
-                                                                       <xsl:with-param name="anyCodes">b</xsl:with-param>
-                                                                       <xsl:with-param name="afterCodes">afgk</xsl:with-param>
-                                                               </xsl:call-template>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
-                                       </subTitle>
-                               </xsl:if>
                                <xsl:call-template name="part"></xsl:call-template>
                        </titleNonfiling>
+                       <!-- hybrid of titleInfo and titleNonfiling which will give us a preformatted string (for punctuation)
+                                but also keep the nonSort stuff in a separate field (for sorting) -->
+                       <titleBrowse>
+                               <xsl:variable name="titleBrowseChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">abfgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
+                               <xsl:choose>
+                                       <xsl:when test="@ind2>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleBrowseChop,1,@ind2)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleBrowseChop,@ind2+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleBrowseChop"/>
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"></xsl:call-template>
+                       </titleBrowse>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='210']">
                        <titleInfo type="abbreviated">
index 3302213..2595e16 100644 (file)
@@ -133,39 +133,46 @@ Added Log Comment
                        <!-- A form of title that ignores non-filing characters; useful
                                 for not converting "L'Oreal" into "L' Oreal" at index time -->
                        <titleNonfiling>
-                               <xsl:variable name="title">
-                                       <xsl:choose>
-                                               <xsl:when test="marc:subfield[@code='b']">
-                                                       <xsl:call-template name="specialSubfieldSelect">
-                                                               <xsl:with-param name="axis">b</xsl:with-param>
-                                                               <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
-                                                       </xsl:call-template>
-                                               </xsl:when>
-                                               <xsl:otherwise>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
                                                        <xsl:call-template name="subfieldSelect">
                                                                <xsl:with-param name="codes">abfgk</xsl:with-param>
                                                        </xsl:call-template>
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                               </xsl:variable>
-                               <title>
-                                       <xsl:value-of select="$title"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
                                </title>
-                               <xsl:if test="marc:subfield[@code='b']">
-                                       <subTitle>
-                                               <xsl:call-template name="chopPunctuation">
-                                                       <xsl:with-param name="chopString">
-                                                               <xsl:call-template name="specialSubfieldSelect">
-                                                                       <xsl:with-param name="axis">b</xsl:with-param>
-                                                                       <xsl:with-param name="anyCodes">b</xsl:with-param>
-                                                                       <xsl:with-param name="afterCodes">afgk</xsl:with-param>
-                                                               </xsl:call-template>
-                                                       </xsl:with-param>
-                                               </xsl:call-template>
-                                       </subTitle>
-                               </xsl:if>
                                <xsl:call-template name="part"></xsl:call-template>
                        </titleNonfiling>
+                       <!-- hybrid of titleInfo and titleNonfiling which will give us a preformatted string (for punctuation)
+                                but also keep the nonSort stuff in a separate field (for sorting) -->
+                       <titleBrowse>
+                               <xsl:variable name="titleBrowseChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">abfgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
+                               <xsl:choose>
+                                       <xsl:when test="@ind2>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleBrowseChop,1,@ind2)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleBrowseChop,@ind2+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleBrowseChop"/>
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:call-template name="part"></xsl:call-template>
+                       </titleBrowse>
                </xsl:for-each>
                <xsl:for-each select="marc:datafield[@tag='210']">
                        <titleInfo type="abbreviated">