Skip to content

Commit

Permalink
[MAINTENANCE] Format XML output of OAI-PMH (#1473)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
stweil and sebastian-meyer authored Feb 5, 2025
1 parent 411bfb8 commit df4bcbe
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Classes/Controller/OaiPmhController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Kitodo\Dlf\Controller;

use DOMDocument;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Kitodo\Dlf\Common\Solr\Solr;
use Kitodo\Dlf\Domain\Model\Token;
Expand Down Expand Up @@ -302,7 +303,19 @@ public function mainAction(): ResponseInterface
$this->view->assign('parameters', $this->parameters);
$this->view->assign('error', $this->error);

return $this->htmlResponse();
// Generate the XML output.
$xmlOutput = $this->view->render();

// Format the XML.
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
// Here we could also choose `false` for a minimized XML.
$dom->formatOutput = true;
$dom->loadXML($xmlOutput);
$formattedXmlOutput = trim($dom->saveXML());

// Return the formatted XML.
return $this->htmlResponse($formattedXmlOutput);
}

/**
Expand Down

0 comments on commit df4bcbe

Please sign in to comment.