kitodo / kitodo-presentation

Kitodo.Presentation is a feature-rich framework for building a METS- or IIIF-based digital library. It is part of the Kitodo Digital Library Suite.
https://kitodo.github.io/kitodo-presentation/
GNU General Public License v3.0
39 stars 45 forks source link

[BUG] Images are not displayed for METS files containing file groups use attribute written lower case #1352

Closed beatrycze-volk closed 1 month ago

beatrycze-volk commented 2 months ago

Description

The images are not displayed if use attribute is written lower case e.g:

<mets:fileGrp use="DEFAULT">
    <mets:file ID="1" MIMETYPE="image/jpeg">
        <mets:FLocat LOCTYPE="URL" xlink:href="https://example.de/img/fullsize/1.jpg"/>
    </mets:file>
</mets:fileGrp>

It works correctly for upper case writing e.g:

<mets:fileGrp USE="DEFAULT">
    <mets:file ID="1" MIMETYPE="image/jpeg">
        <mets:FLocat xlink:href="https://digital.slub-dresden.de/data/kitodo/TheDarea_416971482-19060203/TheDarea_416971482-19060203_tif/jpegs/00000001.tif.medium.jpg" LOCTYPE="URL"/>
    </mets:file>
</mets:fileGrp>

Reproduction

Steps to reproduce the behaviour:

  1. Open any document with lower case writing e.g.: https://dfg-viewer.de/show?tx_dlf[double]=0&tx_dlf[id]=https://alpakatracker.eu/TUBAF_CW_471.xml

Expected Behavior

The letter capitalization in attributes should not matter.

Additional Context

Code causing problems can be found in the class MetsDocument:

          // Build concordance for configured USE attributes.
                foreach ($fileGrps as $fileGrp) {
                    if (in_array((string) $fileGrp['USE'], $useGrps)) {
                        foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) {
                            $fileId = (string) $file->attributes()->ID;
                            $this->fileGrps[$fileId] = (string) $fileGrp['USE'];
                            $this->fileInfos[$fileId] = [
                                'fileGrp' => (string) $fileGrp['USE'],
                                'admId' => (string) $file->attributes()->ADMID,
                                'dmdId' => (string) $file->attributes()->DMDID,
                            ];
                        }
                    }
                }
sebastian-meyer commented 2 months ago

This is not a bug, but intended behavior. XML elements and attributes are always case-sensitive and METS defines this attribute as upper-case (see https://loc.gov/standards/mets/mets.xsd). So having a lower-case USE attribute in a METS file is actually a violation of the METS schema specification and should not be accepted by Kitodo.Presentation.