0

我在将 OAI 源导入 Filemaker 时遇到问题。映射正常,但结果为空。

这是来源:

<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>

等等

这是我制作的 xslt:

<?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>

为了清楚起见,我只指出了 OAI 源代码中的第一个字段。

我希望你能帮我解决这个问题。

最好的问候, Boudewijn Ridder

4

1 回答 1

1

您的尝试不起作用的原因是源 XML 节点位于namespace中。您必须在样式表中声明此命名空间,为其分配前缀并在寻址节点时使用该前缀:

<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>

注意
如果您的输入示例具有代表性,您可能希望使用:

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

从结果中修剪多余的空白。

于 2015-01-15T11:45:21.893 回答