mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added a generic XML file for use in examples
Added DOMImplementation and documented DOMImplemntation::hasFeature() Added DOMXPath::__construct and documented DOMXPath::query git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@175076 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
36ad797985
commit
0198ad7658
4 changed files with 242 additions and 11 deletions
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id='function.dom-domimplementation-hasfeature'>
|
||||
<refnamediv>
|
||||
<refname>DOMImplementation->hasFeature</refname>
|
||||
<refpurpose>
|
||||
Test if the DOM implementation implements a specific feature and version
|
||||
Test if the DOM implementation implements a specific feature
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
|
@ -19,8 +19,54 @@
|
|||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Test if the DOM implementation implements a specific feature and version.
|
||||
Test if the DOM implementation implements a specific
|
||||
<parameter>feature</parameter>. &return.success;
|
||||
</para>
|
||||
<para>
|
||||
You can find a list of all features in the <ulink
|
||||
url="&url.dom2.features;">Conformance</ulink> section of the DOM
|
||||
specification.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>version</parameter> is the version number of the feature to
|
||||
test. In level 2, this can be either <literal>2.0</literal> or
|
||||
<literal>1.0</literal>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Testing your DOM Implementation</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$features = array(
|
||||
'Core' => 'Core module',
|
||||
'XML' => 'XML module',
|
||||
'HTML' => 'HTML module',
|
||||
'Views' => 'Views module',
|
||||
'Stylesheets' => 'Style Sheets module',
|
||||
'CSS' => 'CSS module',
|
||||
'CSS2' => 'CSS2 module',
|
||||
'Events' => 'Events module',
|
||||
'UIEvents' => 'User interface Events module',
|
||||
'MouseEvents' => 'Mouse Events module',
|
||||
'MutationEvents' => 'Mutation Events module',
|
||||
'HTMLEvents' => 'HTML Events module',
|
||||
'Range' => 'Range module',
|
||||
'Traversal' => 'Traversal module'
|
||||
);
|
||||
|
||||
foreach ($features as $key => $name) {
|
||||
if (DOMImplementation::hasFeature($key, '2.0')) {
|
||||
echo "Has feature $name\n";
|
||||
} else {
|
||||
echo "Missing feature $name\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
44
reference/dom/functions/dom-domxpath-construct.xml
Normal file
44
reference/dom/functions/dom-domxpath-construct.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id='function.dom-domxpath-construct'>
|
||||
<refnamediv>
|
||||
<refname>DOMXPath->__construct</refname>
|
||||
<refpurpose>
|
||||
Creates a new DOMXPath object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMXPath</classname></ooclass>
|
||||
<constructorsynopsis>
|
||||
<methodname>__construct</methodname>
|
||||
<methodparam><type>DOMDocument</type><parameter>doc</parameter></methodparam>
|
||||
</constructorsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates a new <classname>DOMXPath</classname> object.
|
||||
</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
|
||||
-->
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<refentry id="function.dom-domxpath-query">
|
||||
<refnamediv>
|
||||
<refname>DOMXPath->query</refname>
|
||||
|
@ -19,16 +19,76 @@
|
|||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Returns a DOMNodeList containing all nodes matching
|
||||
<parameter>expression</parameter>. Any expression which do not return
|
||||
nodes will return an empty DOMNodeList.
|
||||
Returns a <classname>DOMNodeList</classname> containing all nodes matching
|
||||
the given XPath <parameter>expression</parameter>. Any expression which do
|
||||
not return nodes will return an empty <classname>DOMNodeList</classname>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Getting all entries begining with "b"</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->Load('chapter.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
// We starts from the root element
|
||||
$query = '//chapter/para/informaltable/tgroup/tbody/row/entry[substring(., 1, 1) = "b"]';
|
||||
|
||||
$entries = $xpath->query($query);
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
echo 'cell: ' . $entry->nodeValue . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
cell: b1
|
||||
cell: b3
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
The optional <parameter>contextnode</parameter> can be specified for doing
|
||||
relative XPath queries.
|
||||
relative XPath queries. By default, the queries are relative to the root
|
||||
element. Knowing that, we can rewrite our previous example as follow:
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<para>
|
||||
<example>
|
||||
<title>Using the context node</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->Load('chapter.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
$tbody = $doc->getElementsByTagName('tbody')->item(0);
|
||||
|
||||
// our query is relative to the tbody node
|
||||
$query = 'row/entry[substring(., 1, 1) = "b"]';
|
||||
|
||||
$entries = $xpath->query($query, $tbody);
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
echo 'cell: ' . $entry->nodeValue . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<reference id="ref.dom">
|
||||
<title>DOM Functions</title>
|
||||
<titleabbrev>DOM</titleabbrev>
|
||||
|
@ -648,6 +648,30 @@
|
|||
</section>
|
||||
</section>
|
||||
|
||||
<section id='dom.class.domimplementation'>
|
||||
<title><classname>DOMImplementation</classname></title>
|
||||
<para>
|
||||
The <classname>DOMImplementation</classname> interface provides a number
|
||||
of methods for performing operations that are independent of any
|
||||
particular instance of the document object model.
|
||||
</para>
|
||||
<section id='dom.class.domimplementation.methods'>
|
||||
&reftitle.methods;
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><link linkend='function.dom-domimplementation-createdocument'>createDocument</link> - Creates a DOM Document object of the specified type with its document element</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><link linkend='function.dom-domimplementation-createdocumenttype'>createDocumentType</link> - Creates an empty DOMDocumentType object</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><link linkend='function.dom-domimplementation-hasfeature'>hasFeature</link> - Test if the DOM implementation implements a specific feature</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
<section id='dom.class.domnamelist'>
|
||||
<title><classname>DOMNameList</classname></title>
|
||||
<para>
|
||||
|
@ -1019,6 +1043,14 @@
|
|||
<title><classname>DOMXPath</classname></title>
|
||||
<para>
|
||||
</para>
|
||||
<section id='dom.class.domxpath.constructor'>
|
||||
&reftitle.constructor;
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><link linkend='function.dom-domxpath-construct'>__construct</link> - construct a new DOMXPath object</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id='dom.class.domxpath.methods'>
|
||||
&reftitle.methods;
|
||||
<itemizedlist>
|
||||
|
@ -1061,6 +1093,55 @@
|
|||
|
||||
</section>
|
||||
|
||||
<section id="dom.examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
Many examples in this reference require an XML file. We will use the
|
||||
<filename>chapter.xml</filename> that contains the following:
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>chapter.xml</title>
|
||||
<programlisting role="xml">
|
||||
<![CDATA[
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE chapter PUBLIC '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
|
||||
[ <!ENTITY sp "spanish">
|
||||
]>
|
||||
<chapter language="en">
|
||||
<title language="en">Title</title>
|
||||
<para language="ge">
|
||||
&sp;
|
||||
<!-- comment -->
|
||||
<informaltable ID="findme" language="&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>
|
||||
|
||||
|
||||
&reference.dom.constants;
|
||||
|
||||
</partintro>
|
||||
|
|
Loading…
Reference in a new issue