Skip to content

Commit

Permalink
#1101 Removed ListMetadataFormats node from oai-pmh.xslt file and gen…
Browse files Browse the repository at this point in the history
…erate it in the ListMetadataFormats view helper instead.
  • Loading branch information
haogatyp committed Nov 2, 2023
1 parent 7d25512 commit 0903c6a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 47 deletions.
14 changes: 9 additions & 5 deletions modules/oai/views/helpers/ListMetadataFormats.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function listMetadataFormats()
$formats = $oaiConfig->getFormats();

if ($formats) {
$output = PHP_EOL . ' <ListMetadataFormats>';
foreach ($formats as $formatPrefix) {
$server = $serverFactory->create($formatPrefix);
$prefix = $server->getPrefixLabel() ?: $formatPrefix;
Expand All @@ -72,14 +73,17 @@ public function listMetadataFormats()
}

$output .= PHP_EOL;
$output .= ' <metadataFormat>' . PHP_EOL;
$output .= " <metadataPrefix>$prefix</metadataPrefix>" . PHP_EOL;
$output .= " <schema>$schemaUrl</schema>" . PHP_EOL;
$output .= " <metadataNamespace>$metadataNamespaceUrl</metadataNamespace>" . PHP_EOL;
$output .= ' </metadataFormat>';
$output .= ' <metadataFormat>' . PHP_EOL;
$output .= " <metadataPrefix>$prefix</metadataPrefix>" . PHP_EOL;
$output .= " <schema>$schemaUrl</schema>" . PHP_EOL;
$output .= " <metadataNamespace>$metadataNamespaceUrl</metadataNamespace>" . PHP_EOL;
$output .= ' </metadataFormat>';
}
}
}

$output .= PHP_EOL;
$output .= ' </ListMetadataFormats>';
$output .= PHP_EOL . ' ';
}

Expand Down
4 changes: 1 addition & 3 deletions modules/oai/views/scripts/index/oai-pmh.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@

<!-- template for ListMetadataFormats -->
<xsl:template match="Documents" mode="ListMetadataFormats">
<ListMetadataFormats>
<xsl:value-of disable-output-escaping="yes" select="php:function('Application_Xslt::listMetadataFormats')" />
</ListMetadataFormats>
<xsl:value-of disable-output-escaping="yes" select="php:function('Application_Xslt::listMetadataFormats')" />
</xsl:template>

<xsl:template match="Documents" mode="ListIdentifiers">
Expand Down
82 changes: 43 additions & 39 deletions tests/modules/oai/views/helpers/ListMetadataFormatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,60 @@ class Oai_View_Helper_ListMetadataFormatsTest extends ControllerTestCase
*/
protected function getExpectedMetadaFormats()
{
return <<<TEXT
return <<<XML
<metadataFormat>
<metadataPrefix>oai_dc</metadataPrefix>
<schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>
<metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>epicur</metadataPrefix>
<schema>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</schema>
<metadataNamespace>urn:nbn:de:1111-2004033116</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>xMetaDissPlus</metadataPrefix>
<schema>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</schema>
<metadataNamespace>http://www.d-nb.de/standards/xmetadissplus/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>MARC21</metadataPrefix>
<schema>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema>
<metadataNamespace>http://www.loc.gov/MARC21/slim</metadataNamespace>
</metadataFormat>
<ListMetadataFormats>
<metadataFormat>
<metadataPrefix>oai_dc</metadataPrefix>
<schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>
<metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>epicur</metadataPrefix>
<schema>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</schema>
<metadataNamespace>urn:nbn:de:1111-2004033116</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>xMetaDissPlus</metadataPrefix>
<schema>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</schema>
<metadataNamespace>http://www.d-nb.de/standards/xmetadissplus/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>MARC21</metadataPrefix>
<schema>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema>
<metadataNamespace>http://www.loc.gov/MARC21/slim</metadataNamespace>
</metadataFormat>
</ListMetadataFormats>
TEXT;
XML;
}

/**
* @return string
*/
protected function getExpectedMetadaFormatsWithoutOaiDc()
{
return <<<TEXT
return <<<XML
<metadataFormat>
<metadataPrefix>epicur</metadataPrefix>
<schema>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</schema>
<metadataNamespace>urn:nbn:de:1111-2004033116</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>xMetaDissPlus</metadataPrefix>
<schema>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</schema>
<metadataNamespace>http://www.d-nb.de/standards/xmetadissplus/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>MARC21</metadataPrefix>
<schema>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema>
<metadataNamespace>http://www.loc.gov/MARC21/slim</metadataNamespace>
</metadataFormat>
<ListMetadataFormats>
<metadataFormat>
<metadataPrefix>epicur</metadataPrefix>
<schema>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</schema>
<metadataNamespace>urn:nbn:de:1111-2004033116</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>xMetaDissPlus</metadataPrefix>
<schema>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</schema>
<metadataNamespace>http://www.d-nb.de/standards/xmetadissplus/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>MARC21</metadataPrefix>
<schema>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema>
<metadataNamespace>http://www.loc.gov/MARC21/slim</metadataNamespace>
</metadataFormat>
</ListMetadataFormats>
TEXT;
XML;
}

public function testListMetadataFormats()
Expand Down

0 comments on commit 0903c6a

Please sign in to comment.