26 Septembris 2007

Conundrum du jour: mixing elements and qualifiers in Manakin

So one of the problems with DSpace in both its JSP and Manakin incarnations is that authors get lumped together with editors, translators, advisors, and many other sorts of contributors in a number of the displays. This is confusing at best and outright wrong at worst. I promised several of my colleagues that I’d fix that in Manakin.

I’m trying to start slowly here, with the simple display of titles and authors found in (for example) the Recent Submissions section on community and collection pages. Found that bit (and let me congratulate the Manakin devs on the nice, sensible display choices here):

        <div class="artifact-title">
            <a>
                <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
                <xsl:choose>
                    <xsl:when test="$data/dc:title">
                        <xsl:copy-of select="$data/dc:title[1]/child::node()”/>
                    </xsl:when>
                    <xsl:otherwise>
                        <i18n:text>xmlui.dri2xhtml.METS-1.0.no-title</i18n:text>
                    </xsl:otherwise>
                </xsl:choose>
            </a>
        </div>
        <div class=”artifact-info”>
            <xsl:choose>
                <xsl:when test=”$data/dc:contributor”>
                    <xsl:copy-of select=”$data/dc:contributor[1]/child::node()”/>
                </xsl:when>
                <xsl:otherwise>
                    <i18n:text>xmlui.dri2xhtml.METS-1.0.no-author</i18n:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text> </xsl:text>
            <span class=”date”>(<xsl:copy-of select=”substring($data/dcterms:issued/child::node(),1,10)”/>)</span>
        </div>

So, okay, for title we’re grabbing the first dc:title element, and for author we’re grabbing the first contributor element regardless of its qualifier (which is the problem that I want to fix), and for date we’re going straight to something (element unimportant, as I read it) with a qualifier of “issued”.

Huh. So if I read this right, we’re assuming that no two DC elements happen to have the same qualifier for any reason. I suspect that works out fine in practice (though what about dc.contributor and dc.creator?), but it seems, well, brittle. Hacky. Kludgy.

What I don’t quite see how to do is create an XPath that takes both element and qualifier into account, since they’re in different namespaces and may not have any structural relationship to each other. (Where’s the documentation on this particular METS profile, anyway?) Anybody got a brilliant answer?