(PHP 5, PHP 7, PHP 8)
XSLTProcessor::setParameter — Establece el valor para uno o varios parámetros
Establece el valor para uno o más parámetros a ser usado en las siguientes transformaciones con XSLTProcessor. Si el parámetro no existe en la hoja de estilos, será ignorado.
namespaceLa URI para el namespace del parámetro XSLT.
nameNombre local del parámetro XSLT.
valueNuevo valor para el parámetro XSLT.
options
Un array de parejas nombre => valor.
Ejemplo #1 Changing the owner before the transformation
<?php
$collections = array(
'Marc Rutkowski' => 'marc',
'Olivier Parmentier' => 'olivier'
);
$xsl = new DOMDocument;
$xsl->load('collection.xsl');
// Configuración del procesador
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // asociamos las reglas xsl
foreach ($collections as $name => $file) {
// Cargamos el XML origen
$xml = new DOMDocument;
$xml->load('collection_' . $file . '.xml');
$proc->setParameter('', 'owner', $name);
$proc->transformToURI($xml, 'file:///tmp/' . $file . '.html');
}
?>