1
0
mirror of https://github.com/php/doc-it.git synced 2026-03-28 01:22:14 +01:00
Files
archived-doc-it/reference/domxml/reference.xml
Andrioli Darvin 00224b91ea Update to En 1.11
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@130475 c90b9560-bf6c-de11-be94-00142212c4b1
2003-06-06 20:13:19 +00:00

759 lines
22 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- EN-Revision: 1.11 Maintainer: darvina Status: ready -->
<reference id="ref.domxml">
<title>Funzioni DOM XML</title>
<titleabbrev>DOM XML</titleabbrev>
<partintro>
<section id="domxml.intro">
&reftitle.intro;
&warn.experimental;
<para>
Nella versione 4.3.0 di PHP l'estensione DOM XML è stata rivista in modo
da fornire una migliore adesione allo standard DOM. Il modulo contiene ancora
diverse vecchie funzioni, ma non dovrebbero essere più usate. Specialmente
quelle funzioni non orientate agli oggetti.
</para>
<para>
Questo modulo permette di operare con un documento XML utilizzando API DOM.
Inoltre viene fornita una funzione, <function>domxml_xmltree</function>, per convertire
l'intero documento XML in un albero di oggetti PHP. Attualmente questo
albero dovrebbe essere considerato di sola lettura, è possibile modificarlo, ma
questa operazione non avrebbe senso dato che la funzione <function>DomDocument_dump_mem</function>
non può essere applicata
all'albero. Pertanto se si desidera leggere un file XML e scriverne una
versione modificata, occorre utilizzare le funzioni <function>DomDocument_create_element</function>,
<function>DomDocument_create_text_node</function>,
<function>set_attribute</function>, ecc. ed infine
<function>DomDocument_dump_mem</function>.
</para>
</section>
<section id="domxml.requirements">
&reftitle.required;
<para>
Questo modulo utilizza la libreria
<ulink url="&url.domxml;">GNOME xml library</ulink>. Fare il download
ed installare questa libreria. Occorre avere almeno la libxml-2.4.14.
Per potere utilizzare le caratteristiche previste nel DOM XSLT occorre
utilizzare <ulink url="&url.libxslt;">libxslt library</ulink> ed EXSLT
enhancements da <ulink url="&url.exslt;">&url.exslt;</ulink>. Scaricare
ed installare queste librerie se si prevede di utilizzare la funzioni
avanzate di XSLT. Occorre almeno la versione libxslt-1.0.18.
</para>
</section>
&reference.domxml.configure;
<section id="domxml.deprecated">
<title>Funzioni deprecate</title>
<para>
Esistono alcune funzioni che non rientrano nello standard DOM e quindi
non dovrebbero essere più utilizzate come evidenziato nella tabella seguente.
La funzione <function>DomNode_append_child</function> ha modificato il suo
comportamento. Attualmente aggiunge un figlio e non un elemento fratello. Se ciò crea
problemi alle applicazioni si può usare la funzione non DOM
</para>
<para>
<table>
<title>Funzioni deprecate e loro sostituti</title>
<tgroup cols="2">
<thead>
<row>
<entry>Vecchia funzione</entry>
<entry>Nuova funzione</entry>
</row>
</thead>
<tbody>
<row>
<entry>xmldoc</entry>
<entry><function>domxml_open_mem</function></entry>
</row>
<row>
<entry>xmldocfile</entry>
<entry><function>domxml_open_file</function></entry>
</row>
<row>
<entry>domxml_new_xmldoc</entry>
<entry><function>domxml_new_doc</function></entry>
</row>
<row>
<entry>domxml_dump_mem</entry>
<entry><function>DomDocument_dump_mem</function></entry>
</row>
<row>
<entry>domxml_dump_mem_file</entry>
<entry><function>DomDocument_dump_file</function></entry>
</row>
<row>
<entry>DomDocument_dump_mem_file</entry>
<entry><function>DomDocument_dump_file</function></entry>
</row>
<row>
<entry>DomDocument_add_root</entry>
<entry><function>DomDocument_create_element</function> seguita da
<function>DomNode_append_child</function></entry>
</row>
<row>
<entry>DomDocument_dtd</entry>
<entry><function>DomDocument_doctype</function></entry>
</row>
<row>
<entry>DomDocument_root</entry>
<entry><function>DomDocument_document_element</function></entry>
</row>
<row>
<entry>DomDocument_children</entry>
<entry><function>DomNode_child_nodes</function></entry>
</row>
<row>
<entry>DomDocument_imported_node</entry>
<entry>Nessun sostituto.</entry>
</row>
<row>
<entry>DomNode_add_child</entry>
<entry>Creare un nuovo nodo con, ad esempio,
<function>DomDocument_create_element</function> e aggiungere il figlio con
<function>DomNode_append_child</function>.
</entry>
</row>
<row>
<entry>DomNode_children</entry>
<entry><function>DomNode_child_nodes</function></entry>
</row>
<row>
<entry>DomNode_parent</entry>
<entry><function>DomNode_parent_node</function></entry>
</row>
<row>
<entry>DomNode_new_child</entry>
<entry>Creare un nuovo nodo con, ad esempio,
<function>DomDocument_create_element</function> e aggiungere il figlio con
<function>DomNode_append_child</function>.
</entry>
</row>
<row>
<entry>DomNode_get_content</entry>
<entry>Il contenuto è semplicemente un nodo di testo ed è accessibile tramite
<function>DomNode_child_nodes</function>.
</entry>
</row>
<row>
<entry>DomNode_set_content</entry>
<entry>Il contenuto è semplicemente un nodo di testo e può essere aggiunto con
<function>DomNode_append_child</function>.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</section>
&reference.domxml.constants;
<section id="domxml.classes">
<title>Classi</title>
<para>
Le API di questo modulo aderiscono il più possibile allo standard
DOM di livello 2. Di conseguenza le API sono completamente orientate agli oggetti.
Si ritiene una buona idea avere disponibile lo standard DOM quando
si utilizza questo modulo.
Sebbene le API siano orientate agli oggetti, vi sono alcune funzioni che possono
essere richiamate in modo non orientato agli oggetti, passando l'oggetto su cui operare come
primo argomento. Queste funzioni sono state mantenute per compatibilità
verso le vecchie versioni del modulo, ma non se ne incoraggia l'uso nello
sviluppo di nuovi prodotti.
</para>
<para>
Queste API differiscono della API DOM ufficiali per due aspetti. Primo, gli attributi
della classe sono implermentati come funzioni con il medesimo nome e, secondo,
i nomi delle funzioni seguono la convenzione del PHP. Questo significa che
la funzione DOM lastChild() sarà chiamata last_child().
</para>
<para>
In questo modulo sono definite diverse classi, queste saranno elencate
&mdash; compresi i loro metodi &mdash;
nella seguente tabella. Le classi con un equivalente nello standard
DOM sono chiamate DOMxxx.
</para>
<para>
<table>
<title>Elenco delle classi</title>
<tgroup cols="2">
<thead>
<row>
<entry>Nome della classe</entry>
<entry>Classe genitrice</entry>
</row>
</thead>
<tbody>
<row>
<entry>DomAttribute</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomCData</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomComment</entry>
<entry>DomCData : DomNode</entry>
</row>
<row>
<entry>DomDocument</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomDocumentType</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomElement</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomEntity</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomEntityReference</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomProcessingInstruction</entry>
<entry>DomNode</entry>
</row>
<row>
<entry>DomText</entry>
<entry>DomCData : DomNode</entry>
</row>
<row>
<entry>Parser</entry>
<entry>Attualmente chiamata DomParser</entry>
</row>
<row>
<entry>XPathContext</entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe DomDocument (DomDocument : DomNode)</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodi</entry>
<entry>Funzioni</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>doctype</entry>
<entry><function>DomDocument_doctype</function></entry>
<entry></entry>
</row>
<row>
<entry>document_elemnent</entry>
<entry><function>DomDocument_document_element</function></entry>
<entry></entry>
</row>
<row>
<entry>create_element</entry>
<entry><function>DomDocument_create_element</function></entry>
<entry></entry>
</row>
<row>
<entry>create_text_node</entry>
<entry><function>DomDocument_create_text_node</function></entry>
<entry></entry>
</row>
<row>
<entry>create_comment</entry>
<entry><function>DomDocument_create_comment</function></entry>
<entry></entry>
</row>
<row>
<entry>create_cdata_section</entry>
<entry><function>DomDocument_create_cdata_section</function></entry>
<entry></entry>
</row>
<row>
<entry>create_processing_instruction</entry>
<entry><function>DomDocument_create_processing_instruction</function></entry>
<entry></entry>
</row>
<row>
<entry>create_attribute</entry>
<entry><function>DomDocument_create_attribute</function></entry>
<entry></entry>
</row>
<row>
<entry>create_entity_reference</entry>
<entry><function>DomDocument_create_entity_reference</function></entry>
<entry></entry>
</row>
<row>
<entry>get_elements_by_tagname</entry>
<entry><function>DomDocument_get_elements_by_tagname</function></entry>
<entry></entry>
</row>
<row>
<entry>get_element_by_id</entry>
<entry><function>DomDocument_get_element_by_id</function></entry>
<entry></entry>
</row>
<row>
<entry>dump_mem</entry>
<entry><function>DomDocument_dump_mem</function></entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry>dump_file</entry>
<entry><function>DomDocument_dump_file</function></entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry>html_dump_mem</entry>
<entry><function>DomDocument_html_dump_mem</function></entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry>xpath_init</entry>
<entry>xpath_init</entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry>xpath_new_context</entry>
<entry>xpath_new_context</entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry>xptr_new_context</entry>
<entry>xptr_new_context</entry>
<entry>non standard DOM</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe DomElement (DomElement : DomNode)</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodo</entry>
<entry>Funzioni</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>tagname</entry>
<entry><function>DomElement_tagname</function></entry>
<entry></entry>
</row>
<row>
<entry>get_attribute</entry>
<entry><function>DomElement_get_attribute</function></entry>
<entry></entry>
</row>
<row>
<entry>set_attribute</entry>
<entry><function>DomElement_set_attribute</function></entry>
<entry></entry>
</row>
<row>
<entry>remove_attribute</entry>
<entry><function>DomElement_remove_attribute</function></entry>
<entry></entry>
</row>
<row>
<entry>get_attribute_node</entry>
<entry><function>DomElement_get_attribute_node</function></entry>
<entry></entry>
</row>
<!-- This function is not implemented at all for the time being
<row>
<entry>set_attribute_node</entry>
<entry><function>DomElement_set_attribute_node</function></entry>
<entry></entry>
</row>
-->
<row>
<entry>get_elements_by_tagname</entry>
<entry><function>DomElement_get_elements_by_tagname</function></entry>
<entry></entry>
</row>
<row>
<entry>has_attribute</entry>
<entry><function>DomElement_has_attribute</function></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe DomNode</title>
<tgroup cols="2">
<thead>
<row>
<entry>Metodo</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>DomNode_node_name</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_node_value</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_node_type</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_last_child</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_first_child</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_child_nodes</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_previous_sibling</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_next_sibling</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_parent_node</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_owner_document</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_insert_before</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_append_child</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_append_sibling</function></entry>
<entry>non standard DOM. Questa funzione emula il comportamento
di <function>DomNode_append_child</function>.</entry>
</row>
<row>
<entry><function>DomNode_remove_child</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_has_child_nodes</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_has_attributes</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_clone_node</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_attributes</function></entry>
<entry></entry>
</row>
<row>
<entry><function>DomNode_unlink_node</function></entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry><function>DomNode_replace_node</function></entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry><function>DomNode_set_content</function></entry>
<entry>non standard DOM, deprecata</entry>
</row>
<row>
<entry><function>DomNode_get_content</function></entry>
<entry>non standard DOM, deprecata</entry>
</row>
<row>
<entry><function>DomNode_dump_node</function></entry>
<entry>non standard DOM</entry>
</row>
<row>
<entry><function>DomNode_is_blank_node</function></entry>
<entry>non standard DOM</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe DomAttribute (DomAttribute : DomNode)</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodo</entry>
<entry></entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>name</entry>
<entry><function>DomAttribute_name</function></entry>
<entry></entry>
</row>
<row>
<entry>value</entry>
<entry><function>DomAttribute_value</function></entry>
<entry></entry>
</row>
<row>
<entry>specified</entry>
<entry><function>DomAttribute_specified</function></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe DomProcessingInstruction (DomProcessingInstruction : DomNode)</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodo</entry>
<entry>Funzione</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>target</entry>
<entry><function>DomProcessingInstruction_target</function></entry>
<entry></entry>
</row>
<row>
<entry>data</entry>
<entry><function>DomProcessingInstruction_data</function></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe Parser class</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodo</entry>
<entry>Funzione</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>add_chunk</entry>
<entry><function>Parser_add_chunk</function></entry>
<entry></entry>
</row>
<row>
<entry>end</entry>
<entry><function>Parser_end</function></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe XPathContext</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodo</entry>
<entry>Funzione</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>eval</entry>
<entry><function>XPathContext_eval</function></entry>
<entry></entry>
</row>
<row>
<entry>eval_expression</entry>
<entry><function>XPathContext_eval_expression</function></entry>
<entry></entry>
</row>
<row>
<entry>register_ns</entry>
<entry><function>XPathContext_register_ns</function></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Classe DomDocumentType (DomDocumentType : DomNode)</title>
<tgroup cols="3">
<thead>
<row>
<entry>Metodo</entry>
<entry>Funzione</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>name</entry>
<entry><function>DomDocumentType_name</function></entry>
<entry></entry>
</row>
<row>
<entry>entities</entry>
<entry><function>DomDocumentType_entities</function></entry>
<entry></entry>
</row>
<row>
<entry>notations</entry>
<entry><function>DomDocumentType_notations</function></entry>
<entry></entry>
</row>
<row>
<entry>public_id</entry>
<entry><function>DomDocumentType_public_id</function></entry>
<entry></entry>
</row>
<row>
<entry>system_id</entry>
<entry><function>DomDocumentType_system_id</function></entry>
<entry></entry>
</row>
<row>
<entry>internal_subset</entry>
<entry><function>DomDocumentType_internal_subset</function></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
La classe DomDtd è derivata da DomNode. Mentre DomComment è derivata da
DomCData
</para>
</section>
<section id="domxml.examples">
&reftitle.examples;
<para>
Diversi esempi presenti in questo manuale richiedono un testo XML. Anzichè
ripetere questo testo in ogni esempio, si inserirà il testo in un file
che verrà incluso in ogni esempio. Questo file di include verrà illustrato
nel seguente esempio. Si può anche creare un documento XML e
leggerlo con <function>DomDocument_open_file</function>.
</para>
<para>
<example>
<title>File di include example.inc con testo XML</title>
<programlisting role="php">
<![CDATA[
<?php
$xmlstr = "<?xml version='1.0' standalone='yes'?>
<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
[ <!ENTITY sp \"spanish\">
]>
<!-- lsfj -->
<chapter language='en'><title language='en'>Title</title>
<para language='ge'>
&amp;sp;
<!-- comment -->
<informaltable ID='findme' language='&amp;sp;'>
<tgroup cols='3'>
<tbody>
<row><entry>a1</entry><entry
morerows='1'>b1</entry><entry>c1</entry></row>
<row><entry>a2</entry><entry>c2</entry></row>
<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
</tbody>
</tgroup>
</informaltable>
</para>
</chapter>";
?>
]]>
</programlisting>
</example>
</para>
</section>
</partintro>
&reference.domxml.functions;
</reference>
<!-- 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
-->