svn: /phpdoc/fr/trunk/reference/dom/domxpath/ registerphpfunctions.xml

From: Date: Sun, 31 Jan 2010 19:31:46 +0000
Subject: svn: /phpdoc/fr/trunk/reference/dom/domxpath/ registerphpfunctions.xml
Groups: php.doc.fr 
Request: Send a blank email to doc-fr+get-7724@lists.php.net to get a copy of this message
yannick Sun, 31 Jan 2010 19:31:46 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=294275 Log: New translation Changed paths: A phpdoc/fr/trunk/reference/dom/domxpath/registerphpfunctions.xml Added: phpdoc/fr/trunk/reference/dom/domxpath/registerphpfunctions.xml =================================================================== --- phpdoc/fr/trunk/reference/dom/domxpath/registerphpfunctions.xml (rev 0) +++ phpdoc/fr/trunk/reference/dom/domxpath/registerphpfunctions.xml 2010-01-31 19:31:46 UTC (rev 294275) @@ -0,0 +1,201 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision$ --> +<!-- EN-Revision: 290998 Maintainer: yannick Status: ready --> +<!-- Reviewed: no --> + +<refentry xml:id="domxpath.registerphpfunctions" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <refnamediv> + <refname>DOMXPath::registerPhpFunctions</refname> + <refpurpose>Enregistre une fonction PHP comme fonction XPath</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <modifier>public</modifier> <type>void</type><methodname>DOMXPath::registerPhpFunctions</methodname> + <methodparam choice="opt"><type>mixed</type><parameter>restrict</parameter></methodparam> + </methodsynopsis> + <para> + Cette méthode active la possibilité d'utiliser des fonctions PHP dans des + expressions XPath. + </para> + + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>restrict</parameter></term> + <listitem> + <para> + Utilisez ce paramètre uniquement pour autoriser certaines fonctions + à être appelées depuis XPath. + </para> + <para> + Ce paramètre peut être soit une &string; (un nom de fonction) ou + un &array; de noms de fonctions. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + &return.void; + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + Les exemples suivants utilisent le fichier <filename>book.xml</filename> + qui contient les données suivantes : + </para> + <para> + <example> + <title>book.xml</title> + <programlisting role="xml"> +<![CDATA[ +<?xml version="1.0" encoding="UTF-8"?> +<books> + <book> + <title>PHP Basics</title> + <author>Jim Smith</author> + <author>Jane Smith</author> + </book> + <book> + <title>PHP Secrets</title> + <author>Jenny Smythe</author> + </book> + <book> + <title>XML basics</title> + <author>Joe Black</author> + </book> +</books> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Exemple avec <methodname>DOMXPath::registerPHPFunctions</methodname> + et <literal>php:functionString</literal></title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = new DOMDocument; +$doc->load('book.xml'); + +$xpath = new DOMXPath($doc); + +// Enregistre l'espace de noms php (nécessaire) +$xpath->registerNamespace("php", "http://php.net/xpath"); + +// Enregistre les fonctions PHP (Aucune restriction) +$xpath->registerPHPFunctions(); + +// Appèle la fonction substr sur le titre du livre +$nodes = $xpath->query('//book[php:functionString("substr", title, 0, 3) = "PHP"]'); + +echo "{$nodes->length} livres trouvés dont le titre commence par 'PHP':\n"; +foreach ($nodes as $node) { + $title = $node->getElementsByTagName("title")->item(0)->nodeValue; + $author = $node->getElementsByTagName("author")->item(0)->nodeValue; + echo "$title par $author\n"; +} + +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +2 livres trouvés dont le titre commence par 'PHP': +PHP Basics par Jim Smith +PHP Secrets par Jenny Smythe +]]> + </screen> + </example> + </para> + <para> + <example> + <title>Exemple avec <methodname>DOMXPath::registerPHPFunctions</methodname> + et <literal>php:function</literal></title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = new DOMDocument; +$doc->load('book.xml'); + +$xpath = new DOMXPath($doc); + +// Enregistre l'espace de noms php (nécessaire) +$xpath->registerNamespace("php", "http://php.net/xpath"); + +// Enregistre des fonctions PHP (has_multiple uniquement) +$xpath->registerPHPFunctions("has_multiple"); + +function has_multiple($nodes) { + // Retourne true s'il y a plus d'un auteur + return count($nodes) > 1; +} +// Filtre les livres dont les auteurs sont multiples +$books = $xpath->query('//book[php:function("has_multiple", author)]'); + +echo "Livres avec plusieurs auteurs :\n"; +foreach ($books as $book) { + echo $book->getElementsByTagName("title")->item(0)->nodeValue . "\n"; +} + +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Livres avec plusieurs auteurs : +PHP Basics +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><methodname>DOMXPath::registerNamespace</methodname></member> + <member><methodname>DOMXPath::query</methodname></member> + <member><methodname>DOMXPath::evaluate</methodname></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:"../../../../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 +--> Property changes on: phpdoc/fr/trunk/reference/dom/domxpath/registerphpfunctions.xml ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL Added: svn:eol-style + native

« previous php.doc.fr (#7724) next »