首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

XSLTProcessor::setParameter

(PHP 5, PHP 7)

XSLTProcessor :: setParameter - 设置参数的值

描述

代码语言:javascript
复制
bool XSLTProcessor::setParameter ( string $namespace , string $name , string $value )
代码语言:javascript
复制
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

代码语言:javascript
复制
<?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 →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com