XSLTProcessor::setParameter

(PHP 5, PHP 7)

XSLTProcessor::setParameterEstablece el valor para uno o varios parámetros

Descripción

XSLTProcessor::setParameter ( string $namespace , string $name , string $value ) : bool
XSLTProcessor::setParameter ( string $namespace , array $options ) : bool

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.

Parámetros

namespace

La URI para el namespace del parámetro XSLT.

name

Nombre local del parámetro XSLT.

value

Nuevo valor para el parámetro XSLT.

options

Un array de parejas nombre => valor. Esta sintaxis está disponible desde PHP 5.1.0.

Valores devueltos

Devuelve TRUE en caso de éxito o FALSE en caso de error.

Ejemplos

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');
}

?>

Ver también