1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-24 07:42:10 +01:00
Files
archived-doc-en/reference/xsl/xsltprocessor/setparameter.xml

177 lines
4.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="xsltprocessor.setparameter" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>XSLTProcessor::setParameter</refname>
<refpurpose>Set value for a parameter</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="XSLTProcessor">
<modifier>public</modifier> <type>bool</type><methodname>XSLTProcessor::setParameter</methodname>
<methodparam><type>string</type><parameter>namespace</parameter></methodparam>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<methodsynopsis role="XSLTProcessor">
<modifier>public</modifier> <type>bool</type><methodname>XSLTProcessor::setParameter</methodname>
<methodparam><type>string</type><parameter>namespace</parameter></methodparam>
<methodparam><type>array</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
Sets the value of one or more parameters to be used in subsequent
transformations with <classname>XSLTProcessor</classname>. If the
parameter doesn't exist in the stylesheet it will be ignored.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>namespace</parameter></term>
<listitem>
<para>
The namespace URI of the XSLT parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
The local name of the XSLT parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The new value of the XSLT parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
An array of <literal>name =&gt; value</literal> pairs.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<simpara>
Throws a <exceptionname>ValueError</exceptionname> if any of the arguments
contain null bytes.
</simpara>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.4.0</entry>
<entry>
Now throws a <exceptionname>ValueError</exceptionname> if any of the
arguments contain null bytes instead of silently truncating.
</entry>
</row>
<row>
<entry>8.4.0</entry>
<entry>
It is now possible to set a parameter value containing both single and
double quotes. Prior to PHP 8.4.0, this resulted in a warning.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Changing the owner before the transformation</title>
<programlisting role="php">
<![CDATA[
<?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');
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>XSLTProcessor::getParameter</function></member>
<member><function>XSLTProcessor::removeParameter</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->