From 4b7e79f528ec8694f4dc166e724ad294770c0a84 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 6 Nov 2012 13:05:18 -0500 Subject: [PATCH] Added parameter handling to XSLT processor. --- module/VuFind/src/VuFind/XSLT/Processor.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/module/VuFind/src/VuFind/XSLT/Processor.php b/module/VuFind/src/VuFind/XSLT/Processor.php index 37a01f3aca5..27c204dc5be 100644 --- a/module/VuFind/src/VuFind/XSLT/Processor.php +++ b/module/VuFind/src/VuFind/XSLT/Processor.php @@ -42,12 +42,13 @@ class Processor /** * Perform an XSLT transformation and return the results. * - * @param string $xslt Name of stylesheet (in application/xsl directory) - * @param string $xml XML to transform with stylesheet + * @param string $xslt Name of stylesheet (in application/xsl directory) + * @param string $xml XML to transform with stylesheet + * @param string $params Associative array of XSLT parameters * * @return string Transformed XML */ - public static function process($xslt, $xml) + public static function process($xslt, $xml, $params = array()) { $style = new DOMDocument(); // TODO: support local overrides @@ -56,6 +57,9 @@ class Processor $xsl->importStyleSheet($style); $doc = new DOMDocument(); if ($doc->loadXML($xml)) { + foreach ($params as $key => $value) { + $xsl->setParameter('', $key, $value); + } return $xsl->transformToXML($doc); } return ''; -- GitLab