Php/docs/xsltprocessor.setparameter

提供:Dev Guides
< Php
移動先:案内検索

XSLTProcessor::setParameter

(PHP 5, PHP 7)

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


説明

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

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

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 rulesforeach ($collections as $name => $file) {    // XML ソースをロードする    $xml = new DOMDocument;    $xml->load('collection_' . $file . '.xml');    $proc->setParameter(, 'owner', $name);    $proc->transformToURI($xml, 'file:///tmp/' . $file . '.html');}?>

参考