Bug 21472

Summary: Allow linking of $w subfields to 035 or 001+003 using the MarcOrgCode prefix
Product: Koha Reporter: Paul Hoffman <paul>
Component: SearchingAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P3 CC: aholt, bugzilla, heather_hernandez, horganl, katrin.fischer, lauren_denny
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description Paul Hoffman 2018-10-02 15:16:43 UTC
The links that appear under the heading Additional Formats, built using data from 776 fields, are hardcoded to be like this in the OPAC:

    /cgi-bin/koha/opac-search.pl?q=control-number:__________

And like this in the staff interface:

    /cgi-bin/koha/catalogue/search.pl?q=control-number:__________

The blanks are filled in with the contents of the 776 field, subfield $w, with any parenthesized organization code stripped.  Thus, for example, a 776 field like this:

    776 08 $i Online version: [...] $z 9781938168000 $w (OCoLC)895896190

Would yield a staff URL like this:

    /cgi-bin/koha/opac-search.pl?q=control-number:895896190

But that link won't work, at least not in our case; control numbers found in 035 $a are indexed as other-control-number, not control-number, and the organization code is not stripped when indexing.  However, a link like this does retrieve the bib record with the 776 field given above:

    /cgi-bin/koha/catalogue/search.pl?idx=other-control-number,phr&q=(OCoLC)895896190

These links are built in /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl (lines 808 ff.) and /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl (lines 756 ff.); for example, the latter looks like this:

    <!-- MARC21 776 Additional Physical Form Entry -->
        <xsl:if test="marc:datafield[@tag=776]">
            <span class="results_summary add_physical_form">
                <span class="label">Additional physical formats: </span>
                <xsl:for-each select="marc:datafield[@tag=776]">
                    <xsl:variable name="linktext">
                        <xsl:choose>
                        <xsl:when test="marc:subfield[@code='t']">
                            <xsl:value-of select="marc:subfield[@code='t']"/>
                        </xsl:when>
                        <xsl:when test="marc:subfield[@code='a']">
                            <xsl:value-of select="marc:subfield[@code='a']"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>No title</xsl:text>
                        </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:if test="@ind2=8 and marc:subfield[@code='i']">
                        <xsl:call-template name="subfieldSelect">
                            <xsl:with-param name="codes">i</xsl:with-param>
                        </xsl:call-template>
                        <xsl:text>: </xsl:text>
                    </xsl:if>
                    <xsl:choose>
                    <xsl:when test="marc:subfield[@code='w']">
                        <a>
                        <xsl:attribute name="href">
                            <xsl:text>/cgi-bin/koha/catalogue/search.pl?q=control-number:</xsl:text>
                            <xsl:call-template name="extractControlNumber">
                                <xsl:with-param name="subfieldW">
                                    <xsl:value-of select="marc:subfield[@code='w']"/>
                                </xsl:with-param>
                            </xsl:call-template>
                        </xsl:attribute>
                        <xsl:value-of select="$linktext"/>
                        </a>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$linktext"/>
                    </xsl:otherwise>
                    </xsl:choose>
                    <xsl:if test="position() != last()">
                        <xsl:text>; </xsl:text>
                    </xsl:if>
                </xsl:for-each>
            </span>
        </xsl:if>

The template "extractControlNumber" extracts the control number (minus parenthesized prefix) from the value in 776 $w.  Unfortunately, this template is used elsewhere so I'm not sure it's safe to change it so that it does *not* strip the parenthesized prefix.  Perhaps we could add a second parameter to it that specifies whether or not to strip it, with the default set to true.
Comment 1 Katrin Fischer 2018-10-03 13:56:53 UTC
I think the oversight here might be that the $w should only be used for linking when the system preference UseControlNumber is used.

But according to standard, it should be 001 > $w, not 035 (sorry).
Comment 2 Katrin Fischer 2018-10-03 14:17:12 UTC
> But according to standard, it should be 001 > $w, not 035 (sorry).
Actually... that's what I am told, but the documentation is not very clear about it.
Comment 3 Paul Hoffman 2018-10-03 15:57:52 UTC
I'm not sure I understand your comments, Katrina; it sounds like you see some specific flaw in my bug report, but it's not clear to me what that is -- would you mind clarifying?

FWIW, 776 $w is described thus in the documentation of the 76X-78X fields <URL:http://www.loc.gov/marc/bibliographic/bd76x78x.html>:

------------------------------------------------------------------------
$w - Record control number

System control number of the related record preceded by the MARC code, enclosed in parentheses, for the agency to which the control number applies. See Appendix I: Organization Code Sources for a listing of sources used in MARC 21 records.

780 	00$tTechniques of biochemical and biophysical morphology$w(DLC)###72000153#$w(OCoLC)1021945
780 	00$tReview of existential psychology & psychiatry$w(DLC)sf#77000170#
785 	17$tAdult correctional services in Canada$w(CaOONL)840790694E
------------------------------------------------------------------------

