How to create XSLT for OAI-PMH response?

20 views
Skip to first unread message

Asatur Vardanyan

unread,
Jun 28, 2021, 10:30:19 AMJun 28
to OAI-PMH
Hi. I have a response like this:
<?xml version="1.0" encoding="UTF-8"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>2021-06-24T06:02:01Z</responseDate>
<request verb="ListRecords" metadataPrefix="oai_dc" set="p15869coll19" from="2020-09-01" until="2020-09-30">http://digital.americanancestors.org/oai/oai.php</request>
<ListRecords>
<record>
<header>
<identifier>oai:digital.americanancestors.org:p15869coll19/17</identifier>
<datestamp>2020-09-21</datestamp>
<setSpec>p15869coll19</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Papers of Abraham C. Ratshesky</dc:title>
<dc:identifier>P-586</dc:identifier>
<dc:relation>01</dc:relation>
<dc:relation>01</dc:relation>
<dc:subject>Halifax Explosion, Halifax, N.S. 1917; Massachusetts, General Court. Senate; American Red Cross. Boston Metropolitan Chapter</dc:subject>
<dc:description>Photographs; Morse Family</dc:description>
<dc:rights>Open access</dc:rights>
<dc:rights>User has an obligation to determine copyright or other use restrictions prior to publication or distribution. Please contact the archives at jhcref...@nehgs.org or 617-226-1245 for more information.</dc:rights>
<dc:language>English</dc:language>
<dc:source>Wyner Family Jewish Heritage Center, New England Historic Genealogical Society</dc:source>
<dc:identifier>http://digital.americanancestors.org/cdm/ref/collection/p15869coll19/id/17</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
</ListRecords>
</OAI-PMH>

Is it available to generate an XSL file for this response?

John Salter

unread,
Jun 29, 2021, 4:19:24 AMJun 29
to oai...@googlegroups.com

Hi Asatur,

It looks like your system uses the CONTENTdm platform. I'm not sure if there is a way to specify an XSLT to be included in the output of that platform, but the vendor may be able to assist.

 

If you want to apply an XSLT manually to the response, there is a widely used example here: https://github.com/eprints/eprints3.4/blob/master/lib/static/oai2.xsl which will render the oai_dc metadata profile.

The XSLT has to be saved locally (relative to where you are accessing the XML from), and can be included e.g.:

<?xml version='1.0' encoding='UTF-8'?>

<?xml-stylesheet type='text/xsl' href='/oai2.xsl' ?>

<OAI-PMH… >

</OAI-PMH>

 

Hope that helps,

John

--

---
You received this message because you are subscribed to the Google Groups "OAI-PMH" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oai-pmh+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oai-pmh/0e554e9b-84c9-4174-8343-9f74795b89b3n%40googlegroups.com.

Asatur Vardanyan

unread,
Jun 29, 2021, 5:05:11 AMJun 29
to OAI-PMH
Thank you. I have some resources about my problem.
Here my XML response.

    <responseDate>2021-06-23T16:17:01Z</responseDate>
Here XSLT for the above XML

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        version="2.0"
        xpath-default-namespace="http://www.openarchives.org/OAI/2.0/"
        exclude-result-prefixes="oai_dc dc">

    <xsl:output method="xml" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
        <add>
            <xsl:for-each select="OAI-PMH/ListRecords/record">
                <doc>
                    <field name="id">
                        <xsl:value-of select="header/identifier"/>
                    </field>
                    <field name="tcngrams_title">
                        <xsl:value-of select="metadata/oai_dc:dc/dc:title"/>
                    </field>
                    <field name="tcngrams_content">
                        <xsl:value-of
                                select="string-join((metadata/oai_dc:dc/dc:description, metadata/oai_dc:dc/dc:subject,  metadata/oai_dc:dc/dc:coverage), ' ')"/>
                    </field>
                    <field name="sm_url">
                        <xsl:variable name="delimeter">
                            <xsl:text>,</xsl:text>
                        </xsl:variable>
                        [
                        <xsl:for-each select="metadata/oai_dc:dc/dc:identifier">
                            <xsl:choose>
                                <xsl:when test="starts-with(., 'http://')">
                                    <xsl:value-of select="replace(., 'http://', 'https://')"/>
                                    <xsl:value-of select="$delimeter"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:if test="starts-with(., 'https://')">
                                        <xsl:value-of select="."/>
                                        <xsl:value-of select="$delimeter"/>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                        ]
                    </field>

                    <field name="ds_date_created">
                        <xsl:value-of select="concat(header/datestamp,'T00:00:00Z')"/>
                    </field>
                    <field name="ds_date_updated">
                        <xsl:value-of select="concat(header/datestamp,'T00:00:00Z')"/>
                    </field>
                    <xsl:if test="metadata/oai_dc:dc/dc:type">
                        <field name="ss_category">
                            <xsl:value-of select="metadata/oai_dc:dc/dc:type"/>
                        </field>
                    </xsl:if>
                    <field name="ss_topic">
                        <xsl:for-each select="metadata/oai_dc:dc/dc:subject">
                            <xsl:variable name="subject" select="normalize-space(substring-before(.,'--'))"/>

                            <xsl:choose>
                                <xsl:when test="$subject">
                                    <xsl:value-of select="$subject"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="normalize-space(.)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                    </field>
                    <xsl:if test="metadata/oai_dc:dc/dc:creator">
                        <field name="tcngrams_author_name">
                            <xsl:value-of select="metadata/oai_dc:dc/dc:creator"/>
                        </field>
                    </xsl:if>
                    <field name="sm_source">
                        <xsl:value-of
                                select="string-join((metadata/oai_dc:dc/dc:source, metadata/oai_dc:dc/dc:relation), ' ')"/>
                    </field>

                </doc>
            </xsl:for-each>
        </add>
    </xsl:template>

</xsl:transform>

I missed this line exclude-result-prefixes="oai_dc dc".  So the translator could not understand what is oai_dc and dc.

2021 թ. հունիսի 29, երեքշաբթի-ին ժամը 12:19:24 UTC+4-ին j.sa...@leeds.ac.uk օգտատերը գրել է․
Reply all
Reply to author
Forward
0 new messages