XSLTProcessor::setParameter
XSLTProcessor::设置参数
(PHP 5, PHP 7)
XSLTProcessor :: setParameter - 设置参数的值
描述
bool XSLTProcessor::setParameter ( string $namespace , string $name , string $value )
bool XSLTProcessor::setParameter ( string $namespace , array $options )
设置一个或多个参数在 XSLTProcessor 后续转换中使用的值。如果参数在样式表中不存在,它将被忽略。
参数
namespace
XSLT 参数的名称空间 URI。
name
The local name of the XSLT parameter.
value
The new value of the XSLT parameter.
options
An array of name => value pairs. This syntax is available since PHP 5.1.0.
Return Values
Returns TRUE
on success or FALSE
on failure.
Examples
Example #1 Changing the owner before the transformation
<?php
$collections = array(
'Marc Rutkowski' => 'marc',
'Olivier Parmentier' => 'olivier'
$xsl = new DOMDocument;
$xsl->load('collection.xsl'
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl // attach the xsl rules
foreach ($collections as $name => $file) {
// Load the XML source
$xml = new DOMDocument;
$xml->load('collection_' . $file . '.xml'
$proc->setParameter('', 'owner', $name
$proc->transformToURI($xml, 'file:///tmp/' . $file . '.html'
}
?>
See Also
- XSLTProcessor::getParameter() - Get value of a parameter
- XSLTProcessor::removeParameter() - Remove parameter
← XSLTProcessor::removeParameter
XSLTProcessor::setProfiling →
© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/xsltprocessor.setparameter.php