mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
initial translation of xsltprocessor/registerphpfunctionns.xml
This commit is contained in:
146
reference/xsl/xsltprocessor/registerphpfunctionns.xml
Normal file
146
reference/xsl/xsltprocessor/registerphpfunctionns.xml
Normal file
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 01904e809eaf0aa60e7ce0524400ddd5681c9541 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<refentry xml:id="xsltprocessor.registerphpfunctionns" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refnamediv>
|
||||
<refname>XSLTProcessor::registerPHPFunctionNS</refname>
|
||||
<refpurpose>Registra uma função PHP como uma função XSLT com namespace</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis role="XSLTProcessor">
|
||||
<modifier>public</modifier> <type>void</type><methodname>XSLTProcessor::registerPHPFunctionNS</methodname>
|
||||
<methodparam><type>string</type><parameter>namespaceURI</parameter></methodparam>
|
||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||
<methodparam><type>callable</type><parameter>callable</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<simpara>
|
||||
Este método permite usar uma função PHP como uma função XSLT com namespace dentro de folhas de estilo XSL.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>namespaceURI</parameter></term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
O URI do namespace.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>name</parameter></term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
O nome da função local dentro do namespace.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>callable</parameter></term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
A função PHP a ser chamada quando a função XSL for chamada dentro da folha de estilo.
|
||||
Quando uma lista de nós é passada como parâmetro para a função de retorno,
|
||||
o argumento se torna um array contendo os nós DOM correspondentes.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<xi:include xpointer="domxpath.registerphpfunctions..errors" />
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<simpara>
|
||||
&return.void;
|
||||
</simpara>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title>Chamada de função PHP simples a partir de uma folha de estilo</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$xml = <<<EOB
|
||||
<allusers>
|
||||
<user>
|
||||
<uid>bob</uid>
|
||||
</user>
|
||||
<user>
|
||||
<uid>joe</uid>
|
||||
</user>
|
||||
</allusers>
|
||||
EOB;
|
||||
$xsl = <<<EOB
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:my="urn:my.ns">
|
||||
<xsl:output method="html" encoding="utf-8" indent="yes"/>
|
||||
<xsl:template match="allusers">
|
||||
<html><body>
|
||||
<h2><xsl:value-of select="my:count(user/uid)" /> users</h2>
|
||||
<table>
|
||||
<xsl:for-each select="user">
|
||||
<tr>
|
||||
<td>
|
||||
<xsl:value-of select="my:uppercase(string(uid))"/>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</table>
|
||||
</body></html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
EOB;
|
||||
$xmldoc = new DOMDocument();
|
||||
$xmldoc->loadXML($xml);
|
||||
$xsldoc = new DOMDocument();
|
||||
$xsldoc->loadXML($xsl);
|
||||
|
||||
$proc = new XSLTProcessor();
|
||||
$proc->registerPHPFunctionNS('urn:my.ns', 'uppercase', strtoupper(...));
|
||||
$proc->registerPHPFunctionNS('urn:my.ns', 'count', fn (array $arg1) => count($arg1));
|
||||
$proc->importStyleSheet($xsldoc);
|
||||
echo $proc->transformToXML($xmldoc);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<simplelist>
|
||||
<member><methodname>DOMXPath::registerPhpFunctionNS</methodname></member>
|
||||
<member><methodname>DOMXPath::registerPhpFunctions</methodname></member>
|
||||
<member><methodname>XSLTProcessor::registerPhpFunctions</methodname></member>
|
||||
</simplelist>
|
||||
</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
|
||||
-->
|
||||
Reference in New Issue
Block a user