OAI - resumption Token - xsl:iterate
Posted: Tue Dec 05, 2023 4:34 pm
Hello!
I am processing data records from an OAI interface such as https://services.dnb.de/oai/repository? ... 2023-12-01 .
The individual record elements must be processed after a Catalog title is established.
At the end of the list is a resumptionToken, which can be used to call the next page of the result query. ( ) (https://www.dnb.de/EN/Professionell/Met ... 2_akk.html )
How can I use xsl:iterate to build a query that retrieves all pages with the new resumptionToken?
Here is a rough draft:
How can I iterate with the resumption tokens?
Thanks for your help!
I am processing data records from an OAI interface such as https://services.dnb.de/oai/repository? ... 2023-12-01 .
The individual record elements must be processed after a Catalog title is established.
At the end of the list is a resumptionToken, which can be used to call the next page of the result query. ( ) (https://www.dnb.de/EN/Professionell/Met ... 2_akk.html )
How can I use xsl:iterate to build a query that retrieves all pages with the new resumptionToken?
Here is a rough draft:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="3.0" xmlns:oai="http://www.openarchives.org/OAI/2.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="no" encoding="UTF-8"/>
<xsl:param name="param-uri-file-source" select="'https://services.dnb.de/oai/repository?verb=ListRecords&metadataPrefix=oai_dc'"/>
<xsl:variable name="file-source">
<xsl:choose>
<xsl:when test="doc-available($param-uri-file-source)">
<xsl:copy-of select="doc($param-uri-file-source)"/>
</xsl:when>
<xsl:when test="starts-with($param-uri-file-source,'http')">
<xsl:variable name="http">
<xsl:call-template name="get-file-from-interface">
<xsl:with-param name="uri-base-interface" select="$param-uri-file-source"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="doc-available($http)">
<xsl:copy-of select="doc($param-uri-file-source)"/>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:template match="/">
<xsl:result-document method="xml" indent="no" encoding="UTF-8">
<recordMetadata>
<Catalog>
<title>
<xsl:value-of select="'Catalog Title'"/>
</title>
</Catalog>
<!-- Iteration -->
<xsl:iterate select="$file-source/oai:OAI-PMH/oai:ListRecords">
<xsl:param name="param-resumptionToken"/>
<xsl:for-each select="oai:record">
<xsl:variable name="record" select="copy-of(.)"/>
<Titel>
<xsl:value-of select="$record/dc:title"/>
</Titel>
</xsl:for-each>
<xsl:if test="position() = last() and oai:resumptionToken != ''">
<xsl:next-iteration>
<xsl:with-param name="param-resumptionToken" select="oai:resumptionToken"/>
</xsl:next-iteration>
</xsl:if>
</xsl:iterate>
</recordMetadata>
</xsl:result-document>
</xsl:template>
Thanks for your help!