xsltimportfilemakeroai

Importing OAI source into Filemaker


I have a problem with importing an OAI source into Filemaker. The mapping is ok but the result is empty.

This is the source:

<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://dublincore.org/documents/dcmi-namespace/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>2015-01-15T12:05:11Z</responseDate>
<request verb="ListRecords" metadataPrefix="oai_dc">
http://api.memorix-maior.nl/collectiebeheer/oai-pmh/key/SORRY_THIS_KEY_I_CANNOT_SHOW/tenant/nfm
</request>
<ListRecords>
<record>
<header>
<identifier>
e:1d59bf74-a57c-11e1-af90-bf6f69fae6b6:000a80bf-e7d6-7670-b2bd-c269b2e58878
</identifier>

etc.

And this is the xslt I made:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
        <ERRORCODE>0</ERRORCODE>
            <METADATA>
<FIELD NAME="identifier" TYPE="TEXT"/>
            </METADATA>
            <RESULTSET>
            <xsl:for-each select="OAI-PMH/ListRecords/record">
                <ROW>
                    <COL>
                        <DATA><xsl:value-of select="header/identifier"/></DATA>
                    </COL>
                </ROW>
                </xsl:for-each>
            </RESULTSET>
        </FMPXMLRESULT>
    </xsl:template>
</xsl:stylesheet>

To make it clear I only pointed the first field in the OAI source.

I hope you can help me to fix this.

Best regards, Boudewijn Ridder


Solution

  • The reason why your attempt doesn't work is that the source XML nodes are in a namespace. You must declare this namespace in your stylesheet, assign it a prefix and use that prefix when addressing the nodes:

    <xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:oai="http://www.openarchives.org/OAI/2.0/">
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
    
    <xsl:template match="/">
        <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
            <METADATA>
                <FIELD NAME="identifier" TYPE="TEXT"/>
            </METADATA>
            <RESULTSET>
                <xsl:for-each select="oai:OAI-PMH/oai:ListRecords/oai:record">
                    <ROW>
                        <COL>
                            <DATA><xsl:value-of select="oai:header/oai:identifier"/></DATA>
                        </COL>
                    </ROW>
                </xsl:for-each>
            </RESULTSET>
        </FMPXMLRESULT>
    </xsl:template>
    
    </xsl:stylesheet>
    

    Note:
    If your input example is representative, you might want to use :

    <xsl:value-of select="normalize-space(oai:header/oai:identifier)"/>
    

    to trim the extraneous whitespace from the result.