Without the parenthesized agency code, the remaining contents of $w are not a complete, unambiguous reference to a related record.

Sorry if I'm misunderstanding, but it does seem to me that the "Additional Formats" URLs built by the XSLT code should include the parenthesized agency code.

Also, I would say that 003 (with parentheses) concatenated with 001 are equivalent in form to the contents of 035 $a -- lots of records will look like this:

    001 1234567
    003 OCoLC
    ...

But in practice we prefer this, because some ILSes (including one of the two we host) use 001 to hold the system-generated record ID, and so move any existing 003 and 001 into a (new) 035 field.  So a record like the one referred to above would import like this:

    001 88888
    [003 absent, or set to the local agency code]
    035 ## $a (OCoLC)1234567

Also, I suspect (but could be wrong!) that Zebra doesn't index 003 + 001 the way it indexes 035 $a.

Paul.
Comment 4 Laura Horgan 2020-02-11 20:47:44 UTC
The marc tags for 776 |w are usually coming from OCLC and not something that is created by our librarians.  I think the |w is looking for additional records within the KOHA system and we could use the |w for this if appropriate.  When however, you want to send the patron out of the system I think the only way to do this would be to add a KOHA specific code that would allow you to include a link outside the catalog.
Comment 5 Katrin Fischer 2020-02-11 21:02:36 UTC
(In reply to Laura Horgan from comment #4)
> The marc tags for 776 |w are usually coming from OCLC and not something that
> is created by our librarians.  I think the |w is looking for additional
> records within the KOHA system and we could use the |w for this if
> appropriate.  When however, you want to send the patron out of the system I
> think the only way to do this would be to add a KOHA specific code that
> would allow you to include a link outside the catalog.

Hi Laura, if you don't want Koha to use the $w you can set the UseControlNumber preference accordingly. In our union catalog $w is also used for linking records, but when the linked record is also in Koha, the link works correctly. An example would be a 773$w => 001 link for an analytical and a serial record.

At the moment this will only work, if you have 1 $w matching the 001 of another record. It could be discussed, how to improve this further. When I 'built' it, it was certainly influenced by the MARC records I knew from our environment and how I read the standard, but since I have been wondering :)

We could also imagine changing the control-number search to a other-control-number search - this could be tested easily with jQuery and if it works better turned into a preference.
Comment 6 Heather 2020-02-14 17:02:46 UTC
The 035 is a repeatable field, so especially among OCLC users, there can be many 035 fields with record numbers from various systems that have had (or still have) versions of the record.  The 001 field is *not* repeatable, so is commonly used by OCLC users as the current, unique OCLC record number.

ByWater has done a lot of work for us to get our 7XX $w linking entry fields to work as a hyperlink to execute a search on the 001 (OCLC number) of the target record in our catalog, https://keys.bywatersolutions.com/ 
Liz Rea is the latest person that we worked with on it (c.f. ByWater support ticket #45916)--perhaps that work can be contributed to the community?
Comment 7 Laura Horgan 2020-11-12 14:39:24 UTC
I have had difficulty making this work even when trying to link to the 001 in our system.  Would it be possible to point out documentation that details how this would work.  I am particularly interested in having these fields in place when cataloging an ebook when a book is also available in our system.
Comment 8 Katrin Fischer 2021-03-07 13:28:35 UTC
(In reply to Laura Horgan from comment #7)
> I have had difficulty making this work even when trying to link to the 001
> in our system.  Would it be possible to point out documentation that details
> how this would work.  I am particularly interested in having these fields in
> place when cataloging an ebook when a book is also available in our system.

Please see here and especially the other pages linked at the top and bottom of the page: https://wiki.koha-community.org/wiki/Serial_Analytics

I am changing the bug title a little bit as what we discussed here does not only apply to 776, but to the general linking mechanism Koha supports for 7xx fields right now.

To summarize a little:

IS:
Koha currently supports linking by ID between a singular $w subfield and 001 of another record. 003 and 035 are not taken into account.

TO BE DISCUSSED:
- Allow linking of $w and 035 of another record using the prefix
- Make the linking more specific by using the prefix and 001+003
- Take care of repeating $w (which $w should be used for searching the right link?)

I think here (Germany) the expectation would not be to link to another source, but the $w are used to built hierarchies between the records within the catalog. Cataloging in hierarchies (set records and volumes for examples) is the norm here, so the initial goal was to make these hierarchies visible and allow navigating them.

@Heather Could you give some examples from your catalog?
Comment 9 Heather 2021-03-08 16:58:04 UTC
Hi, Katrin!

We have many examples, including:

https://keys.bywatersolutions.com/cgi-bin/koha/opac-detail.pl?biblionumber=16157

https://keys.bywatersolutions.com/cgi-bin/koha/opac-detail.pl?biblionumber=15291

https://keys.bywatersolutions.com/cgi-bin/koha/opac-detail.pl?biblionumber=31840

Let me know if any other specific 7XX example is needed, and I can mock up something.

Cheerio!
h2