XSLTProcessor::setParameter

パラメータの値を設定する

説明

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

XSLTProcessor を使った変換のための 1 つあるいは多くのパラメータの値を設定します。 もしパラメータがスタイルシートに存在しない場合、無視されます。

パラメータ

namespace

XSLT パラメータの名前空間 URI を指定します。

name

XSLT パラメータのローカル名を指定します。

value

XSLT パラメータの新しい値を指定します。

options

名前 => 値 の組の配列を指定します。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例1 変換前に所有者を変更する

<?php

$collections 
= array(
    
'Marc Rutkowski' => 'marc',
    
'Olivier Parmentier' => 'olivier'
);

$xsl = new DOMDocument;
$xsl->load('collection.xsl');

// 変換の設定を行う
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

foreach ($collections as $name => $file) {
    
// XML ソースをロードする
    
$xml = new DOMDocument;
    
$xml->load('collection_' $file '.xml');

    
$proc->setParameter('''owner'$name);
    
$proc->transformToURI($xml'file:///tmp/' $file '.html');
}

?>

参考

  • XSLTProcessor::getParameter
  • XSLTProcessor::removeParameter